kaikaidai commited on
Commit
40a124e
·
verified ·
1 Parent(s): 7c6d478

Update gen_api_answer.py

Browse files
Files changed (1) hide show
  1. gen_api_answer.py +11 -2
gen_api_answer.py CHANGED
@@ -188,11 +188,20 @@ def parse_model_response(response):
188
  def alternative_parse_model_response(output):
189
  try:
190
  print(f"Raw model response: {output}")
 
191
 
192
  # Remove "Feedback:" prefix if present (case insensitive)
193
- output = re.sub(r'^feedback:\s*', '', output.strip(), flags=re.IGNORECASE)
 
 
 
 
 
 
 
 
194
 
195
- # First, try to match the pattern "... [RESULT] X"
196
  pattern = r"(.*?)\s*\[RESULT\]\s*[\(\[]?(\d+)[\)\]]?"
197
  match = re.search(pattern, output, re.DOTALL | re.IGNORECASE)
198
  if match:
 
188
  def alternative_parse_model_response(output):
189
  try:
190
  print(f"Raw model response: {output}")
191
+ output = output.strip()
192
 
193
  # Remove "Feedback:" prefix if present (case insensitive)
194
+ output = re.sub(r'^feedback:\s*', '', output, flags=re.IGNORECASE)
195
+
196
+ # New pattern to match [RESULT] X at the beginning
197
+ begin_result_pattern = r'^\[RESULT\]\s*(\d+)\s*\n*(.*?)$'
198
+ begin_match = re.search(begin_result_pattern, output, re.DOTALL | re.IGNORECASE)
199
+ if begin_match:
200
+ score = int(begin_match.group(1))
201
+ feedback = begin_match.group(2).strip()
202
+ return str(score), feedback
203
 
204
+ # Existing patterns for end-of-string results...
205
  pattern = r"(.*?)\s*\[RESULT\]\s*[\(\[]?(\d+)[\)\]]?"
206
  match = re.search(pattern, output, re.DOTALL | re.IGNORECASE)
207
  if match: