Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
change streaming + fix toggle
Browse files
app.py
CHANGED
@@ -88,14 +88,25 @@ async def chat_response(query, history, method, country, uploaded_file):
|
|
88 |
|
89 |
except Exception as e:
|
90 |
response = f"Error retrieving information: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
# Stream response word by word into the chat
|
93 |
-
words = response.split()
|
94 |
|
95 |
-
for i in range(len(words)):
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
def auto_analyze_file(file, history):
|
101 |
"""Automatically analyze uploaded GeoJSON file and add results to chat"""
|
@@ -126,7 +137,7 @@ def auto_analyze_file(file, history):
|
|
126 |
|
127 |
def toggle_search_method(method):
|
128 |
"""Toggle between GeoJSON upload and country selection"""
|
129 |
-
if method == "Subir
|
130 |
return (
|
131 |
gr.update(visible=True), # geojson_section
|
132 |
gr.update(visible=False), # reports_section
|
|
|
88 |
|
89 |
except Exception as e:
|
90 |
response = f"Error retrieving information: {str(e)}"
|
91 |
+
|
92 |
+
displayed_response = ""
|
93 |
+
|
94 |
+
for i, char in enumerate(response):
|
95 |
+
displayed_response += char
|
96 |
+
history[-1] = (query, displayed_response)
|
97 |
+
yield history, "**Sources:** Sample source documents would appear here..."
|
98 |
+
# Only add delay every few characters to avoid being too slow
|
99 |
+
if i % 3 == 0: # Adjust this number to control speed
|
100 |
+
await asyncio.sleep(0.02)
|
101 |
+
|
102 |
|
103 |
+
# # Stream response word by word into the chat
|
104 |
+
# words = response.split()
|
105 |
|
106 |
+
# for i in range(len(words)):
|
107 |
+
# history[-1] = (query, " ".join(words[:i+1]))
|
108 |
+
# yield history, "**Sources:** Sample source documents would appear here..."
|
109 |
+
# await asyncio.sleep(0.05)
|
110 |
|
111 |
def auto_analyze_file(file, history):
|
112 |
"""Automatically analyze uploaded GeoJSON file and add results to chat"""
|
|
|
137 |
|
138 |
def toggle_search_method(method):
|
139 |
"""Toggle between GeoJSON upload and country selection"""
|
140 |
+
if method == "Subir GeoJson":
|
141 |
return (
|
142 |
gr.update(visible=True), # geojson_section
|
143 |
gr.update(visible=False), # reports_section
|
utils/__pycache__/generator.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/generator.cpython-310.pyc and b/utils/__pycache__/generator.cpython-310.pyc differ
|
|
utils/__pycache__/retriever.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/retriever.cpython-310.pyc and b/utils/__pycache__/retriever.cpython-310.pyc differ
|
|
utils/__pycache__/whisp_api.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/whisp_api.cpython-310.pyc and b/utils/__pycache__/whisp_api.cpython-310.pyc differ
|
|