Abhishek7664 commited on
Commit
b8cbad0
·
verified ·
1 Parent(s): ac3bd97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -41
app.py CHANGED
@@ -1,41 +1,53 @@
1
- import os
2
- import streamlit as st
3
- from langchain_google_genai import ChatGoogleGenerativeAI
4
- from langchain.schema import SystemMessage, HumanMessage
5
- from langchain.chains import LLMChain
6
- from langchain.prompts import PromptTemplate
7
- from dotenv import load_dotenv
8
-
9
- # Load environment variables
10
- load_dotenv()
11
- GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
12
-
13
- # Initialize AI Model
14
- llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", google_api_key=GOOGLE_API_KEY)
15
-
16
- # Define a Prompt Template
17
- prompt = PromptTemplate(
18
- input_variables=["source", "destination"],
19
- template="""
20
- Provide the best travel options from {source} to {destination}.
21
- Include estimated costs for cab, train, bus, and flights.
22
- Format the response in a structured way.
23
- """
24
- )
25
-
26
- # Streamlit UI
27
- st.title("AI-Powered Travel Planner")
28
- source = st.text_input("Enter Source:")
29
- destination = st.text_input("Enter Destination:")
30
-
31
- if st.button("Find Travel Options"):
32
- if source and destination:
33
- messages = [
34
- SystemMessage(content="You are an AI travel assistant. Provide detailed and structured travel recommendations."),
35
- HumanMessage(content=f"Find the best travel options from {source} to {destination}, including estimated costs for cab, train, bus, and flights.")
36
- ]
37
- response = llm(messages)
38
- st.write("### Travel Recommendations:")
39
- st.write(response.content)
40
- else:
41
- st.warning("Please enter both source and destination.")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from langchain_google_genai import ChatGoogleGenerativeAI
4
+ from langchain.schema import SystemMessage, HumanMessage
5
+ from langchain.chains import LLMChain
6
+ from langchain.prompts import PromptTemplate
7
+ from dotenv import load_dotenv
8
+
9
+ # Load environment variables
10
+ load_dotenv()
11
+ GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
12
+
13
+ # Initialize AI Model
14
+ llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", google_api_key=GOOGLE_API_KEY)
15
+
16
+ # Define a Prompt Template
17
+ prompt = PromptTemplate(
18
+ input_variables=["source", "destination"],
19
+ template="""
20
+ You are an AI-powered travel planner.
21
+
22
+ Plan a detailed {}-day budget trip from {source} to {destination}.
23
+
24
+ Include:
25
+ 1. **Travel Options** — cab, train, bus, and flight with estimated one-way and roundtrip costs.
26
+ 2. **Stay Options** — budget, mid-range, and premium stays with approximate cost per night.
27
+ 3. **Local Transport** — average cost per day for autos, e-rickshaws, or cabs.
28
+ 4. **Food & Drinks** — per-day budget for local meals.
29
+ 5. **Extra Costs** — sightseeing entry, boat rides, shopping, etc.
30
+ 6. **Total Estimated Cost** — show total for 4 days (low-budget and mid-range).
31
+ 7. **Sample Itinerary (Day-wise)** — brief plan for 4 days.
32
+
33
+ Format the response clearly using markdown (### headings and bullet points).
34
+ """
35
+ )
36
+
37
+ # Streamlit UI
38
+ st.title("AI-Powered Travel Planner")
39
+ source = st.text_input("Enter Source:")
40
+ destination = st.text_input("Enter Destination:")
41
+
42
+ if st.button("Find Travel Options"):
43
+ if source and destination:
44
+ messages = [
45
+ SystemMessage(content="You are an AI travel assistant."),
46
+ HumanMessage(content=prompt.format(source=source, destination=destination))
47
+ ]
48
+ response = llm(messages)
49
+ st.write("### Travel Recommendations:")
50
+ st.markdown(response.content)
51
+ else:
52
+ st.warning("Please enter both source and destination.")
53
+