Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
546 |
-
if
|
547 |
-
|
548 |
-
|
549 |
-
|
|
|
|
|
550 |
else:
|
551 |
-
logging.error("
|
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)}")
|