Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +17 -19
src/streamlit_app.py
CHANGED
|
@@ -8,10 +8,9 @@ import base64
|
|
| 8 |
from PIL import Image
|
| 9 |
import io
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
# Mock function for demonstration - replace with your actual call_agent function
|
| 15 |
def call_agent(query):
|
| 16 |
"""
|
| 17 |
Mock function - replace this with your actual call_agent function
|
|
@@ -23,16 +22,20 @@ def call_agent(query):
|
|
| 23 |
{"id": 3, "task": "Analyze hydrological flow patterns", "tool": "HydrologyAnalyzer"},
|
| 24 |
{"id": 4, "task": "Generate flood risk assessment maps", "tool": "LLM Reasoning"}
|
| 25 |
]
|
| 26 |
-
|
| 27 |
# Mock state object
|
| 28 |
class MockState:
|
| 29 |
def __init__(self):
|
| 30 |
-
self.query = query
|
| 31 |
-
self.response = mock_response
|
| 32 |
-
self.output_files_path = [f"outputs/geospatial_plan_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:6]}.json"]
|
| 33 |
-
|
| 34 |
return MockState()
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def get_image_base64(image_path):
|
| 37 |
"""Convert local image to base64 string for embedding in HTML"""
|
| 38 |
try:
|
|
@@ -688,8 +691,8 @@ with col2:
|
|
| 688 |
</div>
|
| 689 |
""", unsafe_allow_html=True)
|
| 690 |
|
| 691 |
-
|
| 692 |
-
|
| 693 |
|
| 694 |
# Display chat messages
|
| 695 |
for message in st.session_state.messages:
|
|
@@ -707,11 +710,7 @@ with col2:
|
|
| 707 |
<strong>🤖 AI Task Planner:</strong>
|
| 708 |
</div>
|
| 709 |
""", unsafe_allow_html=True)
|
| 710 |
-
|
| 711 |
-
# Use Streamlit's native components for better rendering
|
| 712 |
-
st.markdown("""
|
| 713 |
-
<div class="task-plan-container">
|
| 714 |
-
""", unsafe_allow_html=True)
|
| 715 |
|
| 716 |
for task in message["tasks"]:
|
| 717 |
st.markdown(f"""
|
|
@@ -752,10 +751,9 @@ with col2:
|
|
| 752 |
</div>
|
| 753 |
""", unsafe_allow_html=True)
|
| 754 |
|
| 755 |
-
|
| 756 |
|
| 757 |
-
|
| 758 |
-
st.markdown('<div class="input-section">', unsafe_allow_html=True)
|
| 759 |
|
| 760 |
# Text input for query
|
| 761 |
user_input = st.text_area(
|
|
@@ -836,7 +834,7 @@ with col2:
|
|
| 836 |
use_container_width=True
|
| 837 |
)
|
| 838 |
|
| 839 |
-
|
| 840 |
|
| 841 |
# Clear chat button (at the bottom)
|
| 842 |
if st.session_state.messages:
|
|
|
|
| 8 |
from PIL import Image
|
| 9 |
import io
|
| 10 |
|
| 11 |
+
from main import call_agent as agent_invoker
|
| 12 |
+
from main import DemoState
|
| 13 |
|
|
|
|
| 14 |
def call_agent(query):
|
| 15 |
"""
|
| 16 |
Mock function - replace this with your actual call_agent function
|
|
|
|
| 22 |
{"id": 3, "task": "Analyze hydrological flow patterns", "tool": "HydrologyAnalyzer"},
|
| 23 |
{"id": 4, "task": "Generate flood risk assessment maps", "tool": "LLM Reasoning"}
|
| 24 |
]
|
| 25 |
+
state = agent_invoker(query)
|
| 26 |
# Mock state object
|
| 27 |
class MockState:
|
| 28 |
def __init__(self):
|
| 29 |
+
self.query = state.get('query', query)
|
| 30 |
+
self.response = state.get('response', mock_response)
|
| 31 |
+
self.output_files_path = state.get('output_files_path', [f"outputs/geospatial_plan_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:6]}.json"])
|
|
|
|
| 32 |
return MockState()
|
| 33 |
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
def get_image_base64(image_path):
|
| 40 |
"""Convert local image to base64 string for embedding in HTML"""
|
| 41 |
try:
|
|
|
|
| 691 |
</div>
|
| 692 |
""", unsafe_allow_html=True)
|
| 693 |
|
| 694 |
+
|
| 695 |
+
|
| 696 |
|
| 697 |
# Display chat messages
|
| 698 |
for message in st.session_state.messages:
|
|
|
|
| 710 |
<strong>🤖 AI Task Planner:</strong>
|
| 711 |
</div>
|
| 712 |
""", unsafe_allow_html=True)
|
| 713 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 714 |
|
| 715 |
for task in message["tasks"]:
|
| 716 |
st.markdown(f"""
|
|
|
|
| 751 |
</div>
|
| 752 |
""", unsafe_allow_html=True)
|
| 753 |
|
| 754 |
+
|
| 755 |
|
| 756 |
+
|
|
|
|
| 757 |
|
| 758 |
# Text input for query
|
| 759 |
user_input = st.text_area(
|
|
|
|
| 834 |
use_container_width=True
|
| 835 |
)
|
| 836 |
|
| 837 |
+
|
| 838 |
|
| 839 |
# Clear chat button (at the bottom)
|
| 840 |
if st.session_state.messages:
|