Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from langchain.memory import ConversationBufferMemory
|
|
| 11 |
from langchain.chains import ConversationChain
|
| 12 |
from langchain_community.llms import HuggingFaceHub
|
| 13 |
|
|
|
|
| 14 |
# 🔓 Extract .streamlit folder if zipped
|
| 15 |
if not os.path.exists(".streamlit"):
|
| 16 |
with zipfile.ZipFile(".streamlit.zip", 'r') as zip_ref:
|
|
@@ -20,10 +21,10 @@ if not os.path.exists(".streamlit"):
|
|
| 20 |
load_dotenv()
|
| 21 |
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
| 22 |
|
| 23 |
-
# ✅ Initialize LangChain LLM
|
| 24 |
llm = HuggingFaceHub(
|
| 25 |
-
repo_id="
|
| 26 |
-
model_kwargs={"temperature": 0.7, "max_new_tokens":
|
| 27 |
huggingfacehub_api_token=HF_API_TOKEN
|
| 28 |
)
|
| 29 |
|
|
@@ -67,7 +68,7 @@ generate_button = st.button("✈️ Generate Trip Plan")
|
|
| 67 |
if generate_button:
|
| 68 |
if from_location and destination and budget and preferences and start_date and end_date:
|
| 69 |
user_prompt = (
|
| 70 |
-
f"Create a detailed day-wise travel itinerary with bullets and headings for a trip from {from_location} to {destination} in India. "
|
| 71 |
f"The trip should start on {start_date.strftime('%B %d, %Y')} and end on {end_date.strftime('%B %d, %Y')}, "
|
| 72 |
f"with a total budget of ₹{budget} INR. The traveler prefers {preferences.lower()} experiences. \n\n"
|
| 73 |
f"Provide a **day-wise breakdown** of the trip including:\n"
|
|
@@ -100,3 +101,4 @@ if follow_up:
|
|
| 100 |
with st.spinner("💡 Thinking..."):
|
| 101 |
response = st.session_state.conversation.run(follow_up)
|
| 102 |
st.markdown(f"**AI:** {response}")
|
|
|
|
|
|
| 11 |
from langchain.chains import ConversationChain
|
| 12 |
from langchain_community.llms import HuggingFaceHub
|
| 13 |
|
| 14 |
+
|
| 15 |
# 🔓 Extract .streamlit folder if zipped
|
| 16 |
if not os.path.exists(".streamlit"):
|
| 17 |
with zipfile.ZipFile(".streamlit.zip", 'r') as zip_ref:
|
|
|
|
| 21 |
load_dotenv()
|
| 22 |
HF_API_TOKEN = os.getenv("HF_API_TOKEN")
|
| 23 |
|
| 24 |
+
# ✅ Initialize LangChain LLM
|
| 25 |
llm = HuggingFaceHub(
|
| 26 |
+
repo_id="mistralai/Mistral-7B-Instruct-v0.1",
|
| 27 |
+
model_kwargs={"temperature": 0.7, "max_new_tokens": 2048},
|
| 28 |
huggingfacehub_api_token=HF_API_TOKEN
|
| 29 |
)
|
| 30 |
|
|
|
|
| 68 |
if generate_button:
|
| 69 |
if from_location and destination and budget and preferences and start_date and end_date:
|
| 70 |
user_prompt = (
|
| 71 |
+
f"Create a detailed day-wise travel itinerary with properly structured bullets and headings for a trip from {from_location} to {destination} in India. "
|
| 72 |
f"The trip should start on {start_date.strftime('%B %d, %Y')} and end on {end_date.strftime('%B %d, %Y')}, "
|
| 73 |
f"with a total budget of ₹{budget} INR. The traveler prefers {preferences.lower()} experiences. \n\n"
|
| 74 |
f"Provide a **day-wise breakdown** of the trip including:\n"
|
|
|
|
| 101 |
with st.spinner("💡 Thinking..."):
|
| 102 |
response = st.session_state.conversation.run(follow_up)
|
| 103 |
st.markdown(f"**AI:** {response}")
|
| 104 |
+
|