Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -203,15 +203,18 @@ def create_gradio_interface(rag_system: AdvancedRAGSystem) -> gr.Blocks:
|
|
| 203 |
except Exception as e:
|
| 204 |
return f"Error: {str(e)}"
|
| 205 |
|
| 206 |
-
def
|
| 207 |
-
"""Query system and update history with error handling"""
|
| 208 |
try:
|
| 209 |
-
|
|
|
|
| 210 |
except Exception as e:
|
| 211 |
-
|
| 212 |
|
| 213 |
def update_history(question: str):
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
with gr.Blocks(title="Advanced RAG System") as demo:
|
| 217 |
gr.Markdown("# Advanced RAG System with PDF Processing")
|
|
|
|
| 203 |
except Exception as e:
|
| 204 |
return f"Error: {str(e)}"
|
| 205 |
|
| 206 |
+
def query_streaming(question: str) -> Generator[str, None, None]:
|
|
|
|
| 207 |
try:
|
| 208 |
+
for response in rag_system.query(question):
|
| 209 |
+
yield response
|
| 210 |
except Exception as e:
|
| 211 |
+
yield f"Error: {str(e)}"
|
| 212 |
|
| 213 |
def update_history(question: str):
|
| 214 |
+
try:
|
| 215 |
+
return f"Last context used ({rag_system.source_documents} documents):\n\n{rag_system.context}"
|
| 216 |
+
except Exception as e:
|
| 217 |
+
return f"Error retrieving context: {str(e)}"
|
| 218 |
|
| 219 |
with gr.Blocks(title="Advanced RAG System") as demo:
|
| 220 |
gr.Markdown("# Advanced RAG System with PDF Processing")
|