Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -220,12 +220,13 @@ Context:
|
|
220 |
# )
|
221 |
# )
|
222 |
|
223 |
-
|
224 |
model=model_name,
|
225 |
messages=messages,
|
226 |
max_tokens=500,
|
227 |
stream=True
|
228 |
-
)
|
|
|
229 |
|
230 |
except Exception as e:
|
231 |
error_msg = f"Error during query processing: {str(e)}"
|
@@ -252,8 +253,7 @@ def create_gradio_interface(rag_system: AdvancedRAGSystem) -> gr.Blocks:
|
|
252 |
def query_fin(question):
|
253 |
"""Query system and update history with error handling"""
|
254 |
try:
|
255 |
-
|
256 |
-
yield x.choices[0].delta.content
|
257 |
except Exception as e:
|
258 |
pass
|
259 |
|
@@ -317,7 +317,9 @@ def create_gradio_interface(rag_system: AdvancedRAGSystem) -> gr.Blocks:
|
|
317 |
query_button.click(
|
318 |
fn=query_fin,
|
319 |
inputs=[question_input],
|
320 |
-
outputs=[answer_output]
|
|
|
|
|
321 |
)
|
322 |
|
323 |
query_button.click(
|
|
|
220 |
# )
|
221 |
# )
|
222 |
|
223 |
+
for x in self.llm.chat.completions.create(
|
224 |
model=model_name,
|
225 |
messages=messages,
|
226 |
max_tokens=500,
|
227 |
stream=True
|
228 |
+
):
|
229 |
+
yield x
|
230 |
|
231 |
except Exception as e:
|
232 |
error_msg = f"Error during query processing: {str(e)}"
|
|
|
253 |
def query_fin(question):
|
254 |
"""Query system and update history with error handling"""
|
255 |
try:
|
256 |
+
yield rag_system.query(question).choices[0].delta.content
|
|
|
257 |
except Exception as e:
|
258 |
pass
|
259 |
|
|
|
317 |
query_button.click(
|
318 |
fn=query_fin,
|
319 |
inputs=[question_input],
|
320 |
+
outputs=[answer_output],
|
321 |
+
api_name="stream_response",
|
322 |
+
show_progress=False
|
323 |
)
|
324 |
|
325 |
query_button.click(
|