-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
114 lines (104 loc) · 3.07 KB
/
app.py
File metadata and controls
114 lines (104 loc) · 3.07 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import os
from dotenv import load_dotenv
from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.openweather import OpenWeatherTools
import streamlit as st
st.set_page_config(layout="wide")
# Load environment variables
load_dotenv()
OPENWEATHER_API_KEY = os.getenv("OPENWEATHER_API_KEY")
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
model = os.environ.get("GROQ_MODEL")
# Streamlit custom CSS
st.markdown(
"""
<style>
.stApp {
background-image: url("https://www.vrbo.com/en-ca/vacation-ideas/wp-content/uploads/2lkKD7pTuWxu9RkgtUrF8P/9698dbf3aca9af2aaaeec7035fa63fee/0_128027516__1_.jpg");
background-size: cover;
background-attachment: fixed;
background-position: center;
color: white;
}
.response-box {
background-color: #444;
padding: 15px;
border-radius: 8px;
color: white;
white-space: pre-wrap;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin-top: 10px;
margin-bottom: 10px;
line-height: 1.1;
}
.response-box p {
margin-top: 0;
margin-bottom: 0;
line-height: 1.1;
}
.response-box pre,
.response-box code {
margin: 0;
padding: 5px;
background: #333;
border-radius: 4px;
line-height: 1.1;
}
</style>
""",
unsafe_allow_html=True,
)
st.title("Canadian Travel Assistant")
st.markdown("Ask about destinations, budget, and current weather in Canada.")
# Agents
weather_agent = Agent(
model=Groq(id=model),
tools=[
OpenWeatherTools(
api_key=OPENWEATHER_API_KEY,
units="imperial",
)
],
name="Weather Agent",
markdown=True,
)
destination_agent = Agent(
model=Groq(id=model),
name="Destination Recommender",
instructions="""
You are a Canadian travel expert.
Recommend destinations in Canada based on current weather and user's preferences.
Consider cities like Toronto, Vancouver, Montreal, Quebec City, etc.
""",
markdown=True,
)
budget_agent = Agent(
model=Groq(id=model),
name="Budget Planner",
instructions="""
You are a travel budget planner.
Estimate costs for travel in Canada based on city, number of days,
and travel style (budget, mid-range, luxury).
Include accommodation, transport, and food costs.
""",
markdown=True,
)
def route_query(query: str):
q = query.lower()
if any(word in q for word in ["weather", "temperature", "climate", "forecast"]):
return weather_agent
elif any(word in q for word in ["budget", "cost", "price", "expenses"]):
return budget_agent
else:
return destination_agent
user_query = st.text_input("✈️ Enter your travel query:")
if user_query:
with st.spinner("Thinking..."):
agent = route_query(user_query)
response = agent.run(user_query)
if response.content:
st.markdown(
f'<div class="response-box">{response.content}</div>',
unsafe_allow_html=True,
)