-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (49 loc) · 1.59 KB
/
main.py
File metadata and controls
63 lines (49 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
"""
Travel Planner - Main entry point
"""
import sys
from config import load_api_keys
from models.travel_plan import TravelPlan
from ui.cli import TravelPlannerCLI
from services.flight_service import FlightService
from services.hotel_service import HotelService
from services.activity_service import ActivityService
from langchain_openai import OpenAI
def main():
"""Main application entry point"""
print("Welcome to Travel Planner!")
print("Loading configuration...")
# Load API keys
keys = load_api_keys()
# Initialize LLM
llm = OpenAI(openai_api_key=keys['openai_api_key'], temperature=0.7)
# Initialize services
flight_service = FlightService(
amadeus_client_id=keys['amadeus_client_id'],
amadeus_client_secret=keys['amadeus_client_secret'],
google_maps_key=keys['google_maps_key'],
llm=llm
)
hotel_service = HotelService(llm=llm)
activity_service = ActivityService(llm=llm)
# Create new travel plan
travel_plan = TravelPlan()
# Initialize UI with services
cli = TravelPlannerCLI(
travel_plan=travel_plan,
flight_service=flight_service,
hotel_service=hotel_service,
activity_service=activity_service
)
# Run the CLI
cli.collect_initial_details()
cli.show_main_menu()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nTravel planning interrupted. Goodbye!")
except Exception as e:
print(f"\nAn error occurred: {e}")
print("Please try again later.")