Amna2024 commited on
Commit
c07fdcc
·
verified ·
1 Parent(s): d72aee6

Update rag_service.py

Browse files
Files changed (1) hide show
  1. rag_service.py +13 -13
rag_service.py CHANGED
@@ -157,21 +157,21 @@ class RAGService:
157
  # return response['response']
158
 
159
  def ask_question(self, question: str):
160
- """Process a question and return response"""
161
- try:
162
- # First attempt
163
- response = self.chain_with_sources.invoke(question)
 
 
 
 
 
 
 
164
 
165
- # Check if response is valid
166
- if not response or not response.get('response') or len(response['response'].strip()) < 0:
167
- # Try to clarify what the user might be asking
168
  return self._handle_ambiguous_question(question)
169
-
170
- return response['response']
171
-
172
- except Exception as e:
173
- print(f"Error in ask_question: {e}")
174
- return self._handle_ambiguous_question(question)
175
 
176
  def _handle_ambiguous_question(self, question: str):
177
  """Handle ambiguous or complex questions"""
 
157
  # return response['response']
158
 
159
  def ask_question(self, question: str):
160
+ """Process a question and return response"""
161
+ try:
162
+ # First attempt
163
+ response = self.chain_with_sources.invoke(question)
164
+
165
+ # Check if response is valid
166
+ if not response or not response.get('response') or len(response['response'].strip()) < 0:
167
+ # Try to clarify what the user might be asking
168
+ return self._handle_ambiguous_question(question)
169
+
170
+ return response['response']
171
 
172
+ except Exception as e:
173
+ print(f"Error in ask_question: {e}")
 
174
  return self._handle_ambiguous_question(question)
 
 
 
 
 
 
175
 
176
  def _handle_ambiguous_question(self, question: str):
177
  """Handle ambiguous or complex questions"""