prthm11 commited on
Commit
5ed4253
·
verified ·
1 Parent(s): 3e092ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -300,7 +300,19 @@ Your task is to process OCR-extracted text from images of Scratch 3.0 code block
300
  # * **Forgiving Inputs:** Recognize that Scratch is designed to be "forgiving in its interpretation of inputs." [cite_start]The Scratch VM handles potentially "invalid" inputs gracefully (e.g., converting a number to a string if expected, returning default values like zero or empty strings, or performing no action) rather than crashing[cite: 20, 21, 22, 38, 39, 41]. This implies that precise type matching for inputs might be handled internally by Scratch, allowing for some flexibility in how values are provided, but the agent should aim for the most common and logical type.
301
  # """
302
 
303
- SYSTEM_PROMPT_JSON_CORRECTOR ="""
 
 
 
 
 
 
 
 
 
 
 
 
304
  You are an assistant that outputs JSON responses strictly following the given schema.
305
  If the JSON you produce has any formatting errors, missing required fields, or invalid structure, you must identify the problems and correct them.
306
  Always return only valid JSON that fully conforms to the schema below, enclosed in triple backticks (```), without any extra text or explanation.
@@ -309,9 +321,14 @@ If you receive an invalid or incomplete JSON response, fix it by:
309
  - Adding any missing required fields with appropriate values.
310
  - Correcting syntax errors such as missing commas, brackets, or quotes.
311
  - Ensuring the JSON structure matches the schema exactly.
 
 
 
312
 
313
  Remember: Your output must be valid JSON only, ready to be parsed without errors.
314
  """
 
 
315
  # debugger and resolver agent for Scratch 3.0
316
  # Main agent of the system agent for Scratch 3.0
317
  agent = create_react_agent(
 
300
  # * **Forgiving Inputs:** Recognize that Scratch is designed to be "forgiving in its interpretation of inputs." [cite_start]The Scratch VM handles potentially "invalid" inputs gracefully (e.g., converting a number to a string if expected, returning default values like zero or empty strings, or performing no action) rather than crashing[cite: 20, 21, 22, 38, 39, 41]. This implies that precise type matching for inputs might be handled internally by Scratch, allowing for some flexibility in how values are provided, but the agent should aim for the most common and logical type.
301
  # """
302
 
303
+ # SYSTEM_PROMPT_JSON_CORRECTOR ="""
304
+ # You are an assistant that outputs JSON responses strictly following the given schema.
305
+ # If the JSON you produce has any formatting errors, missing required fields, or invalid structure, you must identify the problems and correct them.
306
+ # Always return only valid JSON that fully conforms to the schema below, enclosed in triple backticks (```), without any extra text or explanation.
307
+
308
+ # If you receive an invalid or incomplete JSON response, fix it by:
309
+ # - Adding any missing required fields with appropriate values.
310
+ # - Correcting syntax errors such as missing commas, brackets, or quotes.
311
+ # - Ensuring the JSON structure matches the schema exactly.
312
+
313
+ # Remember: Your output must be valid JSON only, ready to be parsed without errors.
314
+ # """
315
+ SYSTEM_PROMPT_JSON_CORRECTOR = """
316
  You are an assistant that outputs JSON responses strictly following the given schema.
317
  If the JSON you produce has any formatting errors, missing required fields, or invalid structure, you must identify the problems and correct them.
318
  Always return only valid JSON that fully conforms to the schema below, enclosed in triple backticks (```), without any extra text or explanation.
 
321
  - Adding any missing required fields with appropriate values.
322
  - Correcting syntax errors such as missing commas, brackets, or quotes.
323
  - Ensuring the JSON structure matches the schema exactly.
324
+ - Ensuring `"pseudocode"` is always a **single JSON string with embedded `\n` newlines** (never arrays, never concatenated with `+`).
325
+ - Removing any invalid concatenation artifacts (`+`, `"string1" + "string2"`).
326
+ - Never output explanations, comments, or extra text — only the corrected JSON.
327
 
328
  Remember: Your output must be valid JSON only, ready to be parsed without errors.
329
  """
330
+
331
+
332
  # debugger and resolver agent for Scratch 3.0
333
  # Main agent of the system agent for Scratch 3.0
334
  agent = create_react_agent(