diff --git a/README.md b/README.md index f8fce4e..82de8cf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Travel.AI is a Python-based tool that integrates the TripAdvisor API with Google Gemini API to recommend the best hotels, restaurants, or attractions based on user input and location. - ## General Info This project was developed as part of the SEO Tech Developer program. It demonstrates how to: @@ -12,7 +11,9 @@ This project was developed as part of the SEO Tech Developer program. It demonst - Store and manage results in a local database - Integrate AI reasoning via Google Gemini -## Technologies Used +## Technologies + +This project uses: - Python 3.11+ - Pandas @@ -28,4 +29,4 @@ This project was developed as part of the SEO Tech Developer program. It demonst ## Contact - **William Du** – [wiiidu315@gmail.com](mailto:wiiidu315@gmail.com) -- **Eshaal Syeda** – [eshaal.syeda@richmond.edu](mailto:eshaal.syeda@richmond.edu) +- **Eshaal Syeda** – [eshaal.syeda@richmond.edu](mailto:eshaal.syeda@richmond.edu) \ No newline at end of file diff --git a/combined.py b/combined.py index 1c8a4c7..497518e 100644 --- a/combined.py +++ b/combined.py @@ -28,35 +28,48 @@ response = requests.get(url, params=data) data_of_trip = response.json() -results = data_of_trip.get('data', []) -top_five = [] +#results = data_of_trip.get('data', []) + +'''top_five = [] + for given in results[:5]: name = given.get('name') if name: top_five.append(name) -combined = ','.join(top_five) -prompt = ( - f"recommend the top {cate} " - f"in {cy}: {combined}." - "based on these, recommend the better one and why" - "two to three sentences" -) - -# Specify the model to use and the messages to send -ai_response = client.models.generate_content( - model="gemini-2.5-flash", - config=types.GenerateContentConfig( - system_instruction=( - "You are a helpful travel assistant." - ) - ), - contents=prompt, -) +combined = ','.join(top_five)''' -print(ai_response.text) parser = Parser(data_of_trip) -parser.write_to_database('locations') +parser.write_to_database(cate) + +# Pull stored results +db_results = parser.pull_list(cate, cy) +for row in db_results: + name = row._mapping.get('name') + + prompt = ( + f"{name} is a {cate} " + f"in {cy}." + "respond in two to three sentences why its good" + ) + + # Specify the model to use and the messages to send + ai_response = client.models.generate_content( + model="gemini-2.5-flash", + config=types.GenerateContentConfig( + system_instruction=( + "You are a helpful travel assistant." + ) + ), + contents=prompt, + ) + + print(ai_response.text) + + another_sugg = input("Do you want another suggestion? (Yes/No): ").lower().strip() + if another_sugg != "yes": + print("Enjoy!") + break diff --git a/json_parsing.py b/json_parsing.py index 238b315..2b0a05d 100644 --- a/json_parsing.py +++ b/json_parsing.py @@ -7,7 +7,7 @@ class Parser: - + def __init__(self, json): load_dotenv() if 'data' in json: @@ -37,7 +37,8 @@ def pull_list(self, table_name, city): f"WHERE \"address_obj.city\" = '{city}' LIMIT 10;") with self.engine.connect() as connection: result = connection.execute(db.text(query)).fetchall() - print(pd.DataFrame(result)) + return result + def drop(self, table_name): command = f"DROP TABLE IF EXISTS {table_name}"