Update app.py
Browse files148 unmodified lines14915015115215315415515615715815916016116216346 unmodified lines21021121221321421521611 unmodified lines228229230231232233234148 unmodified linesimport re, jsontry:# If output does not contain code block, exit earlyif "```" not in raw_output:print("Agent output did not contain a code block.")return None# Extract code inside triple backtickscode_blocks = re.findall(r"```(?:py|python)?\n(.*?)```", raw_output, re.DOTALL)for block in code_blocks:json_match = re.search(r"json\.dumps\((\{.*?\})\)", block, re.DOTALL)if json_match:return json.loads(json_match.group(1))46 unmodified lines7. DO NOT return any explanations, thoughts, or narration outside the final output block.8. DO NOT use `...` in any dictionary values, arrays, or code blocks.9. Use empty lists like [] or strings like "N/A" instead.10. FINALLY return ONLY this exact format:```pythonimport json11 unmodified lines}print(json.dumps(result))```<end_code>Be concise and avoid any narrative outside this final dictionary.Never use unauthorized imports (only pandas, numpy, matplotlib, seaborn are allowed)"""148 unmodified lines14915015115215315415515615715815916016116216316416516616716846 unmodified lines21521621721821922022122222311 unmodified lines235236237238239240241148 unmodified linesimport re, jsontry:# Extract code inside triple backtickscode_blocks = re.findall(r"```(?:py|python)?\n(.*?)```", raw_output, re.DOTALL)for block in code_blocks:# first try to catch a print(json.dumps(...)) with arbitrary whitespacejson_match = re.search(r"print\(\s*json\.dumps\(\s*(\{[\s\S]*?\})\s*\)\s*\)",block,re.DOTALL) or re.search(r"json\.dumps\(\s*(\{[\s\S]*?\})\s*\)",block,re.DOTALL)if json_match:return json.loads(json_match.group(1))46 unmodified lines7. DO NOT return any explanations, thoughts, or narration outside the final output block.8. DO NOT use `...` in any dictionary values, arrays, or code blocks.9. Use empty lists like [] or strings like "N/A" instead.10.Respond only with a JSON-serializable dictionary in Python syntax. Do not include any thoughts, comments, or explanation.11. Any logging or warnings must be disabled or redirected; the only stdout must be the single print(json.dumps(result)) call.12. FINALLY return ONLY this exact format:```pythonimport json11 unmodified lines}print(json.dumps(result))<end_code>Be concise and avoid any narrative outside this final dictionary.Never use unauthorized imports (only pandas, numpy, matplotlib, seaborn are allowed)"""
app.py+15-8