From 3ea03499b75377b1101473b80adb790b09076970 Mon Sep 17 00:00:00 2001 From: Eshaal Syeda Date: Tue, 1 Jul 2025 17:10:17 +0000 Subject: [PATCH 1/4] Combined --- tripadvisor_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tripadvisor_test.py b/tripadvisor_test.py index 44948c4..c3e18ef 100644 --- a/tripadvisor_test.py +++ b/tripadvisor_test.py @@ -1,10 +1,10 @@ import os import requests - TRIPADVISOR_API_KEY = os.getenv('TRIPADVISOR_API_KEY') -'''print("API KEY:", TRIPADVISOR_API_KEY)''' -'''TRIPADVISOR_API_KEY = '6587D61217FA4ED8A4113B9511202EE7''' + +'''print("API KEY:", TRIPADVISOR_API_KEY) +TRIPADVISOR_API_KEY = '6587D61217FA4ED8A4113B9511202EE7''' url = "https://api.content.tripadvisor.com/api/v1/location/search?language=en" From 8d93827cbe1fde77aeaf427911896b1ca0535b39 Mon Sep 17 00:00:00 2001 From: Eshaal Syeda Date: Tue, 1 Jul 2025 17:11:21 +0000 Subject: [PATCH 2/4] Combined --- combined.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 combined.py diff --git a/combined.py b/combined.py new file mode 100644 index 0000000..a654c03 --- /dev/null +++ b/combined.py @@ -0,0 +1,55 @@ +#trip advisor +import os +import requests +from google import genai +from google.genai import types + +# Set environment variables +TRIPADVISOR_API_KEY = os.getenv('TRIPADVISOR_API_KEY') +GENAI_KEY = os.getenv('GENAI_KEY') + +# Create an genAI client using the key from our environment variable +genai.api_key = GENAI_KEY +client = genai.Client( + api_key=my_api_key, +) + +url = "https://api.content.tripadvisor.com/api/v1/location/search?language=en" +data = { + 'key': TRIPADVISOR_API_KEY, + 'searchQuery': cy, + 'category': cate +} + +cy = input("Enter the city that youre looking suggestions for: ") +cate = input("What are you looking for — a hotel, restaurant, or attraction? ") + +response = requests.get(url, params=data) +print(response.status_code) +print(response.json()) + +#gen ai + +# Create an genAI client using the key from our environment variable +client = genai.Client( + api_key=my_api_key, +) + +# AI Prompt +prompt = ( + f"recommend the top {cate} " + f"in {cy} and explain why it's better." +) + +# Specify the model to use and the messages to send +response = client.models.generate_content( + model="gemini-2.5-flash", + config=types.GenerateContentConfig( + system_instruction=( + "You are a nice travel assistant who gives helpful suggestions." + ) + ), + contents=prompt, +) + +print(response.text) From d61ebb9e6d3d0322ef698490c89458a5685bb15f Mon Sep 17 00:00:00 2001 From: Eshaal Syeda Date: Tue, 1 Jul 2025 17:34:10 +0000 Subject: [PATCH 3/4] Combined tripadvisor and genai api --- combined.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/combined.py b/combined.py index a654c03..f07aeef 100644 --- a/combined.py +++ b/combined.py @@ -8,12 +8,15 @@ TRIPADVISOR_API_KEY = os.getenv('TRIPADVISOR_API_KEY') GENAI_KEY = os.getenv('GENAI_KEY') -# Create an genAI client using the key from our environment variable +# Create an genAI client genai.api_key = GENAI_KEY client = genai.Client( - api_key=my_api_key, + api_key=GENAI_KEY, ) +cy = input("Enter the city that youre looking suggestions for: ") +cate = input("What are you looking for — a hotel, restaurant, or attraction? ") + url = "https://api.content.tripadvisor.com/api/v1/location/search?language=en" data = { 'key': TRIPADVISOR_API_KEY, @@ -21,21 +24,10 @@ 'category': cate } -cy = input("Enter the city that youre looking suggestions for: ") -cate = input("What are you looking for — a hotel, restaurant, or attraction? ") - response = requests.get(url, params=data) -print(response.status_code) -print(response.json()) - -#gen ai -# Create an genAI client using the key from our environment variable -client = genai.Client( - api_key=my_api_key, -) +print(response.json()) -# AI Prompt prompt = ( f"recommend the top {cate} " f"in {cy} and explain why it's better." From 7a8a8a3214285d54cb5d0d5a0f248a25861439a9 Mon Sep 17 00:00:00 2001 From: Eshaal Syeda Date: Tue, 1 Jul 2025 17:38:31 +0000 Subject: [PATCH 4/4] Combined tripadvisor and genai api --- combined.py | 1 - 1 file changed, 1 deletion(-) diff --git a/combined.py b/combined.py index f07aeef..eea161f 100644 --- a/combined.py +++ b/combined.py @@ -1,4 +1,3 @@ -#trip advisor import os import requests from google import genai