diff --git a/Project1-PairProgramming.py b/Project1-PairProgramming.py new file mode 100644 index 0000000..10d4d97 --- /dev/null +++ b/Project1-PairProgramming.py @@ -0,0 +1,37 @@ +'''Codio Day5 module: Google GenAI API.''' + +import os +from google import genai +from google.genai import types + +# Set environment variables +my_api_key = os.getenv('GENAI_KEY') +genai.api_key = my_api_key + +# Create an genAI client using the key from our environment variable +client = genai.Client( + api_key=my_api_key, +) + +# User Inputs +cy = input("Enter the city that youre looking suggestions for: ") +cate = input("What are you looking for — a hotel, restaurant, or attraction? ") + +# 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) diff --git a/tripadvisor_test.py b/tripadvisor_test.py new file mode 100644 index 0000000..44948c4 --- /dev/null +++ b/tripadvisor_test.py @@ -0,0 +1,22 @@ +import os +import requests + + +TRIPADVISOR_API_KEY = os.getenv('TRIPADVISOR_API_KEY') +'''print("API KEY:", TRIPADVISOR_API_KEY)''' +'''TRIPADVISOR_API_KEY = '6587D61217FA4ED8A4113B9511202EE7''' + +url = "https://api.content.tripadvisor.com/api/v1/location/search?language=en" + +cy = input("Enter the city that youre looking suggestions for: ") +cate = input("What are you looking for — a hotel, restaurant, or attraction? ") + +data = { + 'key': TRIPADVISOR_API_KEY, + 'searchQuery': cy, + 'category': cate +} + +response = requests.get(url, params=data) +print(response.status_code) +print(response.json())