bhuvanmdev commited on
Commit
ada214d
·
verified ·
1 Parent(s): fe9b76b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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 query_fin(question):
207
- """Query system and update history with error handling"""
208
  try:
209
- yield rag_system.query(question).choices[0].delta.content
 
210
  except Exception as e:
211
- pass
212
 
213
  def update_history(question: str):
214
- return f"Last context used ({rag_system.source_documents} documents):\n\n{rag_system.context}"
 
 
 
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")