Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,10 +75,19 @@ def answer_question(question, documents):
|
|
| 75 |
"top_p": 0.9 # Control diversity via nucleus sampling
|
| 76 |
}
|
| 77 |
|
|
|
|
| 78 |
response = client.text_generation(question_with_context, **generate_kwargs)
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
# Streamlit file uploader for PDF
|
|
|
|
| 75 |
"top_p": 0.9 # Control diversity via nucleus sampling
|
| 76 |
}
|
| 77 |
|
| 78 |
+
# Generate the response using the text generation method
|
| 79 |
response = client.text_generation(question_with_context, **generate_kwargs)
|
| 80 |
|
| 81 |
+
# Print the response to inspect its structure
|
| 82 |
+
print(f"Response: {response}")
|
| 83 |
+
|
| 84 |
+
# If the response is a string, we can directly return it
|
| 85 |
+
if isinstance(response, str):
|
| 86 |
+
return response
|
| 87 |
+
else:
|
| 88 |
+
# If it's a dictionary, extract the generated text
|
| 89 |
+
return response.get("generated_text", "No answer generated.")
|
| 90 |
+
|
| 91 |
|
| 92 |
|
| 93 |
# Streamlit file uploader for PDF
|