Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -741,14 +741,17 @@ with st.sidebar:
|
|
| 741 |
if st.session_state.get("mcp_connected", False):
|
| 742 |
st.info("MCP integration is active! You'll receive context-aware travel recommendations.")
|
| 743 |
else:
|
| 744 |
-
|
| 745 |
-
st.
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
|
|
|
|
|
|
|
|
|
| 752 |
|
| 753 |
# Add MongoDB and OpenAI integration section ONLY if the modules are available
|
| 754 |
if MONGODB_AVAILABLE and OPENAI_AVAILABLE:
|
|
@@ -781,24 +784,24 @@ with st.sidebar:
|
|
| 781 |
initialize_mongodb_collection()
|
| 782 |
else:
|
| 783 |
st.warning("Please provide an OpenAI API key for vector search functionality.")
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
st.
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
|
| 803 |
# About section
|
| 804 |
st.markdown("### โน๏ธ " + t("about"))
|
|
@@ -814,29 +817,6 @@ with st.sidebar:
|
|
| 814 |
"transportation, activities, dining, and itinerary creation."
|
| 815 |
)
|
| 816 |
|
| 817 |
-
# Show notification for MCP if unavailable
|
| 818 |
-
if not MCP_AVAILABLE:
|
| 819 |
-
# Add notification about optional MCP features
|
| 820 |
-
st.sidebar.markdown("""
|
| 821 |
-
<div style="padding: 10px; border-radius: 5px; margin-bottom: 10px; background-color: #f8f9fa; border-left: 3px solid #3366cc;">
|
| 822 |
-
<b>โน๏ธ Optional Feature Unavailable</b><br>
|
| 823 |
-
Model Context Protocol integration is unavailable because the required packages are not installed.
|
| 824 |
-
<code>pip install mcp-python-sdk</code> to enable this feature.
|
| 825 |
-
</div>
|
| 826 |
-
""", unsafe_allow_html=True)
|
| 827 |
-
|
| 828 |
-
# Don't check again - these variables are already defined at the top of the script
|
| 829 |
-
# Just show a notification based on their values
|
| 830 |
-
if not MONGODB_AVAILABLE or not OPENAI_AVAILABLE:
|
| 831 |
-
# Add notification at the top of the app about optional MongoDB features
|
| 832 |
-
st.sidebar.markdown("""
|
| 833 |
-
<div style="padding: 10px; border-radius: 5px; margin-bottom: 10px; background-color: #f8f9fa; border-left: 3px solid #046A38;">
|
| 834 |
-
<b>โน๏ธ Optional Feature Unavailable</b><br>
|
| 835 |
-
MongoDB geo-based recommendations are unavailable because the required packages are not installed.
|
| 836 |
-
<code>pip install pymongo openai</code> to enable this feature.
|
| 837 |
-
</div>
|
| 838 |
-
""", unsafe_allow_html=True)
|
| 839 |
-
|
| 840 |
# Add travel form
|
| 841 |
st.markdown("## " + t("create_itinerary"))
|
| 842 |
st.markdown("### " + t("trip_details"))
|
|
@@ -1062,29 +1042,49 @@ with tabs[0]:
|
|
| 1062 |
if 'tailvy_api_key' in st.session_state and st.session_state.tailvy_api_key and 'tailvy_used' in st.session_state and st.session_state.tailvy_used:
|
| 1063 |
st.markdown(
|
| 1064 |
"""
|
| 1065 |
-
<div style="display: inline-block; background-color: #046A38; color: white;
|
| 1066 |
padding: 5px 10px; border-radius: 15px; margin-bottom: 10px; font-size: 0.8rem;">
|
| 1067 |
โจ Enhanced with Tailvy AI
|
| 1068 |
</div>
|
| 1069 |
-
""",
|
| 1070 |
unsafe_allow_html=True
|
| 1071 |
)
|
| 1072 |
-
|
| 1073 |
-
st.markdown('<div class="output-container"><div class="output-text">' +
|
| 1074 |
-
st.session_state.generated_itinerary + '</div></div>',
|
| 1075 |
unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
|
| 1077 |
# Details tab
|
| 1078 |
with tabs[1]:
|
| 1079 |
-
if st.session_state.step_results.get("destination_research"):
|
| 1080 |
-
st.
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
st.
|
| 1086 |
-
|
| 1087 |
-
|
|
|
|
|
|
|
|
|
|
| 1088 |
|
| 1089 |
# Download and share tab
|
| 1090 |
with tabs[2]:
|
|
@@ -1095,6 +1095,8 @@ with tabs[2]:
|
|
| 1095 |
download_link = get_download_link(st.session_state.generated_itinerary, f"Travel_Itinerary_{destination.replace(' ', '_')}.txt")
|
| 1096 |
st.markdown(download_link, unsafe_allow_html=True)
|
| 1097 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
| 1098 |
|
| 1099 |
# Maps and visualization tab
|
| 1100 |
with tabs[3]:
|
|
|
|
| 741 |
if st.session_state.get("mcp_connected", False):
|
| 742 |
st.info("MCP integration is active! You'll receive context-aware travel recommendations.")
|
| 743 |
else:
|
| 744 |
+
# Show collapsed expander for optional MCP feature
|
| 745 |
+
with st.expander("๐ง Model Context Protocol (Optional)", expanded=False):
|
| 746 |
+
st.caption("""
|
| 747 |
+
**Context-aware AI** - Enhance responses with Model Context Protocol
|
| 748 |
+
|
| 749 |
+
To enable this optional feature:
|
| 750 |
+
```bash
|
| 751 |
+
pip install mcp-python-sdk
|
| 752 |
+
```
|
| 753 |
+
Then restart the application.
|
| 754 |
+
""")
|
| 755 |
|
| 756 |
# Add MongoDB and OpenAI integration section ONLY if the modules are available
|
| 757 |
if MONGODB_AVAILABLE and OPENAI_AVAILABLE:
|
|
|
|
| 784 |
initialize_mongodb_collection()
|
| 785 |
else:
|
| 786 |
st.warning("Please provide an OpenAI API key for vector search functionality.")
|
| 787 |
+
else:
|
| 788 |
+
# Show collapsed expander for optional MongoDB feature
|
| 789 |
+
with st.expander("๐บ๏ธ MongoDB Geo Search (Optional)", expanded=False):
|
| 790 |
+
missing_packages = []
|
| 791 |
+
if not MONGODB_AVAILABLE:
|
| 792 |
+
missing_packages.append("pymongo")
|
| 793 |
+
if not OPENAI_AVAILABLE:
|
| 794 |
+
missing_packages.append("openai")
|
| 795 |
+
|
| 796 |
+
st.caption(f"""
|
| 797 |
+
**Location-based recommendations** - Find nearby attractions with MongoDB Atlas
|
| 798 |
+
|
| 799 |
+
To enable this optional feature:
|
| 800 |
+
```bash
|
| 801 |
+
pip install {' '.join(missing_packages)}
|
| 802 |
+
```
|
| 803 |
+
Then restart the application.
|
| 804 |
+
""")
|
| 805 |
|
| 806 |
# About section
|
| 807 |
st.markdown("### โน๏ธ " + t("about"))
|
|
|
|
| 817 |
"transportation, activities, dining, and itinerary creation."
|
| 818 |
)
|
| 819 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 820 |
# Add travel form
|
| 821 |
st.markdown("## " + t("create_itinerary"))
|
| 822 |
st.markdown("### " + t("trip_details"))
|
|
|
|
| 1042 |
if 'tailvy_api_key' in st.session_state and st.session_state.tailvy_api_key and 'tailvy_used' in st.session_state and st.session_state.tailvy_used:
|
| 1043 |
st.markdown(
|
| 1044 |
"""
|
| 1045 |
+
<div style="display: inline-block; background-color: #046A38; color: white;
|
| 1046 |
padding: 5px 10px; border-radius: 15px; margin-bottom: 10px; font-size: 0.8rem;">
|
| 1047 |
โจ Enhanced with Tailvy AI
|
| 1048 |
</div>
|
| 1049 |
+
""",
|
| 1050 |
unsafe_allow_html=True
|
| 1051 |
)
|
| 1052 |
+
|
| 1053 |
+
st.markdown('<div class="output-container"><div class="output-text">' +
|
| 1054 |
+
st.session_state.generated_itinerary + '</div></div>',
|
| 1055 |
unsafe_allow_html=True)
|
| 1056 |
+
else:
|
| 1057 |
+
# Show message when no itinerary has been generated yet
|
| 1058 |
+
st.info("๐ Fill out the form above and click '๐ Create My Personal Travel Itinerary' to generate your customized travel plan!")
|
| 1059 |
+
st.markdown("""
|
| 1060 |
+
### How it works:
|
| 1061 |
+
1. **Enter your details** - Origin, destination, dates, and preferences
|
| 1062 |
+
2. **Click Submit** - Our AI agents will research your destination
|
| 1063 |
+
3. **Get your itinerary** - Personalized recommendations for accommodations, activities, dining, and more!
|
| 1064 |
+
|
| 1065 |
+
#### Powered by AI Agents:
|
| 1066 |
+
- ๐ Destination Research Agent
|
| 1067 |
+
- ๐จ Accommodation Agent
|
| 1068 |
+
- ๐ Transportation Agent
|
| 1069 |
+
- ๐ฏ Activities Agent
|
| 1070 |
+
- ๐ฝ๏ธ Dining Agent
|
| 1071 |
+
- ๐ Itinerary Integration Agent
|
| 1072 |
+
""")
|
| 1073 |
|
| 1074 |
# Details tab
|
| 1075 |
with tabs[1]:
|
| 1076 |
+
if st.session_state.step_results.get("destination_research") or st.session_state.step_results.get("dining"):
|
| 1077 |
+
if st.session_state.step_results.get("destination_research"):
|
| 1078 |
+
st.markdown('<div class="output-container"><h3>๐งญ Destination Information</h3><div class="output-text">' +
|
| 1079 |
+
st.session_state.step_results["destination_research"] + '</div></div>',
|
| 1080 |
+
unsafe_allow_html=True)
|
| 1081 |
+
|
| 1082 |
+
if st.session_state.step_results.get("dining"):
|
| 1083 |
+
st.markdown('<div class="output-container"><h3>๐ฝ๏ธ Dining Recommendations</h3><div class="output-text">' +
|
| 1084 |
+
st.session_state.step_results["dining"] + '</div></div>',
|
| 1085 |
+
unsafe_allow_html=True)
|
| 1086 |
+
else:
|
| 1087 |
+
st.info("Generate an itinerary to see detailed research about your destination and dining recommendations!")
|
| 1088 |
|
| 1089 |
# Download and share tab
|
| 1090 |
with tabs[2]:
|
|
|
|
| 1095 |
download_link = get_download_link(st.session_state.generated_itinerary, f"Travel_Itinerary_{destination.replace(' ', '_')}.txt")
|
| 1096 |
st.markdown(download_link, unsafe_allow_html=True)
|
| 1097 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 1098 |
+
else:
|
| 1099 |
+
st.info("Generate an itinerary first to download it as a file!")
|
| 1100 |
|
| 1101 |
# Maps and visualization tab
|
| 1102 |
with tabs[3]:
|