MCPcopy Create free account
hub / github.com/microsoft/data-formulator / request_code_expl

Function request_code_expl

py-src/data_formulator/routes/agents.py:621–650  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

619
620@agent_bp.route('/code-expl', methods=['GET', 'POST'])
621def request_code_expl():
622 if not request.is_json:
623 raise AppError(ErrorCode.INVALID_REQUEST, "Invalid request format")
624
625 logger.info("# code-expl request")
626 content = request.get_json()
627 client = get_client(content['model'])
628
629 input_tables = content["input_tables"]
630 code = content["code"]
631
632 identity_id = get_identity_id()
633 workspace = get_workspace(identity_id)
634
635 language_instruction = get_language_instruction()
636
637 try:
638 code_expl_agent = CodeExplanationAgent(client=client, workspace=workspace, language_instruction=language_instruction)
639 candidates = code_expl_agent.run(input_tables, code)
640
641 if candidates and len(candidates) > 0:
642 result = candidates[0]
643 return json_ok(result)
644 else:
645 raise AppError(ErrorCode.AGENT_ERROR, "No explanation generated")
646 except AppError:
647 raise
648 except Exception as e:
649 logger.error("Error in code-expl", exc_info=e)
650 raise classify_and_wrap_llm_error(e) from e
651
652@agent_bp.route('/chart-insight', methods=['GET', 'POST'])
653def request_chart_insight():

Callers

nothing calls this directly

Calls 9

runMethod · 0.95
AppErrorClass · 0.90
get_identity_idFunction · 0.90
get_workspaceFunction · 0.90
json_okFunction · 0.90
get_clientFunction · 0.85
get_language_instructionFunction · 0.85

Tested by

no test coverage detected