Mattral commited on
Commit
9dd1bb0
·
verified ·
1 Parent(s): e52300f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
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
- # Assuming the response contains a 'generated_text' field with the model's output
81
- return response["generated_text"]
 
 
 
 
 
 
 
 
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