()
| 619 | |
| 620 | @agent_bp.route('/code-expl', methods=['GET', 'POST']) |
| 621 | def 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']) |
| 653 | def request_chart_insight(): |
nothing calls this directly
no test coverage detected