dmfelder commited on
Commit
562e827
·
verified ·
1 Parent(s): 582a927

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -149,6 +149,8 @@ Please provide a direct, factual answer to this question. Think step by step if
149
 
150
  Response:"""
151
 
 
 
152
  # Use the inference client to get a response
153
  response = self.client.text_generation(
154
  prompt,
@@ -158,14 +160,26 @@ Response:"""
158
  return_full_text=False
159
  )
160
 
 
 
161
  # Extract the answer from the response
162
  answer = self._extract_answer(response, question_type)
163
- logging.info(f"Agent response for {question_type}: {answer}")
 
 
 
 
 
 
 
 
 
164
  return answer
165
 
166
  except Exception as e:
167
  logging.error(f"Error in agent execution: {e}")
168
- return "ERROR"
 
169
 
170
  def _extract_answer(self, raw_answer: str, question_type: str) -> str:
171
  """Extract the final answer from the raw response"""
 
149
 
150
  Response:"""
151
 
152
+ logging.info(f"Sending prompt to model (first 100 chars): {prompt[:100]}...")
153
+
154
  # Use the inference client to get a response
155
  response = self.client.text_generation(
156
  prompt,
 
160
  return_full_text=False
161
  )
162
 
163
+ logging.info(f"Raw model response: {response}")
164
+
165
  # Extract the answer from the response
166
  answer = self._extract_answer(response, question_type)
167
+ logging.info(f"Extracted answer: {answer}")
168
+
169
+ # If we still have ERROR, try a simple fallback
170
+ if answer == "ERROR" and response:
171
+ # Just return the first reasonable part of the response
172
+ clean_response = response.strip()
173
+ if len(clean_response) > 0 and len(clean_response) < 200:
174
+ answer = clean_response
175
+ logging.info(f"Using fallback answer: {answer}")
176
+
177
  return answer
178
 
179
  except Exception as e:
180
  logging.error(f"Error in agent execution: {e}")
181
+ # Return a more specific error message for debugging
182
+ return f"AGENT_ERROR: {str(e)}"
183
 
184
  def _extract_answer(self, raw_answer: str, question_type: str) -> str:
185
  """Extract the final answer from the raw response"""