Shreyas094 commited on
Commit
9547bec
1 Parent(s): 10b6796

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -542,13 +542,15 @@ def get_response_from_llama(query, model, selected_docs, file_type, num_calls=1,
542
  stream=True,
543
  top_p=0.9,
544
  ):
545
- # Updated response handling
546
- if hasattr(response, 'text'): # Check if 'text' attribute exists
547
- chunk = response.text
548
- full_response += chunk
549
- yield full_response # Yield the accumulated response so far
 
 
550
  else:
551
- logging.error("No 'text' attribute found in response object.")
552
  break
553
  except Exception as e:
554
  logging.error(f"Error during API call: {str(e)}")
 
542
  stream=True,
543
  top_p=0.9,
544
  ):
545
+ # Check the structure of the response object
546
+ if isinstance(response, dict) and "choices" in response:
547
+ for choice in response["choices"]:
548
+ if "delta" in choice and "content" in choice["delta"]:
549
+ chunk = choice["delta"]["content"]
550
+ full_response += chunk
551
+ yield full_response # Yield the accumulated response so far
552
  else:
553
+ logging.error("Unexpected response format or missing attributes in the response object.")
554
  break
555
  except Exception as e:
556
  logging.error(f"Error during API call: {str(e)}")