keynes42 commited on
Commit
c669617
·
verified ·
1 Parent(s): 0c96221

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -111,7 +111,7 @@ class BasicModel:
111
  content_text = content
112
  prompt.append(f"<|im_start|>{role}\n\n{content_text}<|im_end|>") # Qwen3 format
113
 
114
- print(f"{role}: {content_text}") ## <- Print the last message in log
115
 
116
  # Add the assistant prompt start
117
  prompt.append("<|im_start|>assistant\n\n")
@@ -160,6 +160,9 @@ class BasicModel:
160
  json.loads(json_substring)
161
  # If it's valid, we replace the original response with just the clean JSON part.
162
  response = json_substring
 
 
 
163
  # If no valid JSON is found, we proceed with the original response string.
164
  except (json.JSONDecodeError, TypeError):
165
  # Pass silently and let the framework handle the potentially malformed string.
@@ -185,13 +188,11 @@ class BasicModel:
185
 
186
  # This is the core fix from the evaluation report's advice.
187
  # We take the raw code string and wrap it in the required markdown format.
188
- raw_code = agent_output_dict["code"]
189
 
190
  # We also clean up potential markdown fences the LLM might have added itself
191
- if raw_code.strip().startswith("```"):
192
- raw_code = raw_code.strip()
193
- # raw_code = regex.sub(r"^(?:```(?:py|python)?\n)?(.*?)(?:\n```)?$", r"\1", raw_code, flags=regex.DOTALL)
194
- cleaned_code = regex.sub(r"^\s*```(?:py|python)?\n(.*?)\n```\s*$", r"\1", raw_code, flags=regex.DOTALL)
195
 
196
  # formatted_code = f"```py\n{raw_code}\n```"
197
 
 
111
  content_text = content
112
  prompt.append(f"<|im_start|>{role}\n\n{content_text}<|im_end|>") # Qwen3 format
113
 
114
+ # print(f"{role}: {content_text}") ## <- Print the last message in log
115
 
116
  # Add the assistant prompt start
117
  prompt.append("<|im_start|>assistant\n\n")
 
160
  json.loads(json_substring)
161
  # If it's valid, we replace the original response with just the clean JSON part.
162
  response = json_substring
163
+
164
+ print("\n -------------JSON string is successfully extracted!-------\n----------------\n")
165
+
166
  # If no valid JSON is found, we proceed with the original response string.
167
  except (json.JSONDecodeError, TypeError):
168
  # Pass silently and let the framework handle the potentially malformed string.
 
188
 
189
  # This is the core fix from the evaluation report's advice.
190
  # We take the raw code string and wrap it in the required markdown format.
191
+ raw_code = agent_output_dict["code"].strip()
192
 
193
  # We also clean up potential markdown fences the LLM might have added itself
194
+ # raw_code = regex.sub(r"^(?:```(?:py|python)?\n)?(.*?)(?:\n```)?$", r"\1", raw_code, flags=regex.DOTALL)
195
+ cleaned_code = regex.sub(r"^\s*```(?:py|python)?\n(.*?)\n```\s*$", r"\1", raw_code, flags=regex.DOTALL)
 
 
196
 
197
  # formatted_code = f"```py\n{raw_code}\n```"
198