alvinhenrick commited on
Commit
7686ee5
1 Parent(s): e9413a5
Files changed (1) hide show
  1. medirag/rag/qa_rag.py +6 -3
medirag/rag/qa_rag.py CHANGED
@@ -31,10 +31,13 @@ class QuestionAnswerRunner:
31
 
32
  async def _handle_streaming_query(self, query: str) -> AsyncGenerator[str, None]:
33
  try:
34
- result = await self.rag.run(query=query)
35
- if hasattr(result, "async_response_gen"):
 
 
 
36
  accumulated_response = ""
37
- async for chunk in result.async_response_gen():
38
  accumulated_response += chunk
39
  yield chunk
40
  self.semantic_cache.save(query, accumulated_response)
 
31
 
32
  async def _handle_streaming_query(self, query: str) -> AsyncGenerator[str, None]:
33
  try:
34
+ response = await self.rag.run(query=query)
35
+ if isinstance(response, str):
36
+ yield response
37
+ self.semantic_cache.save(query, response)
38
+ if hasattr(response, "async_response_gen"):
39
  accumulated_response = ""
40
+ async for chunk in response.async_response_gen():
41
  accumulated_response += chunk
42
  yield chunk
43
  self.semantic_cache.save(query, accumulated_response)