Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .hfignore +52 -5
- README.md +14 -1
- app/=4.44.1 +0 -0
- app/app.py +136 -0
- app/bkp/Dockerfile +18 -0
- app/bkp/streamlit_app.py +83 -0
- app/requirements.txt +4 -1
- requirements-local.txt +1 -1
- requirements.txt +1 -2
- uv.lock +8 -0
.hfignore
CHANGED
|
@@ -1,5 +1,52 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
*.
|
| 4 |
-
*.
|
| 5 |
-
*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ignore Python cache and virtual environments
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
*.pyo
|
| 5 |
+
*.pyd
|
| 6 |
+
.venv/
|
| 7 |
+
venv/
|
| 8 |
+
env/
|
| 9 |
+
ENV/
|
| 10 |
+
|
| 11 |
+
# Ignore notebooks checkpoints
|
| 12 |
+
.ipynb_checkpoints/
|
| 13 |
+
|
| 14 |
+
# Ignore system files
|
| 15 |
+
.DS_Store
|
| 16 |
+
Thumbs.db
|
| 17 |
+
|
| 18 |
+
# Ignore logs and temp files
|
| 19 |
+
*.log
|
| 20 |
+
*.tmp
|
| 21 |
+
*.bak
|
| 22 |
+
|
| 23 |
+
# Ignore environment and secret files
|
| 24 |
+
.env
|
| 25 |
+
*.env
|
| 26 |
+
.env.*
|
| 27 |
+
secrets.json
|
| 28 |
+
config.json
|
| 29 |
+
|
| 30 |
+
# Ignore build artifacts
|
| 31 |
+
dist/
|
| 32 |
+
build/
|
| 33 |
+
*.egg-info/
|
| 34 |
+
|
| 35 |
+
# Ignore datasets or large local data files
|
| 36 |
+
data/
|
| 37 |
+
*.csv
|
| 38 |
+
*.tsv
|
| 39 |
+
*.xlsx
|
| 40 |
+
*.parquet
|
| 41 |
+
|
| 42 |
+
# Ignore tests and docs (optional)
|
| 43 |
+
tests/
|
| 44 |
+
docs/
|
| 45 |
+
|
| 46 |
+
# Ignore Git folders
|
| 47 |
+
.git/
|
| 48 |
+
.gitignore
|
| 49 |
+
|
| 50 |
+
# Hugging Face specific
|
| 51 |
+
.hf_cache/
|
| 52 |
+
output/
|
README.md
CHANGED
|
@@ -23,7 +23,7 @@ following features:
|
|
| 23 |
uv init ai-trip-planner
|
| 24 |
```
|
| 25 |
|
| 26 |
-
## Create a virtual environment
|
| 27 |
uv is like npm in nodejs. uv is created using RUST language.
|
| 28 |
```
|
| 29 |
uv python list
|
|
@@ -36,6 +36,19 @@ source .venv/bin/activate
|
|
| 36 |
|
| 37 |
deactivate
|
| 38 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
## Install the packages
|
| 40 |
```
|
| 41 |
uv pip install -r requirements.txt
|
|
|
|
| 23 |
uv init ai-trip-planner
|
| 24 |
```
|
| 25 |
|
| 26 |
+
## Create a virtual environment - option1
|
| 27 |
uv is like npm in nodejs. uv is created using RUST language.
|
| 28 |
```
|
| 29 |
uv python list
|
|
|
|
| 36 |
|
| 37 |
deactivate
|
| 38 |
```
|
| 39 |
+
|
| 40 |
+
## Create a virtual environment - option2
|
| 41 |
+
uv is like npm in nodejs. uv is created using RUST language.
|
| 42 |
+
```
|
| 43 |
+
uv python list
|
| 44 |
+
|
| 45 |
+
conda create --prefix /home/azureuser/ws/agenticai/projects/ai-trip-planner/.venv python=3.11 -y
|
| 46 |
+
|
| 47 |
+
conda activate /home/azureuser/ws/agenticai/projects/ai-trip-planner/.venv
|
| 48 |
+
|
| 49 |
+
conda deactivate
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
## Install the packages
|
| 53 |
```
|
| 54 |
uv pip install -r requirements.txt
|
app/=4.44.1
ADDED
|
File without changes
|
app/app.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import datetime
|
| 4 |
+
import os
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
|
| 7 |
+
# Load environment variables
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
# Backend endpoint - use environment variable or default to Hugging Face
|
| 11 |
+
BASE_URL = os.getenv("API_BASE_URL", "https://mishrabp-trip-advisor-api.hf.space")
|
| 12 |
+
|
| 13 |
+
def format_travel_plan(answer):
|
| 14 |
+
"""Format the travel plan response with markdown styling"""
|
| 15 |
+
return f"""### πΊοΈ AI-Generated Travel Plan
|
| 16 |
+
**Generated:** {datetime.datetime.now().strftime('%Y-%m-%d at %H:%M')}
|
| 17 |
+
**Created by:** Kube9t's Travel Agent
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
{answer}
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
π *Please double-check all travel details, costs, and dates before booking.*"""
|
| 26 |
+
|
| 27 |
+
def query_travel_agent(message, history):
|
| 28 |
+
"""Handle the travel agent query and format the response"""
|
| 29 |
+
try:
|
| 30 |
+
# Make API request
|
| 31 |
+
payload = {"question": message}
|
| 32 |
+
response = requests.post(f"{BASE_URL}/query", json=payload)
|
| 33 |
+
|
| 34 |
+
if response.status_code == 200:
|
| 35 |
+
answer = response.json().get("answer", "No answer returned.")
|
| 36 |
+
formatted_response = {
|
| 37 |
+
"role": "assistant",
|
| 38 |
+
"content": format_travel_plan(answer)
|
| 39 |
+
}
|
| 40 |
+
else:
|
| 41 |
+
formatted_response = {
|
| 42 |
+
"role": "assistant",
|
| 43 |
+
"content": f"β Bot failed to respond: {response.text}"
|
| 44 |
+
}
|
| 45 |
+
except Exception as e:
|
| 46 |
+
formatted_response = {
|
| 47 |
+
"role": "assistant",
|
| 48 |
+
"content": f"β οΈ Something went wrong: {str(e)}"
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
# Return updated history
|
| 52 |
+
return history + [
|
| 53 |
+
{"role": "user", "content": message},
|
| 54 |
+
formatted_response
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
def create_demo():
|
| 58 |
+
"""Create and configure the Gradio interface"""
|
| 59 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 60 |
+
# Header
|
| 61 |
+
gr.Markdown(
|
| 62 |
+
"""
|
| 63 |
+
# π Travel Planner Agentic Application
|
| 64 |
+
Let me help you design your next perfect trip β just tell me where you want to go!
|
| 65 |
+
"""
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
with gr.Row():
|
| 69 |
+
# Sidebar
|
| 70 |
+
with gr.Column(scale=1):
|
| 71 |
+
gr.Image(
|
| 72 |
+
"https://cdn-icons-png.flaticon.com/512/201/201623.png",
|
| 73 |
+
width=80,
|
| 74 |
+
show_label=False
|
| 75 |
+
)
|
| 76 |
+
gr.Markdown("### Navigation")
|
| 77 |
+
gr.Markdown("- π Home\n- π§³ My Trips\n- βοΈ Settings")
|
| 78 |
+
gr.Markdown("---")
|
| 79 |
+
gr.Markdown("*Powered by Kube9t's Travel Agent AI*")
|
| 80 |
+
|
| 81 |
+
# Main chat interface
|
| 82 |
+
with gr.Column(scale=3):
|
| 83 |
+
chatbot = gr.Chatbot(
|
| 84 |
+
height=400,
|
| 85 |
+
show_label=False,
|
| 86 |
+
avatar_images=["π€", "π€"],
|
| 87 |
+
type="messages" # Use new message format
|
| 88 |
+
)
|
| 89 |
+
msg = gr.Textbox(
|
| 90 |
+
label="Ask me something like: 'Plan a 7 days trip to Washington-DC, NewYork, and Niagra.'",
|
| 91 |
+
placeholder="Type your travel query here...",
|
| 92 |
+
lines=2
|
| 93 |
+
)
|
| 94 |
+
with gr.Row():
|
| 95 |
+
submit = gr.Button("Send", variant="primary")
|
| 96 |
+
clear = gr.Button("Clear")
|
| 97 |
+
|
| 98 |
+
# Event handlers
|
| 99 |
+
msg.submit(
|
| 100 |
+
fn=query_travel_agent,
|
| 101 |
+
inputs=[msg, chatbot],
|
| 102 |
+
outputs=chatbot
|
| 103 |
+
).then(
|
| 104 |
+
fn=lambda: "",
|
| 105 |
+
outputs=msg
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
submit.click(
|
| 109 |
+
fn=query_travel_agent,
|
| 110 |
+
inputs=[msg, chatbot],
|
| 111 |
+
outputs=chatbot
|
| 112 |
+
).then(
|
| 113 |
+
fn=lambda: "",
|
| 114 |
+
outputs=msg
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
clear.click(lambda: [], outputs=chatbot)
|
| 118 |
+
|
| 119 |
+
return demo
|
| 120 |
+
|
| 121 |
+
# Create and launch the app
|
| 122 |
+
app = create_demo()
|
| 123 |
+
|
| 124 |
+
if __name__ == "__main__":
|
| 125 |
+
# Determine if running locally
|
| 126 |
+
is_local = os.getenv("RUNNING_LOCAL", "false").lower() == "true"
|
| 127 |
+
|
| 128 |
+
# Launch with appropriate settings
|
| 129 |
+
if is_local:
|
| 130 |
+
app.launch(
|
| 131 |
+
server_name="127.0.0.1",
|
| 132 |
+
server_port=7860,
|
| 133 |
+
share=False
|
| 134 |
+
)
|
| 135 |
+
else:
|
| 136 |
+
app.launch()
|
app/bkp/Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use lightweight Python base image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy app code and requirements
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
COPY . .
|
| 10 |
+
|
| 11 |
+
# Install dependencies
|
| 12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# Expose HF Spaces port
|
| 15 |
+
EXPOSE 7860
|
| 16 |
+
|
| 17 |
+
# Run Streamlit using the shell form (RECOMMENDED FIX)
|
| 18 |
+
CMD streamlit run ./streamlit_app.py --server.port=7860 --server.headless=true
|
app/bkp/streamlit_app.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import datetime
|
| 4 |
+
|
| 5 |
+
BASE_URL = "https://mishrabp-trip-advisor-api.hf.space/" # Backend endpoint
|
| 6 |
+
|
| 7 |
+
# Set up Streamlit page configuration
|
| 8 |
+
st.set_page_config(
|
| 9 |
+
page_title="Travel Planner Agentic Application",
|
| 10 |
+
page_icon="π",
|
| 11 |
+
layout="wide",
|
| 12 |
+
initial_sidebar_state="expanded",
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# ---------------------------
|
| 16 |
+
# Sidebar Navigation
|
| 17 |
+
# ---------------------------
|
| 18 |
+
with st.sidebar:
|
| 19 |
+
st.image("https://cdn-icons-png.flaticon.com/512/201/201623.png", width=80)
|
| 20 |
+
st.title("π Travel Planner")
|
| 21 |
+
st.markdown("Plan your trips effortlessly with AI βοΈ")
|
| 22 |
+
st.markdown("---")
|
| 23 |
+
st.subheader("Navigation")
|
| 24 |
+
st.page_link("https://openai.com", label="π Home", disabled=True)
|
| 25 |
+
st.page_link("https://openai.com", label="π§³ My Trips", disabled=True)
|
| 26 |
+
st.page_link("https://openai.com", label="βοΈ Settings", disabled=True)
|
| 27 |
+
st.markdown("---")
|
| 28 |
+
st.caption("Powered by Kube9t's Travel Agent AI")
|
| 29 |
+
|
| 30 |
+
# ---------------------------
|
| 31 |
+
# Hero Section
|
| 32 |
+
# ---------------------------
|
| 33 |
+
st.markdown(
|
| 34 |
+
"""
|
| 35 |
+
<div style="background-color:#0c2a45; padding:2rem 1rem; border-radius:10px;">
|
| 36 |
+
<h1 style="color:white; text-align:center;">π Travel Planner Agentic Application</h1>
|
| 37 |
+
<p style="color:white; text-align:center; font-size:1.2rem;">
|
| 38 |
+
Let me help you design your next perfect trip β just tell me where you want to go!
|
| 39 |
+
</p>
|
| 40 |
+
</div>
|
| 41 |
+
""",
|
| 42 |
+
unsafe_allow_html=True
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
st.markdown("### β¨ What can I help you plan today?")
|
| 46 |
+
|
| 47 |
+
# Initialize chat history
|
| 48 |
+
if "messages" not in st.session_state:
|
| 49 |
+
st.session_state.messages = []
|
| 50 |
+
|
| 51 |
+
# Chat input form
|
| 52 |
+
with st.form(key="query_form", clear_on_submit=True):
|
| 53 |
+
user_input = st.text_input("Ask me something like: 'Plan a 7 days trip to Washnigton-DC, NewYork, and Niagra.'")
|
| 54 |
+
submit_button = st.form_submit_button("Send")
|
| 55 |
+
|
| 56 |
+
# Handle form submission
|
| 57 |
+
if submit_button and user_input.strip():
|
| 58 |
+
try:
|
| 59 |
+
with st.spinner("π§ Thinking..."):
|
| 60 |
+
payload = {"question": user_input}
|
| 61 |
+
response = requests.post(f"{BASE_URL}/query", json=payload)
|
| 62 |
+
|
| 63 |
+
if response.status_code == 200:
|
| 64 |
+
answer = response.json().get("answer", "No answer returned.")
|
| 65 |
+
markdown_content = f"""
|
| 66 |
+
### πΊοΈ AI-Generated Travel Plan
|
| 67 |
+
**Generated:** {datetime.datetime.now().strftime('%Y-%m-%d at %H:%M')}
|
| 68 |
+
**Created by:** Kube9t's Travel Agent
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
{answer}
|
| 73 |
+
|
| 74 |
+
---
|
| 75 |
+
|
| 76 |
+
π *Please double-check all travel details, costs, and dates before booking.*
|
| 77 |
+
"""
|
| 78 |
+
st.markdown(markdown_content)
|
| 79 |
+
else:
|
| 80 |
+
st.error("β Bot failed to respond: " + response.text)
|
| 81 |
+
|
| 82 |
+
except Exception as e:
|
| 83 |
+
st.error(f"β οΈ Something went wrong: {e}")
|
app/requirements.txt
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
streamlit
|
| 2 |
altair
|
| 3 |
pandas
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
streamlit
|
| 2 |
altair
|
| 3 |
pandas
|
| 4 |
+
gradio>=4.44.1
|
| 5 |
+
requests==2.31.0
|
| 6 |
+
python-dotenv==1.0.1
|
| 7 |
+
|
requirements-local.txt
CHANGED
|
@@ -15,6 +15,6 @@ httpx
|
|
| 15 |
requests
|
| 16 |
azure-identity
|
| 17 |
mlflow
|
| 18 |
-
gradio
|
| 19 |
|
| 20 |
-e .
|
|
|
|
| 15 |
requests
|
| 16 |
azure-identity
|
| 17 |
mlflow
|
| 18 |
+
gradio>=4.44.1
|
| 19 |
|
| 20 |
-e .
|
requirements.txt
CHANGED
|
@@ -9,10 +9,9 @@ langchain_groq
|
|
| 9 |
langchain_openai
|
| 10 |
fastapi
|
| 11 |
python-dotenv
|
| 12 |
-
streamlit
|
| 13 |
uvicorn
|
| 14 |
httpx
|
| 15 |
requests
|
| 16 |
azure-identity
|
| 17 |
mlflow
|
| 18 |
-
gradio
|
|
|
|
| 9 |
langchain_openai
|
| 10 |
fastapi
|
| 11 |
python-dotenv
|
|
|
|
| 12 |
uvicorn
|
| 13 |
httpx
|
| 14 |
requests
|
| 15 |
azure-identity
|
| 16 |
mlflow
|
| 17 |
+
gradio==4.19.2
|
uv.lock
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = 1
|
| 2 |
+
revision = 2
|
| 3 |
+
requires-python = ">=3.11"
|
| 4 |
+
|
| 5 |
+
[[package]]
|
| 6 |
+
name = "ai-trip-planner"
|
| 7 |
+
version = "0.1.0"
|
| 8 |
+
source = { virtual = "." }
|