CoolFace
Apppublic

KaiserShultz/Ankelodon_AI_Multi_task_agentic_system

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
test_stable.ipynb1441 linesDownload Raw Back to test_folder
1{2 "cells": [3  {4   "cell_type": "code",5   "execution_count": 1,6   "metadata": {},7   "outputs": [8    {9     "name": "stderr",10     "output_type": "stream",11     "text": [12      "d:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",13      "  from .autonotebook import tqdm as notebook_tqdm\n"14     ]15    }16   ],17   "source": [18    "import math\n",19    "from langgraph.checkpoint.memory import MemorySaver\n",20    "from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolMessage\n",21    "import uuid\n",22    "\n",23    "from typing import Sequence\n",24    "from langchain_core.messages import BaseMessage\n",25    "from langgraph.graph.message import add_messages\n",26    "\n",27    "import os, io, json, base64\n",28    "from typing import Optional, Dict, Any, List\n",29    "from langchain_core.tools import tool\n",30    "\n",31    "# pip install google-generativeai pillow\n",32    "import google.generativeai as genai\n",33    "from PIL import Image\n",34    "from langgraph.prebuilt import ToolNode\n",35    "\n",36    "from dotenv import load_dotenv\n",37    "import pandas as pd\n",38    "from IPython.display import display, Image\n",39    "from langchain_community.document_loaders import DataFrameLoader, TextLoader\n",40    "from langchain_community.vectorstores import Chroma\n",41    "from langchain_openai import ChatOpenAI, OpenAIEmbeddings\n",42    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",43    "from langchain.schema import Document\n",44    "from langchain.schema.output_parser import StrOutputParser\n",45    "import pickle \n",46    "\n",47    "\n",48    "from langchain_core.prompts import ChatPromptTemplate, PromptTemplate\n",49    "from pydantic import BaseModel, Field\n",50    "\n",51    "from typing import List, TypedDict, Annotated, Literal, Optional, Union\n",52    "\n",53    "from langgraph.graph import StateGraph, END\n",54    "\n",55    "load_dotenv()\n",56    "import os\n",57    "import json\n",58    "import re\n",59    "import operator\n",60    "\n",61    "from langgraph.store.memory import InMemoryStore\n",62    "in_memory_store = InMemoryStore() #сохраняем состояние между запусками\n",63    "\n",64    "from IPython.display import Image, display\n",65    "\n",66    "from langgraph.checkpoint.memory import MemorySaver\n",67    "from langgraph.graph import StateGraph, MessagesState, START, END\n",68    "from langgraph.store.base import BaseStore\n",69    "\n",70    "from langchain_core.messages import HumanMessage, SystemMessage\n",71    "from langchain_core.runnables.config import RunnableConfig\n",72    "from PIL import Image, ImageStat, ExifTags\n",73    "import pandas as pd\n",74    "\n",75    "\n",76    "#TOOLS\n",77    "\n",78    "from tools import (web_search, arxiv_search, wiki_search, add, subtract, multiply, divide, power, \n",79    "analyze_csv_file, analyze_docx_file, analyze_pdf_file, analyze_txt_file, analyze_image_file, vision_qa_gemma, analyze_excel_file, preprocess_files, save_and_read_file, download_file_from_url)\n",80    "\n",81    "from code_interpreter import safe_code_run\n"82   ]83  },84  {85   "cell_type": "code",86   "execution_count": 2,87   "metadata": {},88   "outputs": [],89   "source": [90    "# === НОВЫЕ PYDANTIC МОДЕЛИ ===\n",91    "\n",92    "class ComplexityLevel(BaseModel):\n",93    "    level: Literal[\"simple\", \"moderate\", \"complex\"] = Field(description=\"Complexity level of the query\")\n",94    "    reasoning: str = Field(description=\"Explanation for the complexity assessment\")\n",95    "    needs_planning: bool = Field(description=\"Whether this query requires detailed planning\")\n",96    "    suggested_approach: str = Field(description=\"Recommended approach for handling this query\")\n",97    "\n",98    "class CritiqueFeedback(BaseModel):\n",99    "    quality_score: int = Field(ge=1, le=10, description=\"Quality score from 1-10\")\n",100    "    is_complete: bool = Field(description=\"Whether the answer is complete\")\n",101    "    is_accurate: bool = Field(description=\"Whether the answer appears accurate\")\n",102    "    missing_elements: List[str] = Field(default_factory=list, description=\"What's missing from the answer\")\n",103    "    errors_found: List[str] = Field(default_factory=list, description=\"Potential errors identified\")\n",104    "    suggested_improvements: List[str] = Field(default_factory=list, description=\"Suggestions for improvement\")\n",105    "    needs_replanning: bool = Field(description=\"Whether the plan should be revised\")\n",106    "    replan_instructions: Optional[str] = Field(default=None, description=\"Instructions for replanning\")"107   ]108  },109  {110   "cell_type": "code",111   "execution_count": 3,112   "metadata": {},113   "outputs": [],114   "source": [115    "llm = ChatOpenAI(model=\"gpt-4o-mini\", temperature=0.25)\n",116    "TOOLS = [download_file_from_url, web_search, arxiv_search, wiki_search, add, subtract, multiply, divide, power, analyze_excel_file, analyze_csv_file, analyze_docx_file, analyze_pdf_file, analyze_txt_file, analyze_image_file, vision_qa_gemma, safe_code_run]"117   ]118  },119  {120   "cell_type": "code",121   "execution_count": 4,122   "metadata": {},123   "outputs": [],124   "source": [125    "SYSTEM_PROMPT_PLANNER = \"\"\"\n",126    "You are the PLANNER of a multi-tool agent (GAIA I–II level). \n",127    "Your job is to produce a minimal, reliable, reproducible plan to solve the user’s request using available tools.\n",128    "You DO NOT call tools yourself; you only output a plan. The executor will run the plan.\n",129    "Tools are already bound to the model via .bind_tools(), so use EXACT tool names.\n",130    "\n",131    "Principles\n",132    "- Goal: a correct, verifiable answer (with citations/artifacts where appropriate).\n",133    "- Minimality: use as few steps/tool calls as possible.\n",134    "- Proper routing: pick the right branch: info | calc | table | doc_qa | image_qa | multi_hop.\n",135    "- Files first: never send raw files to the code interpreter. First extract with specialized tools (CSV/XLSX/PDF/DOCX/TXT/IMG). \n",136    "  Only then compute on the extracted data (if needed) with the safe code interpreter.\n",137    "- Units & rounding: be explicit about units and rounding rules when numbers are involved.\n",138    "- Evidence: require sources (URL/page/figure caption) for external facts.\n",139    "- Fallbacks: define success criteria per step and a failure policy (“replan”, “stop”, or jump to another step-id).\n",140    "- Cost aware: start with cheap preview/metadata tools before heavy steps.\n",141    "\n",142    "\n",143    "Patterns / Routing\n",144    "- info/web: web_search/wiki_search/arxiv_search → gather citations.\n",145    "- calc: ensure data is available → safe_code_run only on extracted data; request plots/dataframes only if needed.\n",146    "- table (CSV/XLSX): analyze_* to confirm columns/shape → aggregate via safe_code_run (or SQL tool if available).\n",147    "- doc_qa (PDF/DOCX/TXT): analyze_* for pages/preview → extract_text or OCR if needed → answer with page/quote.\n",148    "- image_qa: analyze_image_* for metadata/OCR, or vision_qa_* for visual questions; for chart numbers, convert figure→table and verify with computation.\n",149    "- multi_hop: decompose into sub-queries, retrieve per modality, then synthesize with citations.\n",150    "\n",151    "Output format\n",152    "Return ONLY a single JSON object following this schema:\n",153    "{\n",154    "  \"task_type\": \"info | calc | table | doc_qa | image_qa | multi_hop\",\n",155    "  \"assumptions\": [\"string\", \"...\"],\n",156    "  \"plan_rationale\": \"why this route and which tools are needed\",\n",157    "  \"steps\": [\n",158    "    {\n",159    "      \"id\": \"s1\",\n",160    "      \"description\": \"what and why\",\n",161    "      \"evidence_needed\": [\"citations|page_numbers|figure_captions|stats_check|unit_check\"],\n",162    "      \"success_criteria\": \"how we know the step succeeded\",\n",163    "      \"on_fail\": \"replan | stop | sN\",\n",164    "      \"outputs_to_state\": [\"what we expect to store for later steps\"]\n",165    "    }\n",166    "  ],\n",167    "  \"answer_guidelines\": {\n",168    "    \"final_answer_template\": \"how to form the final answer\",\n",169    "    \"citations_required\": true,\n",170    "    \"min_citations\": 1,\n",171    "    \"units_policy\": \"what units to report and conversions\",\n",172    "    \"rounding_policy\": \"how to round numbers\",\n",173    "    \"include_artifacts\": [\"plots\",\"tables\",\"snippets\"]\n",174    "  }\n",175    "}\n",176    "\n",177    "Constraints\n",178    "- Output must be valid JSON only. No markdown, no comments, no tool calls.\n",179    "- Use exact tool names from the injected catalog (tools are already bound via .bind_tools()).\n",180    "- Prefer a single-pass plan; add a fallback step only when necessary.\n",181    "- Do not assume file I/O inside the code interpreter beyond its sandboxed read-only rules; data must be staged beforehand by extract tools.\n",182    "\"\"\""183   ]184  },185  {186   "cell_type": "code",187   "execution_count": 5,188   "metadata": {},189   "outputs": [],190   "source": [191    "SYSTEM_EXECUTOR_PROMPT = \"\"\"\n",192    "ROLE: You are the EXECUTOR of a multi-tool agent system (GAIA I–II level).\n",193    "MISSION:\n",194    "\n",195    "Your only responsibility is to EXECUTE the steps of the plan generated by the PLANNER.\n",196    "You never change, reinterpret, or optimize the plan — you just follow it exactly as given.\n",197    "You can use the available tools strictly in the order and manner specified in {plan}.\n",198    "\n",199    "CRITICAL EXECUTION PROTOCOL:\n",200    "\n",201    "MANDATORY: Before ANY tool call, you MUST output reasoning inside <REASONING> ... </REASONING> tags.\n",202    "MANDATORY: Each <REASONING> block must contain:\n",203    "\n",204    "What step you are about to execute\n",205    "Why this tool is needed for this step\n",206    "What specific inputs you will provide to the tool\n",207    "What output you expect from the tool\n",208    "\n",209    "\n",210    "MANDATORY: Only after completing the <REASONING> block, proceed with the actual tool call.\n",211    "FORBIDDEN: Making any tool call without a preceding <REASONING> block.\n",212    "\n",213    "EXECUTION RULES:\n",214    "\n",215    "Do NOT invent new steps or modify the plan.\n",216    "BEFORE EACH TOOL CALL — MANDATORY <REASONING> STEP (NO EXCEPTIONS)\n",217    "If a step requires a tool — first reason, then call that tool with exactly the required inputs.\n",218    "If a step can be solved without a tool — just provide the direct output (no reasoning needed for non-tool steps).\n",219    "If a step fails, you may retry it, but never alter its intent.\n",220    "At the end: if you have all required results -> generate the FINAL ANSWER to the user.\n",221    "\n",222    "REASONING REQUIREMENTS:\n",223    "\n",224    "IMPERATIVE: NO TOOL CALLS WITHOUT <REASONING> TAGS FIRST\n",225    "Keep reasoning concise but complete (2-4 sentences)\n",226    "Be logical, precise and consistent\n",227    "Always specify: current step + tool choice + expected outcome\n",228    "After receiving tool results, you may add clarifying reasoning if needed\n",229    "\n",230    "EXECUTION FLOW EXAMPLE:\n",231    "<REASONING>\n",232    "I need to execute step 1 of the plan which requires searching for information about X. I will use the web_search tool with query \"X\" to gather relevant data that the next steps depend on.\n",233    "</REASONING>\n",234    "[tool call here]\n",235    "<REASONING>\n",236    "The search returned relevant information about X. Now proceeding to step 2 which requires...\n",237    "</REASONING>\n",238    "[next tool call here]\n",239    "OUTPUT GUIDELINES:\n",240    "\n",241    "For intermediate steps: return only the results (with mandatory <REASONING> before each tool).\n",242    "For the final answer: provide a clear, concise solution to the user's request, formatted for readability.\n",243    "MANDATORY: End final solution with <FINAL_ANSWER> marker\n",244    "Do not expose internal IDs, tool errors, or system details.\n",245    "\n",246    "FAILSAFE:\n",247    "\n",248    "If the plan is empty or invalid -> return \"\" (empty string).\n",249    "If the requested task is already trivially solvable without tools -> skip execution and answer directly.\n",250    "\n",251    "COMPLIANCE CHECK:\n",252    "\n",253    "Before submitting any response, verify: \"Did I include <REASONING> before EVERY tool call?\"\n",254    "If no: add the missing reasoning blocks\n",255    "If yes: proceed with response\n",256    "\n",257    "CRITICAL REMINDERS:\n",258    "\n",259    "NO TOOL CALLS WITHOUT <REASONING> TAGS — ZERO EXCEPTIONS\n",260    "EVERY TOOL CALL MUST BE PRECEDED BY REASONING\n",261    "ADD <FINAL_ANSWER> MARKER AT THE END\n",262    "\"\"\"\n",263    "\n",264    "\n",265    "COMPLEXITY_ASSESSOR_PROMPT = \"\"\"\n",266    "You are a COMPLEXITY ASSESSOR for a multi-tool agent system.\n",267    "Your job is to analyze user queries and determine their complexity level and processing requirements.\n",268    "\n",269    "COMPLEXITY LEVELS:\n",270    "1. SIMPLE: Direct questions that can be answered immediately without tools or with single tool use\n",271    "   - Examples: \"What is 2+2?\", \"Define photosynthesis\", \"What's the capital of France?\"\n",272    "   \n",273    "2. MODERATE: Questions requiring 1-3 tool calls or basic analysis\n",274    "   - Examples: \"Search for recent news about AI\", \"Analyze this CSV file\", \"What's the weather tomorrow?\"\n",275    "   \n",276    "3. COMPLEX: Multi-step problems requiring planning, multiple tools, or sophisticated reasoning\n",277    "   - Examples: Research tasks, multi-file analysis, calculations with dependencies, creative projects\n",278    "\n",279    "ASSESSMENT CRITERIA:\n",280    "- Number of steps likely needed\n",281    "- Tool complexity and dependencies\n",282    "- Data processing requirements\n",283    "- Need for intermediate reasoning\n",284    "- Risk of failure without proper planning\n",285    "\n",286    "RULES:\n",287    "- SIMPLE queries bypass planning entirely\n",288    "- MODERATE queries may use lightweight planning\n",289    "- COMPLEX queries require full planning with fallbacks\n",290    "- When in doubt, err toward higher complexity\n",291    "\n",292    "Analyze the query and respond with your assessment.\n",293    "\"\"\"\n",294    "\n",295    "CRITIC_PROMPT = \"\"\"\n",296    "You are the CRITIC of a multi-tool agent system.\n",297    "Your job is to evaluate execution reports and provide detailed feedback.\n",298    "\n",299    "EVALUATION FRAMEWORK:\n",300    "\n",301    "1. COMPLETENESS (0-3 points):\n",302    "   - 3: Fully addresses all aspects of the query\n",303    "   - 2: Addresses main aspects, minor gaps\n",304    "   - 1: Partial answer, significant gaps\n",305    "   - 0: Incomplete or off-topic\n",306    "\n",307    "2. ACCURACY (0-3 points):\n",308    "   - 3: All information appears accurate and well-sourced\n",309    "   - 2: Mostly accurate, minor issues\n",310    "   - 1: Some accuracy concerns\n",311    "   - 0: Significant accuracy problems\n",312    "\n",313    "3. METHODOLOGY (0-2 points):\n",314    "   - 2: Appropriate tools and approach used\n",315    "   - 1: Acceptable approach, could be better\n",316    "   - 0: Poor methodology or tool selection\n",317    "\n",318    "4. EVIDENCE (0-2 points):\n",319    "   - 2: Strong evidence and sources provided\n",320    "   - 1: Some evidence provided\n",321    "   - 0: Insufficient evidence\n",322    "\n",323    "TOTAL SCORE: /10 points\n",324    "\n",325    "DECISION THRESHOLDS:\n",326    "- 8-10: Accept (excellent quality)\n",327    "- 6-7: Accept with minor notes\n",328    "- 4-5: Marginal, consider replanning\n",329    "- 0-3: Reject, requires replanning\n",330    "\n",331    "EXECUTION REPORT TO EVALUATE:\n",332    "Query: {query}\n",333    "Approach: {approach}\n",334    "Tools Used: {tools}\n",335    "Key Findings: {findings}\n",336    "Sources: {sources}\n",337    "Confidence: {confidence}\n",338    "Limitations: {limitations}\n",339    "Final Answer: {answer}\n",340    "\n",341    "Provide detailed critique focusing on what works well and what could be improved.\n",342    "\"\"\""343   ]344  },345  {346   "cell_type": "code",347   "execution_count": 6,348   "metadata": {},349   "outputs": [],350   "source": [351    "#PLANNER PYDANTIC MODELS\n",352    "\n",353    "from typing import Any, Dict, List, Optional, Literal, Iterable\n",354    "from pydantic import BaseModel, Field, ValidationError\n",355    "\n",356    "TaskType = Literal[\"info\", \"calc\", \"table\", \"doc_qa\", \"image_qa\", \"multi_hop\"]\n",357    "EvidenceTag = Literal[\"citations\", \"page_numbers\", \"figure_captions\", \"stats_check\", \"unit_check\"]\n",358    "\n",359    "class PlanStep(BaseModel):\n",360    "    id: str\n",361    "    description: str\n",362    "    #tool: Optional[str] = Field(default=None, description=\"Exact tool name or null for reasoning step\")\n",363    "    #args_hint: Dict[str, Any] = Field(default_factory=dict)\n",364    "    evidence_needed: List[EvidenceTag] = Field(default_factory=list)\n",365    "    success_criteria: str\n",366    "    on_fail: str = Field(default=\"replan\", description=\"One of: 'replan' | 'stop' | step-id\")\n",367    "    outputs_to_state: List[str] = Field(default_factory=list)\n",368    "\n",369    "class AnswerGuidelines(BaseModel):\n",370    "    final_answer_template: str\n",371    "    citations_required: bool = False\n",372    "    min_citations: int = 0\n",373    "    units_policy: Optional[str] = None\n",374    "    rounding_policy: Optional[str] = None\n",375    "    include_artifacts: List[str] = Field(default_factory=list)\n",376    "\n",377    "class PlannerPlan(BaseModel):\n",378    "    task_type: TaskType\n",379    "    assumptions: List[str] = Field(default_factory=list)\n",380    "    plan_rationale: str\n",381    "    steps: List[PlanStep]\n",382    "    answer_guidelines: AnswerGuidelines"383   ]384  },385  {386   "cell_type": "code",387   "execution_count": 7,388   "metadata": {},389   "outputs": [],390   "source": [391    "llm_with_tools = llm.bind_tools(TOOLS)\n",392    "config = {\"configurable\": {\"thread_id\": \"1\"}, \"recursion_limit\" : 50}\n",393    "TOOL_NODE = ToolNode(TOOLS)\n",394    "planner_llm = llm.with_structured_output(PlannerPlan)\n",395    "\n",396    "class ToolExecution(BaseModel):\n",397    "    tool_name: str\n",398    "    arguments: str\n",399    "    call_id: str\n",400    "    \n",401    "    class Config:\n",402    "        extra = \"forbid\"\n",403    "\n",404    "class ExecutionReport(BaseModel):\n",405    "    \"\"\"Structured report for critic evaluation.\"\"\"\n",406    "    query_summary: str = Field(description=\"Brief summary of the user's query\")\n",407    "    approach_used: str = Field(description=\"What approach/strategy was used\")\n",408    "    tools_executed: List[ToolExecution] = Field(default_factory=list, description=\"List of tools used with results\")\n",409    "    key_findings: List[str] = Field(default_factory=list, description=\"Main findings or results\")\n",410    "    data_sources: List[str] = Field(default_factory=list, description=\"Sources of information used\")\n",411    "    assumptions_made: List[str] = Field(default_factory=list, description=\"Any assumptions made during execution\")\n",412    "    confidence_level: Literal[\"low\", \"medium\", \"high\"] = Field(description=\"Confidence in the answer\")\n",413    "    limitations: List[str] = Field(default_factory=list, description=\"Known limitations or caveats\")\n",414    "    final_answer: str = Field(description=\"The actual answer to the user's query\")\n",415    "\n",416    "    class Config:\n",417    "        extra = \"forbid\"\n",418    "\n",419    "\n",420    "class AgentState(MessagesState):\n",421    "    query: str\n",422    "    final_answer: str\n",423    "    plan: Optional[PlannerPlan]\n",424    "    complexity_assessment: ComplexityLevel\n",425    "    current_step: int\n",426    "    reasoning_done: bool\n",427    "    messages : Annotated[Sequence[BaseMessage], add_messages]\n",428    "    files: List[str]\n",429    "    file_contents: Dict[str, Any]\n",430    "    critique_feedback: Optional[CritiqueFeedback]\n",431    "    iteration_count :int\n",432    "    max_iterations: int\n",433    "    execution_report : ExecutionReport\n",434    "\n",435    "\n",436    "def query_input(state : AgentState) -> AgentState:\n",437    "    print(\"=== USER QUERY TRANSFERED TO AGENT ===\")\n",438    "\n",439    "    files = state.get(\"files\", [])\n",440    "    if files:\n",441    "        print(f\"Processing {len(files)} files:\")\n",442    "        file_info = preprocess_files(files)\n",443    "    \n",444    "        for file_path, info in file_info.items():\n",445    "            print(f\"  - {file_path}: {info['type']} ({info['size']} bytes) -> {info['suggested_tool']}\")\n",446    "\n",447    "        state[\"file_contents\"] = file_info\n",448    "        file_context = \"\\n\\n=== AVAILABLE FILES FOR ANALYSIS ===\\n\"\n",449    "        for file_path, info in file_info.items():\n",450    "            filename = os.path.basename(file_path)\n",451    "            file_context += f\"File: {filename}\\n\"\n",452    "            file_context += f\"  - Type: {info['type']}\\n\"  \n",453    "            file_context += f\"  - Size: {info['size']} bytes\\n\"\n",454    "            file_context += f\"  - Suggested tool: {info['suggested_tool']}\\n\"\n",455    "            if info.get(\"preview\"):\n",456    "                file_context += f\"  - Preview: {info['preview']}\\n\"\n",457    "            file_context += \"\\n\"\n",458    "        \n",459    "        # Добавляем инструкции по работе с файлами\n",460    "        file_context += \"IMPORTANT: Use the suggested tools to analyze these files before processing their data.\\n\"\n",461    "        file_context += \"File paths are available in the agent state and can be passed directly to analysis tools.\\n\"\n",462    "        \n",463    "        original_query = state.get(\"query\", \"\")\n",464    "        state[\"query\"] = original_query + file_context\n",465    "    return state\n",466    "\n",467    "\n",468    "def planner(state : AgentState) -> AgentState:\n",469    "    sys_stack = [\n",470    "            SystemMessage(content=SYSTEM_PROMPT_PLANNER.strip()),\n",471    "            HumanMessage(content=state[\"query\"]),\n",472    "        ]\n",473    "    plan: PlannerPlan = planner_llm.invoke(sys_stack)\n",474    "    \n",475    "    print(\"=== GENERATED PLAN ===\")\n",476    "    return {\"messages\" : sys_stack + state[\"messages\"],\n",477    "            \"plan\": plan,\n",478    "            \"current_step \": 0,\n",479    "            \"reasoning_done\": False}\n",480    "\n",481    "def agent(state: AgentState) -> AgentState:\n",482    "    \n",483    "    \"\"\"\n",484    "    sys_msg = SystemMessage(\n",485    "        content=SYSTEM_EXECUTOR_PROMPT.strip().format(\n",486    "            plan=json.dumps(state[\"plan\"], indent=2)\n",487    "        )\n",488    "    )\n",489    "    \"\"\"\n",490    "    current_step = state.get(\"current_step\", 0)\n",491    "    reasoning_done = state.get(\"reasoning_done\", False)\n",492    "    plan = state.get(\"plan\", {})\n",493    "    steps = state[\"plan\"].steps\n",494    "\n",495    "    if current_step >= len(steps):\n",496    "        return {\n",497    "            \"messages\": state[\"messages\"] + [AIMessage(content=\"All steps completed. <FINAL_ANSWER>\")],\n",498    "            \"reasoning_done\": False\n",499    "        }\n",500    "\n",501    "    current_step_info = steps[current_step]\n",502    "\n",503    "    if not reasoning_done:\n",504    "\n",505    "        # ✅ ДОБАВЛЕНО: Специальный контекст для файлов\n",506    "        file_context = \"\"\n",507    "        file_contents = state.get(\"file_contents\", {})\n",508    "        if file_contents:\n",509    "            file_context = \"\\n\\nAVAILABLE FILES IN CURRENT SESSION:\\n\"\n",510    "            for filepath, info in file_contents.items():\n",511    "                filename = os.path.basename(filepath)\n",512    "                file_context += f\"- {filename}: {info['type']} file, suggested tool: {info['suggested_tool']}\\n\"\n",513    "                file_context += f\"  Path: {filepath}\\n\"\n",514    "\n",515    "        reasoning_prompt = f\"\"\"\n",516    "        {SYSTEM_EXECUTOR_PROMPT}\n",517    "        \n",518    "        CURRENT TASK: You must perform reasoning for step {current_step + 1}.\n",519    "        \n",520    "        STEP INFO: {current_step_info}\\n\\n\n",521    "\n",522    "        FILE CONTEXT: {file_contents}\n",523    "        \n",524    "        CRITICAL: You MUST output your reasoning in <REASONING> tags, but DO NOT call any tools yet.\n",525    "        Explain what you need to do and why, then end your response.\n",526    "\n",527    "        REASONING IS IMPERATIVE BEFORE ANY TOOL CALLS.\n",528    "        \"\"\"\n",529    "\n",530    "        sys_msg = SystemMessage(content = reasoning_prompt)\n",531    "        stack = [sys_msg] + state[\"messages\"]\n",532    "\n",533    "        step = llm.invoke(stack)\n",534    "        print(\"=== REASONING STEP ===\")\n",535    "        print(step.content)\n",536    "\n",537    "        return {\n",538    "            \"messages\" : state[\"messages\"] + [step],\n",539    "            \"reasoning_done\" : True\n",540    "        }\n",541    "    \n",542    "    else:\n",543    "        tool_prompt = f\"\"\"\n",544    "        Now execute the tool for step {current_step + 1}.\n",545    "        \n",546    "        STEP INFO: {current_step_info}\n",547    "        \n",548    "        You have already done the reasoning. Now call the appropriate tool with the correct parameters.\n",549    "        Available file paths: {list(state.get(\"file_contents\", {}).keys())}\\n\n",550    "        IMPORTANT NOTE: IF YOU DECIDED TO USE safe_code_run, MAKE SURE TO FINISH CALCULATIONS WITH print() or saving to a variable NAMED 'result' so that the output can be captured!\n",551    "        \"\"\" \n",552    "\n",553    "        sys_msg = SystemMessage(content=tool_prompt)\n",554    "        stack = [sys_msg] + state[\"messages\"]  # Берем последние сообщения включая reasoning\n",555    "        \n",556    "        # Используем модель С инструментами для выполнения\n",557    "        step = llm_with_tools.invoke(stack)\n",558    "        print(\"=== TOOL EXECUTION ===\")\n",559    "        print(f\"Tool calls: {step.tool_calls}\")\n",560    "        \n",561    "        return {\n",562    "            \"messages\": state[\"messages\"] + [step],\n",563    "            \"current_step\": current_step + 1 if step.tool_calls else current_step,\n",564    "            \"reasoning_done\": False  # Сбрасываем для следующего шага\n",565    "        }\n",566    "\n",567    "\n",568    "def should_continue(state : AgentState) -> bool:\n",569    "    \n",570    "    last_message = state[\"messages\"][-1]\n",571    "    reasoning_done = state.get(\"reasoning_done\", False)\n",572    "    if \"<FINAL_ANSWER>\" in last_message.content:\n",573    "        return \"final_answer\"\n",574    "    elif last_message.tool_calls:\n",575    "        return \"tools\" \n",576    "    elif not reasoning_done and \"<REASONING>\" in last_message.content:\n",577    "        # Reasoning выполнен, но инструменты еще не вызваны\n",578    "        return \"agent\"\n",579    "    elif reasoning_done:\n",580    "        # Reasoning выполнен, теперь нужно вызвать инструменты\n",581    "        return \"agent\"\n",582    "    else:\n",583    "        # Нужно сделать reasoning\n",584    "        return \"agent\"\n",585    "\n",586    "# 6. Добавить отладочную информацию в TOOL_NODE\n",587    "class DebuggingToolNode(ToolNode):\n",588    "    def __init__(self, tools):\n",589    "        super().__init__(tools)\n",590    "    \n",591    "    def __call__(self, state):\n",592    "        print(\"=== TOOL EXECUTION STARTED ===\")\n",593    "        result = super().__call__(state)\n",594    "        print(\"=== TOOL EXECUTION COMPLETED ===\")\n",595    "        return result\n",596    "\n",597    "DEBUGGING_TOOL_NODE = DebuggingToolNode(TOOLS)\n",598    "\n",599    "\n",600    "\n",601    "\"\"\"\n",602    "def summary(state : AgentState) -> AgentState:\n",603    "    print(\"=== FINAL ANSWER ===\")\n",604    "    summarizer_prompt = \n",605    "    Now you have to provide final answer for the user query : {query}\n",606    "    In messages below you have all the context you need.\n",607    "\n",608    "    YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, Apply the rules above for each element (number or string), ensure there is exactly one space after each comma.\n",609    "    Your answer should only start with \"FINAL ANSWER: \", then follows with the answer.\n",610    "\n",611    "    Here is the context:\n",612    "    {messages}\n",613    "\n",614    "    REMEMBER AND STRICTLY FOLLOW THE FORMATTING RULES ABOVE. ALWAYS USE THIS FORMAT:\n",615    "    FINAL ANSWER: ...\n",616    "    \n",617    "\n",618    "    state[\"final_answer\"] = llm.invoke([SystemMessage(content=summarizer_prompt.strip().format(query=state[\"query\"], messages = state[\"messages\"]))])\n",619    "    return state\n",620    "\"\"\"\n",621    "\n",622    "def enhanced_finalizer(state: AgentState) -> AgentState:\n",623    "    \"\"\"Generate comprehensive execution report for critic evaluation.\"\"\"\n",624    "    print(\"=== GENERATING EXECUTION REPORT ===\")\n",625    "    \n",626    "    # Extract tool execution information\n",627    "    tools_executed = []\n",628    "    data_sources = []\n",629    "    \n",630    "    for msg in state[\"messages\"]:\n",631    "        if hasattr(msg, 'tool_calls') and msg.tool_calls:\n",632    "            for tool_call in msg.tool_calls:\n",633    "                tools_executed.append(ToolExecution(\n",634    "                tool_name=tool_call['name'],\n",635    "                arguments=str(tool_call['args']),\n",636    "                call_id=tool_call['id']\n",637    "            ))\n",638    "        \n",639    "        # Extract data sources from tool results\n",640    "        if hasattr(msg, 'content') and isinstance(msg.content, str):\n",641    "            # Look for URLs, file names, or other sources\n",642    "            import re\n",643    "            urls = re.findall(r'https?://[^\\s]+', msg.content)\n",644    "            data_sources.extend(urls)\n",645    "    \n",646    "    # Get plan information if available\n",647    "    plan = state.get(\"plan\")\n",648    "    approach_used = \"Direct execution\"\n",649    "    assumptions_made = []\n",650    "    \n",651    "    if plan:\n",652    "        approach_used = f\"{plan.task_type} approach with {len(plan.steps)} steps\"\n",653    "        assumptions_made = plan.assumptions\n",654    "    \n",655    "    # Generate structured report (КОСТЫЛЬ ЗДЕСЬ!)\n",656    "    report_generator_prompt = f\"\"\"\n",657    "    Generate a comprehensive execution report for the following query processing:\n",658    "\n",659    "    ORIGINAL QUERY: {state['query']}\n",660    "    \n",661    "    EXECUTION CONTEXT:\n",662    "    - Complexity Level: {state.get('complexity_assessment', {}).level}\n",663    "    - Plan Used: {plan if plan else {}}\n",664    "    - Tools Executed: {tools_executed}\n",665    "    - Available Files: {list(state.get('file_contents', {}).keys())}\n",666    "    \n",667    "    CONVERSATION HISTORY:\n",668    "    {[msg.content[:200] + \"...\" if len(msg.content) > 200 else msg.content \n",669    "      for msg in state['messages'][-5:]]}  # Last 5 messages for context\n",670    "    \n",671    "    Based on this information, create a structured execution report that includes:\n",672    "    1. Query summary\n",673    "    2. Approach used\n",674    "    3. Key findings from the execution\n",675    "    4. Data sources used\n",676    "    5. Your confidence level in the results\n",677    "    6. Any limitations or caveats\n",678    "    7. The final answer\n",679    "    \n",680    "    Be thorough but concise. This report will be evaluated by a critic for quality assurance.\n",681    "    \"\"\"\n",682    "    \n",683    "    report_llm = llm.with_structured_output(ExecutionReport)\n",684    "    \n",685    "    execution_report = report_llm.invoke([\n",686    "        SystemMessage(content=report_generator_prompt),\n",687    "        HumanMessage(content=\"Generate the execution report.\")\n",688    "    ])\n",689    "    \n",690    "    print(f\"Report generated - Confidence: {execution_report.confidence_level}\")\n",691    "    print(f\"Key findings: {len(execution_report.key_findings)}\")\n",692    "    print(f\"Data sources: {len(execution_report.data_sources)}\")\n",693    "    \n",694    "    # Format final answer for user\n",695    "    formatted_answer = format_final_answer(execution_report, state.get('complexity_assessment', {}))\n",696    "    print(execution_report)\n",697    "    return {\n",698    "        \"execution_report\": execution_report,\n",699    "        \"final_answer\": formatted_answer\n",700    "    }\n",701    "\n",702    "def format_final_answer(report: ExecutionReport, complexity: dict) -> str:\n",703    "    \"\"\"Format the final answer based on complexity and report content.\"\"\"\n",704    "    \n",705    "    if complexity.level == 'simple':\n",706    "        # For simple queries, just return the answer\n",707    "        return f\"FINAL ANSWER: {report.final_answer}\"\n",708    "    \n",709    "    # For complex queries, provide more detailed response\n",710    "    formatted = f\"\"\"FINAL ANSWER: {report.final_answer}\n",711    "\n",712    "SUMMARY:\n",713    "{report.query_summary}\n",714    "\n",715    "KEY FINDINGS:\n",716    "{chr(10).join(f\"• {finding}\" for finding in report.key_findings)}\"\"\"\n",717    "    \n",718    "    if report.data_sources:\n",719    "        formatted += f\"\"\"\n",720    "\n",721    "SOURCES:\n",722    "{chr(10).join(f\"• {source}\" for source in report.data_sources[:5])}\"\"\"  # Limit to 5 sources\n",723    "    \n",724    "    if report.limitations:\n",725    "        formatted += f\"\"\"\n",726    "\n",727    "LIMITATIONS:\n",728    "{chr(10).join(f\"• {limitation}\" for limitation in report.limitations)}\"\"\"\n",729    "    \n",730    "    return formatted\n",731    "\n",732    "\n",733    "def complexity_assessor(state: AgentState) -> AgentState:\n",734    "    \"\"\"Assess query complexity and determine if planning is needed.\"\"\"\n",735    "    print(\"=== COMPLEXITY ASSESSMENT ===\")\n",736    "    \n",737    "    complexity_llm = llm.with_structured_output(ComplexityLevel)\n",738    "    \n",739    "    assessment_message = [\n",740    "        SystemMessage(content=COMPLEXITY_ASSESSOR_PROMPT.strip()),\n",741    "        HumanMessage(content=f\"Query: {state['query']}\")\n",742    "    ]\n",743    "    \n",744    "    assessment = complexity_llm.invoke(assessment_message)\n",745    "    \n",746    "    print(f\"Complexity: {assessment.level}\")\n",747    "    print(f\"Needs planning: {assessment.needs_planning}\")\n",748    "    print(f\"Reasoning: {assessment.reasoning}\")\n",749    "    \n",750    "    return {\n",751    "        \"complexity_assessment\": assessment,\n",752    "        \"messages\": state[\"messages\"] + assessment_message\n",753    "    }\n",754    "\n",755    "\n",756    "def simple_executor(state: AgentState) -> AgentState:\n",757    "    \"\"\"Handle simple queries directly without planning.\"\"\"\n",758    "    print(\"=== SIMPLE EXECUTION ===\")\n",759    "    \n",760    "    # For simple queries, use the LLM with tools directly\n",761    "    simple_prompt = f\"\"\"\n",762    "    Answer this simple query directly and efficiently: {state['query']}\n",763    "    \n",764    "    You have access to tools if needed, but try to answer directly when possible.\n",765    "    If you need files, they are available at: {list(state.get('file_contents', {}).keys())}\n",766    "    \n",767    "    Provide a clear, concise answer.\n",768    "    \"\"\"\n",769    "    \n",770    "    response = llm_with_tools.invoke([\n",771    "        SystemMessage(content=simple_prompt),\n",772    "        HumanMessage(content=state['query'])\n",773    "    ])\n",774    "    \n",775    "    return {\n",776    "        \"messages\": state[\"messages\"] + [response],\n",777    "        \"final_answer\": response.content\n",778    "    }\n",779    "\n",780    "\n",781    "def should_use_planning(state: AgentState) -> str:\n",782    "    \"\"\"Route based on complexity assessment.\"\"\"\n",783    "    complexity = state[\"complexity_assessment\"]\n",784    "    \n",785    "    if complexity.level == \"simple\" and not complexity.needs_planning:\n",786    "        return \"simple_executor\"\n",787    "    else:\n",788    "        return \"planner\"\n",789    "    \n",790    "\"\"\"    \n",791    "def critic_evaluator(state: AgentState) -> AgentState:\n",792    "    \n",793    "    print(\"=== ANSWER CRITIQUE ===\")\n",794    "    \n",795    "    critic_llm = llm.with_structured_output(CritiqueFeedback)\n",796    "    \n",797    "    # Gather tool execution results for context\n",798    "    tool_results = []\n",799    "    for msg in state[\"messages\"]:\n",800    "        if hasattr(msg, 'tool_calls') and msg.tool_calls:\n",801    "            tool_results.extend([f\"Tool: {tc['name']}, Args: {tc['args']}\" for tc in msg.tool_calls])\n",802    "    \n",803    "    if state.get(\"plan\"):\n",804    "        terra = state.get(\"plan\")\n",805    "    else:\n",806    "        terra = \"No plan used\"\n",807    "    critique_prompt = CRITIC_PROMPT.format(\n",808    "        query=state[\"query\"],\n",809    "        plan=terra,\n",810    "        answer=state[\"final_answer\"],\n",811    "        tool_results=tool_results[:5]   #Limit context\n",812    "    )\n",813    "    \n",814    "    critique = critic_llm.invoke([\n",815    "        SystemMessage(content=critique_prompt),\n",816    "        HumanMessage(content=\"Please evaluate this answer.\")\n",817    "    ])\n",818    "    \n",819    "    print(f\"Quality Score: {critique.quality_score}/10\")\n",820    "    print(f\"Complete: {critique.is_complete}\")\n",821    "    print(f\"Accurate: {critique.is_accurate}\")\n",822    "    if critique.errors_found:\n",823    "        print(f\"Errors: {critique.errors_found}\")\n",824    "    if critique.needs_replanning:\n",825    "        print(f\"Needs replanning: {critique.replan_instructions}\")\n",826    "    \n",827    "    return {\n",828    "        \"critique_feedback\": critique,\n",829    "        \"iteration_count\": state.get(\"iteration_count\", 0) + 1\n",830    "    }\n",831    "\"\"\"\n",832    "\n",833    "def critic_evaluator(state: AgentState) -> AgentState:\n",834    "    \"\"\"Enhanced critic that evaluates execution reports.\"\"\"\n",835    "    print(\"=== ENHANCED ANSWER CRITIQUE ===\")\n",836    "    \n",837    "    report = state.get(\"execution_report\")\n",838    "    critic_llm = llm.with_structured_output(CritiqueFeedback)\n",839    "    \n",840    "    critique_prompt = CRITIC_PROMPT.format(\n",841    "        query=report.query_summary,\n",842    "        approach=report.approach_used,\n",843    "        tools=report.tools_executed,\n",844    "        findings=report.key_findings,\n",845    "        sources=report.data_sources,\n",846    "        confidence=report.confidence_level,\n",847    "        limitations=report.limitations,\n",848    "        answer=report.final_answer\n",849    "    )\n",850    "    \n",851    "    critique = critic_llm.invoke([\n",852    "        SystemMessage(content=critique_prompt),\n",853    "        HumanMessage(content=\"Evaluate this execution report thoroughly.\")\n",854    "    ])\n",855    "    \n",856    "    print(f\"Quality Score: {critique.quality_score}/10\")\n",857    "    print(f\"Complete: {critique.is_complete}\")\n",858    "    print(f\"Accurate: {critique.is_accurate}\")\n",859    "    \n",860    "    if critique.errors_found:\n",861    "        print(f\"Issues found: {critique.errors_found}\")\n",862    "    \n",863    "    if critique.needs_replanning:\n",864    "        print(f\"Replanning needed: {critique.replan_instructions}\")\n",865    "    \n",866    "    return {\n",867    "        \"critique_feedback\": critique,\n",868    "        \"iteration_count\": state.get(\"iteration_count\", 0) + 1\n",869    "    }\n",870    "\n",871    "\n",872    "\n",873    "def should_replan(state: AgentState) -> str:\n",874    "    \"\"\"Decide whether to accept answer, replan, or stop.\"\"\"\n",875    "    critique = state.get(\"critique_feedback\")\n",876    "    iteration_count = state.get(\"iteration_count\", 0)\n",877    "    max_iterations = state.get(\"max_iterations\", 3)\n",878    "    \n",879    "    if not critique:\n",880    "        return \"end\"\n",881    "    \n",882    "    # Stop if max iterations reached\n",883    "    if iteration_count >= max_iterations:\n",884    "        print(f\"Max iterations ({max_iterations}) reached. Accepting current answer.\")\n",885    "        return \"end\"\n",886    "    \n",887    "    # Accept if quality is good enough\n",888    "    if critique.quality_score >= 7 or not critique.needs_replanning:\n",889    "        return \"end\"\n",890    "    \n",891    "    # Replan if quality is poor and we haven't exceeded max iterations\n",892    "    if critique.needs_replanning and iteration_count < max_iterations:\n",893    "        print(\"Replanning due to critic feedback...\")\n",894    "        return \"replan\"\n",895    "    \n",896    "    return \"end\"\n",897    "\n",898    "def replanner(state: AgentState) -> AgentState:\n",899    "    \"\"\"Create a revised plan based on critic feedback.\"\"\"\n",900    "    print(\"=== REPLANNING ===\")\n",901    "    \n",902    "    critique = state[\"critique_feedback\"]\n",903    "    previous_plan = state.get(\"plan\")\n",904    "    \n",905    "    replan_prompt = f\"\"\"\n",906    "    {SYSTEM_PROMPT_PLANNER}\n",907    "    \n",908    "    REPLANNING CONTEXT:\n",909    "    Original Query: {state['query']}\n",910    "    Previous Plan: {previous_plan if previous_plan else {}}\n",911    "    \n",912    "    CRITIC FEEDBACK:\n",913    "    - Quality Score: {critique.quality_score}/10\n",914    "    - Issues Found: {critique.errors_found}\n",915    "    - Missing Elements: {critique.missing_elements}\n",916    "    - Improvement Suggestions: {critique.suggested_improvements}\n",917    "    - Specific Instructions: {critique.replan_instructions}\n",918    "    \n",919    "    Create a REVISED plan that addresses these issues. Focus on fixing the identified problems.\n",920    "    \"\"\"\n",921    "    \n",922    "    revised_plan = planner_llm.invoke([\n",923    "        SystemMessage(content=replan_prompt),\n",924    "        HumanMessage(content=\"Create a revised plan based on the feedback.\")\n",925    "    ])\n",926    "    \n",927    "    print(\"Plan revised based on critic feedback\")\n",928    "    \n",929    "    return {\n",930    "        \"plan\": revised_plan,\n",931    "        \"current_step\": 0,\n",932    "        \"reasoning_done\": False\n",933    "        #\"messages\": [] Reset messages for fresh execution\n",934    "    }\n"935   ]936  },937  {938   "cell_type": "code",939   "execution_count": 8,940   "metadata": {},941   "outputs": [],942   "source": [943    "#GRAPH BUILDING\n",944    "\n",945    "builder = StateGraph(AgentState)\n",946    "builder.add_node(\"INPUT\", query_input)\n",947    "builder.add_node(\"COMPLEXITY_ASSESSOR\", complexity_assessor)\n",948    "builder.add_node(\"PLANNING\", planner)\n",949    "builder.add_node(\"AGENT\", agent)\n",950    "builder.add_node(\"TOOLS\", DEBUGGING_TOOL_NODE)\n",951    "builder.add_node(\"FINALIZER\", enhanced_finalizer)\n",952    "builder.add_node(\"SIMPLE_EXECUTOR\", simple_executor)\n",953    "builder.add_node(\"CRITIC\", critic_evaluator)\n",954    "builder.add_node(\"REPLANNER\", replanner)\n",955    "\n",956    "builder.set_entry_point(\"INPUT\")\n",957    "builder.add_edge(\"INPUT\", \"COMPLEXITY_ASSESSOR\")\n",958    "\n",959    "builder.add_conditional_edges(\n",960    "        \"COMPLEXITY_ASSESSOR\",\n",961    "        should_use_planning,\n",962    "        {\"simple_executor\": \"SIMPLE_EXECUTOR\", \"planner\": \"PLANNING\"},\n",963    "    )\n",964    "builder.add_edge(\"SIMPLE_EXECUTOR\", \"FINALIZER\")\n",965    "\n",966    "\n",967    "builder.add_edge(\"PLANNING\", \"AGENT\")\n",968    "builder.add_conditional_edges(\n",969    "        \"AGENT\",\n",970    "        should_continue,\n",971    "        {\"tools\": \"TOOLS\", \"agent\": \"AGENT\", \"final_answer\": \"FINALIZER\"},\n",972    "    )\n",973    "builder.add_edge(\"TOOLS\", \"AGENT\")\n",974    "builder.add_edge(\"FINALIZER\", \"CRITIC\")\n",975    "builder.add_conditional_edges(\n",976    "        \"CRITIC\",\n",977    "        should_replan,\n",978    "        {\"end\": END, \"replan\": \"REPLANNER\"},\n",979    "    )\n",980    "builder.add_edge(\"REPLANNER\", \"AGENT\")\n",981    "\n",982    "\n",983    "system = builder.compile(checkpointer=MemorySaver())"984   ]985  },986  {987   "cell_type": "code",988   "execution_count": 9,989   "metadata": {},990   "outputs": [991    {992     "name": "stdout",993     "output_type": "stream",994     "text": [995      "=== USER QUERY TRANSFERED TO AGENT ===\n",996      "=== COMPLEXITY ASSESSMENT ===\n",997      "Complexity: complex\n",998      "Needs planning: True\n",999      "Reasoning: This query involves multiple steps, including identifying the specific kit version, locating the relevant paper, extracting data about the vials, and performing calculations to determine the cumulative volume of fluid. It requires sophisticated reasoning and potentially multiple tool calls to gather and analyze the necessary data.\n",1000      "=== GENERATED PLAN ===\n",1001      "=== REASONING STEP ===\n",1002      "{\n",1003      "  \"task_type\": \"doc_qa\",\n",1004      "  \"assumptions\": [\n",1005      "    \"The paper contains specific information about the 114 version of the kit and the opaque-capped vials without stickers.\",\n",1006      "    \"The cumulative milliliters of fluid in the vials can be extracted from the text.\"\n",1007      "  ],\n",1008      "  \"plan_rationale\": \"I will use the doc_qa tool to extract text from the paper to find details about the 114 version of the kit and the opaque-capped vials without stickers. This step is essential to gather the necessary information for calculating the cumulative fluid volume.\",\n",1009      "  \"steps\": [\n",1010      "    {\n",1011      "      \"id\": \"s1\",\n",1012      "      \"description\": \"Extract text from the paper to find details about the 114 version of the kit and the opaque-capped vials without stickers.\",\n",1013      "      \"evidence_needed\": [\"page_numbers\"],\n",1014      "      \"success_criteria\": \"Successfully extract relevant information about the vials and their fluid volumes.\",\n",1015      "      \"on_fail\": \"stop\",\n",1016      "      \"outputs_to_state\": [\"cumulative milliliters of fluid in opaque-capped vials without stickers\"]\n",1017      "    }\n",1018      "  ],\n",1019      "  \"answer_guidelines\": {\n",1020      "    \"final_answer_template\": \"Report the total cumulative milliliters of fluid found in the opaque-capped vials without stickers.\",\n",1021      "    \"citations_required\": true,\n",1022      "    \"min_citations\": 1,\n",1023      "    \"units_policy\": \"Report in milliliters (mL).\",\n",1024      "    \"rounding_policy\": \"Round to two decimal places.\",\n",1025      "    \"include_artifacts\": [\"snippets\"]\n",1026      "  }\n",1027      "}\n",1028      "=== TOOL EXECUTION ===\n",1029      "Tool calls: []\n",1030      "=== REASONING STEP ===\n",1031      "{\n",1032      "  \"task_type\": \"doc_qa\",\n",1033      "  \"assumptions\": [\n",1034      "    \"The paper contains specific information about the 114 version of the kit and the opaque-capped vials without stickers.\",\n",1035      "    \"The cumulative milliliters of fluid in the vials can be extracted from the text.\"\n",1036      "  ],\n",1037      "  \"plan_rationale\": \"I will use the doc_qa tool to extract text from the paper to find details about the 114 version of the kit and the opaque-capped vials without stickers. This step is essential to gather the necessary information for calculating the cumulative fluid volume.\",\n",1038      "  \"steps\": [\n",1039      "    {\n",1040      "      \"id\": \"s1\",\n",1041      "      \"description\": \"Extract text from the paper to find details about the 114 version of the kit and the opaque-capped vials without stickers.\",\n",1042      "      \"evidence_needed\": [\"page_numbers\"],\n",1043      "      \"success_criteria\": \"Successfully extract relevant information about the vials and their fluid volumes.\",\n",1044      "      \"on_fail\": \"stop\",\n",1045      "      \"outputs_to_state\": [\"cumulative milliliters of fluid in opaque-capped vials without stickers\"]\n",1046      "    }\n",1047      "  ],\n",1048      "  \"answer_guidelines\": {\n",1049      "    \"final_answer_template\": \"Report the total cumulative milliliters of fluid found in the opaque-capped vials without stickers.\",\n",1050      "    \"citations_required\": true,\n",1051      "    \"min_citations\": 1,\n",1052      "    \"units_policy\": \"Report in milliliters (mL).\",\n",1053      "    \"rounding_policy\": \"Round to two decimal places.\",\n",1054      "    \"include_artifacts\": [\"snippets\"]\n",1055      "  }\n",1056      "}\n",1057      "=== TOOL EXECUTION ===\n",1058      "Tool calls: []\n",1059      "=== REASONING STEP ===\n",1060      "<REASONING>\n",1061      "I need to execute step 1 of the plan, which involves extracting text from the paper to find details about the 114 version of the kit and the opaque-capped vials without stickers. I will use the doc_qa tool to gather this information, as it is essential for determining the cumulative milliliters of fluid in the vials. The specific input for this tool will be the reference to the paper mentioned in the query. I expect to receive relevant information about the vials and their fluid volumes as output.\n",1062      "</REASONING>\n",1063      "[tool call here]\n",1064      "=== TOOL EXECUTION ===\n",1065      "Tool calls: [{'name': 'arxiv_search', 'args': {'query': 'De Novo-Whole Genome Assembly of the Roborovski Dwarf Hamster (Phodopus roborovskii) Genome'}, 'id': 'call_eKQUtRMjgGsgO7ITT2afdsOA', 'type': 'tool_call'}]\n",1066      "=== GENERATING EXECUTION REPORT ===\n"1067     ]1068    },1069    {1070     "ename": "KeyboardInterrupt",1071     "evalue": "",1072     "output_type": "error",1073     "traceback": [1074      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",1075      "\u001b[31mKeyboardInterrupt\u001b[39m                         Traceback (most recent call last)",1076      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[9]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m workflow = \u001b[43msystem\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mquery\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mHow many cumulative milliliters of fluid is in all the opaque-capped vials without stickers in the 114 version of the kit that was used for the PromethION long-read sequencing in the paper De Novo-Whole Genome Assembly of the Roborovski Dwarf Hamster (Phodopus roborovskii) Genome?\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcurrent_step\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mreasoning_done\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfiles\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfiles_contents\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43miteration_count\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_iterations\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m10\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mplan\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m}\u001b[49m\u001b[43m \u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n",1077      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\pregel\\main.py:3026\u001b[39m, in \u001b[36mPregel.invoke\u001b[39m\u001b[34m(self, input, config, context, stream_mode, print_mode, output_keys, interrupt_before, interrupt_after, durability, **kwargs)\u001b[39m\n\u001b[32m   3023\u001b[39m chunks: \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mdict\u001b[39m[\u001b[38;5;28mstr\u001b[39m, Any] | Any] = []\n\u001b[32m   3024\u001b[39m interrupts: \u001b[38;5;28mlist\u001b[39m[Interrupt] = []\n\u001b[32m-> \u001b[39m\u001b[32m3026\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   3027\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m   3028\u001b[39m \u001b[43m    \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3029\u001b[39m \u001b[43m    \u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3030\u001b[39m \u001b[43m    \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m=\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mupdates\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[32m   3031\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\n\u001b[32m   3032\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3033\u001b[39m \u001b[43m    \u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m=\u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3034\u001b[39m \u001b[43m    \u001b[49m\u001b[43moutput_keys\u001b[49m\u001b[43m=\u001b[49m\u001b[43moutput_keys\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3035\u001b[39m \u001b[43m    \u001b[49m\u001b[43minterrupt_before\u001b[49m\u001b[43m=\u001b[49m\u001b[43minterrupt_before\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3036\u001b[39m \u001b[43m    \u001b[49m\u001b[43minterrupt_after\u001b[49m\u001b[43m=\u001b[49m\u001b[43minterrupt_after\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3037\u001b[39m \u001b[43m    \u001b[49m\u001b[43mdurability\u001b[49m\u001b[43m=\u001b[49m\u001b[43mdurability\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3038\u001b[39m \u001b[43m    \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   3039\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m   3040\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mvalues\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\n\u001b[32m   3041\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[43m==\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m2\u001b[39;49m\u001b[43m:\u001b[49m\n",1078      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\pregel\\main.py:2647\u001b[39m, in \u001b[36mPregel.stream\u001b[39m\u001b[34m(self, input, config, context, stream_mode, print_mode, output_keys, interrupt_before, interrupt_after, durability, subgraphs, debug, **kwargs)\u001b[39m\n\u001b[32m   2645\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m task \u001b[38;5;129;01min\u001b[39;00m loop.match_cached_writes():\n\u001b[32m   2646\u001b[39m     loop.output_writes(task.id, task.writes, cached=\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[32m-> \u001b[39m\u001b[32m2647\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m_\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrunner\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtick\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   2648\u001b[39m \u001b[43m    \u001b[49m\u001b[43m[\u001b[49m\u001b[43mt\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mloop\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtasks\u001b[49m\u001b[43m.\u001b[49m\u001b[43mvalues\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mt\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwrites\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   2649\u001b[39m \u001b[43m    \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstep_timeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   2650\u001b[39m \u001b[43m    \u001b[49m\u001b[43mget_waiter\u001b[49m\u001b[43m=\u001b[49m\u001b[43mget_waiter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   2651\u001b[39m \u001b[43m    \u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m=\u001b[49m\u001b[43mloop\u001b[49m\u001b[43m.\u001b[49m\u001b[43maccept_push\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   2652\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m   2653\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;66;43;03m# emit output\u001b[39;49;00m\n\u001b[32m   2654\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;28;43;01myield from\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m_output\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   2655\u001b[39m \u001b[43m        \u001b[49m\u001b[43mstream_mode\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprint_mode\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msubgraphs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mqueue\u001b[49m\u001b[43m.\u001b[49m\u001b[43mEmpty\u001b[49m\n\u001b[32m   2656\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   2657\u001b[39m loop.after_tick()\n",1079      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\pregel\\_runner.py:162\u001b[39m, in \u001b[36mPregelRunner.tick\u001b[39m\u001b[34m(self, tasks, reraise, timeout, retry_policy, get_waiter, schedule_task)\u001b[39m\n\u001b[32m    160\u001b[39m t = tasks[\u001b[32m0\u001b[39m]\n\u001b[32m    161\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m162\u001b[39m     \u001b[43mrun_with_retry\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    163\u001b[39m \u001b[43m        \u001b[49m\u001b[43mt\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    164\u001b[39m \u001b[43m        \u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    165\u001b[39m \u001b[43m        \u001b[49m\u001b[43mconfigurable\u001b[49m\u001b[43m=\u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m    166\u001b[39m \u001b[43m            \u001b[49m\u001b[43mCONFIG_KEY_CALL\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpartial\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    167\u001b[39m \u001b[43m                \u001b[49m\u001b[43m_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    168\u001b[39m \u001b[43m                \u001b[49m\u001b[43mweakref\u001b[49m\u001b[43m.\u001b[49m\u001b[43mref\u001b[49m\u001b[43m(\u001b[49m\u001b[43mt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    169\u001b[39m \u001b[43m                \u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m=\u001b[49m\u001b[43mretry_policy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    170\u001b[39m \u001b[43m                \u001b[49m\u001b[43mfutures\u001b[49m\u001b[43m=\u001b[49m\u001b[43mweakref\u001b[49m\u001b[43m.\u001b[49m\u001b[43mref\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfutures\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    171\u001b[39m \u001b[43m                \u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m=\u001b[49m\u001b[43mschedule_task\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    172\u001b[39m \u001b[43m                \u001b[49m\u001b[43msubmit\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43msubmit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    173\u001b[39m \u001b[43m            \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    174\u001b[39m \u001b[43m        \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    175\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    176\u001b[39m     \u001b[38;5;28mself\u001b[39m.commit(t, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m    177\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",1080      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\pregel\\_retry.py:42\u001b[39m, in \u001b[36mrun_with_retry\u001b[39m\u001b[34m(task, retry_policy, configurable)\u001b[39m\n\u001b[32m     40\u001b[39m     task.writes.clear()\n\u001b[32m     41\u001b[39m     \u001b[38;5;66;03m# run the task\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m42\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtask\u001b[49m\u001b[43m.\u001b[49m\u001b[43mproc\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtask\u001b[49m\u001b[43m.\u001b[49m\u001b[43minput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m     43\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m ParentCommand \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m     44\u001b[39m     ns: \u001b[38;5;28mstr\u001b[39m = config[CONF][CONFIG_KEY_CHECKPOINT_NS]\n",1081      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\_internal\\_runnable.py:657\u001b[39m, in \u001b[36mRunnableSeq.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m    655\u001b[39m     \u001b[38;5;66;03m# run in context\u001b[39;00m\n\u001b[32m    656\u001b[39m     \u001b[38;5;28;01mwith\u001b[39;00m set_config_context(config, run) \u001b[38;5;28;01mas\u001b[39;00m context:\n\u001b[32m--> \u001b[39m\u001b[32m657\u001b[39m         \u001b[38;5;28minput\u001b[39m = \u001b[43mcontext\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstep\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    658\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    659\u001b[39m     \u001b[38;5;28minput\u001b[39m = step.invoke(\u001b[38;5;28minput\u001b[39m, config)\n",1082      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langgraph\\_internal\\_runnable.py:401\u001b[39m, in \u001b[36mRunnableCallable.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m    399\u001b[39m         run_manager.on_chain_end(ret)\n\u001b[32m    400\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m401\u001b[39m     ret = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    402\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.recurse \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(ret, Runnable):\n\u001b[32m    403\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m ret.invoke(\u001b[38;5;28minput\u001b[39m, config)\n",1083      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 295\u001b[39m, in \u001b[36menhanced_finalizer\u001b[39m\u001b[34m(state)\u001b[39m\n\u001b[32m    266\u001b[39m report_generator_prompt = \u001b[33mf\u001b[39m\u001b[33m\"\"\"\u001b[39m\n\u001b[32m    267\u001b[39m \u001b[33mGenerate a comprehensive execution report for the following query processing:\u001b[39m\n\u001b[32m    268\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m    290\u001b[39m \u001b[33mBe thorough but concise. This report will be evaluated by a critic for quality assurance.\u001b[39m\n\u001b[32m    291\u001b[39m \u001b[33m\u001b[39m\u001b[33m\"\"\"\u001b[39m\n\u001b[32m    293\u001b[39m report_llm = llm.with_structured_output(ExecutionReport)\n\u001b[32m--> \u001b[39m\u001b[32m295\u001b[39m execution_report = \u001b[43mreport_llm\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\n\u001b[32m    296\u001b[39m \u001b[43m    \u001b[49m\u001b[43mSystemMessage\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcontent\u001b[49m\u001b[43m=\u001b[49m\u001b[43mreport_generator_prompt\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    297\u001b[39m \u001b[43m    \u001b[49m\u001b[43mHumanMessage\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcontent\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mGenerate the execution report.\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m    298\u001b[39m \u001b[43m\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    300\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mReport generated - Confidence: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mexecution_report.confidence_level\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m    301\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mKey findings: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(execution_report.key_findings)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n",1084      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\runnables\\base.py:3243\u001b[39m, in \u001b[36mRunnableSequence.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m   3241\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m set_config_context(config) \u001b[38;5;28;01mas\u001b[39;00m context:\n\u001b[32m   3242\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m i == \u001b[32m0\u001b[39m:\n\u001b[32m-> \u001b[39m\u001b[32m3243\u001b[39m         input_ = \u001b[43mcontext\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstep\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43minput_\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   3244\u001b[39m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m   3245\u001b[39m         input_ = context.run(step.invoke, input_, config)\n",1085      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\runnables\\base.py:5710\u001b[39m, in \u001b[36mRunnableBindingBase.invoke\u001b[39m\u001b[34m(self, input, config, **kwargs)\u001b[39m\n\u001b[32m   5703\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m   5704\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34minvoke\u001b[39m(\n\u001b[32m   5705\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   (...)\u001b[39m\u001b[32m   5708\u001b[39m     **kwargs: Optional[Any],\n\u001b[32m   5709\u001b[39m ) -> Output:\n\u001b[32m-> \u001b[39m\u001b[32m5710\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mbound\u001b[49m\u001b[43m.\u001b[49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   5711\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m   5712\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_merge_configs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   5713\u001b[39m \u001b[43m        \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43m{\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m   5714\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",1086      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:395\u001b[39m, in \u001b[36mBaseChatModel.invoke\u001b[39m\u001b[34m(self, input, config, stop, **kwargs)\u001b[39m\n\u001b[32m    383\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m    384\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34minvoke\u001b[39m(\n\u001b[32m    385\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   (...)\u001b[39m\u001b[32m    390\u001b[39m     **kwargs: Any,\n\u001b[32m    391\u001b[39m ) -> BaseMessage:\n\u001b[32m    392\u001b[39m     config = ensure_config(config)\n\u001b[32m    393\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m cast(\n\u001b[32m    394\u001b[39m         \u001b[33m\"\u001b[39m\u001b[33mChatGeneration\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m--> \u001b[39m\u001b[32m395\u001b[39m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mgenerate_prompt\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    396\u001b[39m \u001b[43m            \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_convert_input\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    397\u001b[39m \u001b[43m            \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    398\u001b[39m \u001b[43m            \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcallbacks\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    399\u001b[39m \u001b[43m            \u001b[49m\u001b[43mtags\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtags\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    400\u001b[39m \u001b[43m            \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmetadata\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    401\u001b[39m \u001b[43m            \u001b[49m\u001b[43mrun_name\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mrun_name\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    402\u001b[39m \u001b[43m            \u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m=\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mrun_id\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    403\u001b[39m \u001b[43m            \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    404\u001b[39m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m.generations[\u001b[32m0\u001b[39m][\u001b[32m0\u001b[39m],\n\u001b[32m    405\u001b[39m     ).message\n",1087      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:1023\u001b[39m, in \u001b[36mBaseChatModel.generate_prompt\u001b[39m\u001b[34m(self, prompts, stop, callbacks, **kwargs)\u001b[39m\n\u001b[32m   1014\u001b[39m \u001b[38;5;129m@override\u001b[39m\n\u001b[32m   1015\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mgenerate_prompt\u001b[39m(\n\u001b[32m   1016\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   (...)\u001b[39m\u001b[32m   1020\u001b[39m     **kwargs: Any,\n\u001b[32m   1021\u001b[39m ) -> LLMResult:\n\u001b[32m   1022\u001b[39m     prompt_messages = [p.to_messages() \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;129;01min\u001b[39;00m prompts]\n\u001b[32m-> \u001b[39m\u001b[32m1023\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mgenerate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprompt_messages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",1088      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:840\u001b[39m, in \u001b[36mBaseChatModel.generate\u001b[39m\u001b[34m(self, messages, stop, callbacks, tags, metadata, run_name, run_id, **kwargs)\u001b[39m\n\u001b[32m    837\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m i, m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(input_messages):\n\u001b[32m    838\u001b[39m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    839\u001b[39m         results.append(\n\u001b[32m--> \u001b[39m\u001b[32m840\u001b[39m             \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_generate_with_cache\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    841\u001b[39m \u001b[43m                \u001b[49m\u001b[43mm\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    842\u001b[39m \u001b[43m                \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    843\u001b[39m \u001b[43m                \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrun_managers\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrun_managers\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m    844\u001b[39m \u001b[43m                \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    845\u001b[39m \u001b[43m            \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    846\u001b[39m         )\n\u001b[32m    847\u001b[39m     \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[32m    848\u001b[39m         \u001b[38;5;28;01mif\u001b[39;00m run_managers:\n",1089      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_core\\language_models\\chat_models.py:1089\u001b[39m, in \u001b[36mBaseChatModel._generate_with_cache\u001b[39m\u001b[34m(self, messages, stop, run_manager, **kwargs)\u001b[39m\n\u001b[32m   1087\u001b[39m     result = generate_from_stream(\u001b[38;5;28miter\u001b[39m(chunks))\n\u001b[32m   1088\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m inspect.signature(\u001b[38;5;28mself\u001b[39m._generate).parameters.get(\u001b[33m\"\u001b[39m\u001b[33mrun_manager\u001b[39m\u001b[33m\"\u001b[39m):\n\u001b[32m-> \u001b[39m\u001b[32m1089\u001b[39m     result = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_generate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1090\u001b[39m \u001b[43m        \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\n\u001b[32m   1091\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1092\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m   1093\u001b[39m     result = \u001b[38;5;28mself\u001b[39m._generate(messages, stop=stop, **kwargs)\n",1090      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\langchain_openai\\chat_models\\base.py:1152\u001b[39m, in \u001b[36mBaseChatOpenAI._generate\u001b[39m\u001b[34m(self, messages, stop, run_manager, **kwargs)\u001b[39m\n\u001b[32m   1149\u001b[39m payload.pop(\u001b[33m\"\u001b[39m\u001b[33mstream\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m   1150\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m   1151\u001b[39m     raw_response = (\n\u001b[32m-> \u001b[39m\u001b[32m1152\u001b[39m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mroot_client\u001b[49m\u001b[43m.\u001b[49m\u001b[43mchat\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcompletions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mwith_raw_response\u001b[49m\u001b[43m.\u001b[49m\u001b[43mparse\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m   1153\u001b[39m \u001b[43m            \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mpayload\u001b[49m\n\u001b[32m   1154\u001b[39m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1155\u001b[39m     )\n\u001b[32m   1156\u001b[39m     response = raw_response.parse()\n\u001b[32m   1157\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m openai.BadRequestError \u001b[38;5;28;01mas\u001b[39;00m e:\n",1091      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\openai\\_legacy_response.py:364\u001b[39m, in \u001b[36mto_raw_response_wrapper.<locals>.wrapped\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m    360\u001b[39m extra_headers[RAW_RESPONSE_HEADER] = \u001b[33m\"\u001b[39m\u001b[33mtrue\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    362\u001b[39m kwargs[\u001b[33m\"\u001b[39m\u001b[33mextra_headers\u001b[39m\u001b[33m\"\u001b[39m] = extra_headers\n\u001b[32m--> \u001b[39m\u001b[32m364\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m cast(LegacyAPIResponse[R], \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m)\n",1092      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\openai\\resources\\chat\\completions\\completions.py:183\u001b[39m, in \u001b[36mCompletions.parse\u001b[39m\u001b[34m(self, messages, model, audio, response_format, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, prompt_cache_key, reasoning_effort, safety_identifier, seed, service_tier, stop, store, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, verbosity, web_search_options, extra_headers, extra_query, extra_body, timeout)\u001b[39m\n\u001b[32m    176\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mparser\u001b[39m(raw_completion: ChatCompletion) -> ParsedChatCompletion[ResponseFormatT]:\n\u001b[32m    177\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m _parse_chat_completion(\n\u001b[32m    178\u001b[39m         response_format=response_format,\n\u001b[32m    179\u001b[39m         chat_completion=raw_completion,\n\u001b[32m    180\u001b[39m         input_tools=chat_completion_tools,\n\u001b[32m    181\u001b[39m     )\n\u001b[32m--> \u001b[39m\u001b[32m183\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_post\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    184\u001b[39m \u001b[43m    \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/chat/completions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m    185\u001b[39m \u001b[43m    \u001b[49m\u001b[43mbody\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmaybe_transform\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    186\u001b[39m \u001b[43m        \u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m    187\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessages\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    188\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodel\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    189\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43maudio\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43maudio\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    190\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfrequency_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrequency_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    191\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunction_call\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunction_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    192\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunctions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunctions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    193\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogit_bias\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogit_bias\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    194\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    195\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_completion_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_completion_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    196\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    197\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmetadata\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    198\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodalities\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodalities\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    199\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mn\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    200\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mparallel_tool_calls\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mparallel_tool_calls\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    201\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mprediction\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprediction\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    202\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mpresence_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpresence_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    203\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mprompt_cache_key\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprompt_cache_key\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    204\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mreasoning_effort\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mreasoning_effort\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    205\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mresponse_format\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m_type_to_response_format\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresponse_format\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    206\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msafety_identifier\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43msafety_identifier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    207\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mseed\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mseed\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    208\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mservice_tier\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mservice_tier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    209\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstop\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    210\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstore\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstore\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    211\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m    212\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    213\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtemperature\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtemperature\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    214\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtool_choice\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtool_choice\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    215\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtools\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    216\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_logprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_logprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    217\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_p\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_p\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    218\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43muser\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43muser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    219\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mverbosity\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mverbosity\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    220\u001b[39m \u001b[43m            \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mweb_search_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mweb_search_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    221\u001b[39m \u001b[43m        \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    222\u001b[39m \u001b[43m        \u001b[49m\u001b[43mcompletion_create_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43mCompletionCreateParams\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    223\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    224\u001b[39m \u001b[43m    \u001b[49m\u001b[43moptions\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmake_request_options\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    225\u001b[39m \u001b[43m        \u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    226\u001b[39m \u001b[43m        \u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    227\u001b[39m \u001b[43m        \u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    228\u001b[39m \u001b[43m        \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    229\u001b[39m \u001b[43m        \u001b[49m\u001b[43mpost_parser\u001b[49m\u001b[43m=\u001b[49m\u001b[43mparser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    230\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    231\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;66;43;03m# we turn the `ChatCompletion` instance into a `ParsedChatCompletion`\u001b[39;49;00m\n\u001b[32m    232\u001b[39m \u001b[43m    \u001b[49m\u001b[38;5;66;43;03m# in the `parser` function above\u001b[39;49;00m\n\u001b[32m    233\u001b[39m \u001b[43m    \u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcast\u001b[49m\u001b[43m(\u001b[49m\u001b[43mType\u001b[49m\u001b[43m[\u001b[49m\u001b[43mParsedChatCompletion\u001b[49m\u001b[43m[\u001b[49m\u001b[43mResponseFormatT\u001b[49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mChatCompletion\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    234\u001b[39m \u001b[43m    \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m    235\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",1093      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\openai\\_base_client.py:1259\u001b[39m, in \u001b[36mSyncAPIClient.post\u001b[39m\u001b[34m(self, path, cast_to, body, options, files, stream, stream_cls)\u001b[39m\n\u001b[32m   1245\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mpost\u001b[39m(\n\u001b[32m   1246\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   1247\u001b[39m     path: \u001b[38;5;28mstr\u001b[39m,\n\u001b[32m   (...)\u001b[39m\u001b[32m   1254\u001b[39m     stream_cls: \u001b[38;5;28mtype\u001b[39m[_StreamT] | \u001b[38;5;28;01mNone\u001b[39;00m = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m   1255\u001b[39m ) -> ResponseT | _StreamT:\n\u001b[32m   1256\u001b[39m     opts = FinalRequestOptions.construct(\n\u001b[32m   1257\u001b[39m         method=\u001b[33m\"\u001b[39m\u001b[33mpost\u001b[39m\u001b[33m\"\u001b[39m, url=path, json_data=body, files=to_httpx_files(files), **options\n\u001b[32m   1258\u001b[39m     )\n\u001b[32m-> \u001b[39m\u001b[32m1259\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m cast(ResponseT, \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopts\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m)\u001b[49m)\n",1094      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\openai\\_base_client.py:982\u001b[39m, in \u001b[36mSyncAPIClient.request\u001b[39m\u001b[34m(self, cast_to, options, stream, stream_cls)\u001b[39m\n\u001b[32m    980\u001b[39m response = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m    981\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m982\u001b[39m     response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_client\u001b[49m\u001b[43m.\u001b[49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    983\u001b[39m \u001b[43m        \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    984\u001b[39m \u001b[43m        \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_should_stream_response_body\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    985\u001b[39m \u001b[43m        \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    986\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    987\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m httpx.TimeoutException \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[32m    988\u001b[39m     log.debug(\u001b[33m\"\u001b[39m\u001b[33mEncountered httpx.TimeoutException\u001b[39m\u001b[33m\"\u001b[39m, exc_info=\u001b[38;5;28;01mTrue\u001b[39;00m)\n",1095      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpx\\_client.py:914\u001b[39m, in \u001b[36mClient.send\u001b[39m\u001b[34m(self, request, stream, auth, follow_redirects)\u001b[39m\n\u001b[32m    910\u001b[39m \u001b[38;5;28mself\u001b[39m._set_timeout(request)\n\u001b[32m    912\u001b[39m auth = \u001b[38;5;28mself\u001b[39m._build_request_auth(request, auth)\n\u001b[32m--> \u001b[39m\u001b[32m914\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_handling_auth\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    915\u001b[39m \u001b[43m    \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    916\u001b[39m \u001b[43m    \u001b[49m\u001b[43mauth\u001b[49m\u001b[43m=\u001b[49m\u001b[43mauth\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    917\u001b[39m \u001b[43m    \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    918\u001b[39m \u001b[43m    \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m=\u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    919\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    920\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    921\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m stream:\n",1096      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpx\\_client.py:942\u001b[39m, in \u001b[36mClient._send_handling_auth\u001b[39m\u001b[34m(self, request, auth, follow_redirects, history)\u001b[39m\n\u001b[32m    939\u001b[39m request = \u001b[38;5;28mnext\u001b[39m(auth_flow)\n\u001b[32m    941\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m942\u001b[39m     response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_handling_redirects\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    943\u001b[39m \u001b[43m        \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    944\u001b[39m \u001b[43m        \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    945\u001b[39m \u001b[43m        \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m=\u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m    946\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    947\u001b[39m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    948\u001b[39m         \u001b[38;5;28;01mtry\u001b[39;00m:\n",1097      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpx\\_client.py:979\u001b[39m, in \u001b[36mClient._send_handling_redirects\u001b[39m\u001b[34m(self, request, follow_redirects, history)\u001b[39m\n\u001b[32m    976\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m._event_hooks[\u001b[33m\"\u001b[39m\u001b[33mrequest\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m    977\u001b[39m     hook(request)\n\u001b[32m--> \u001b[39m\u001b[32m979\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_single_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    980\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    981\u001b[39m     \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m._event_hooks[\u001b[33m\"\u001b[39m\u001b[33mresponse\u001b[39m\u001b[33m\"\u001b[39m]:\n",1098      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpx\\_client.py:1014\u001b[39m, in \u001b[36mClient._send_single_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m   1009\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[32m   1010\u001b[39m         \u001b[33m\"\u001b[39m\u001b[33mAttempted to send an async request with a sync Client instance.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m   1011\u001b[39m     )\n\u001b[32m   1013\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=request):\n\u001b[32m-> \u001b[39m\u001b[32m1014\u001b[39m     response = \u001b[43mtransport\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1016\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response.stream, SyncByteStream)\n\u001b[32m   1018\u001b[39m response.request = request\n",1099      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpx\\_transports\\default.py:250\u001b[39m, in \u001b[36mHTTPTransport.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    237\u001b[39m req = httpcore.Request(\n\u001b[32m    238\u001b[39m     method=request.method,\n\u001b[32m    239\u001b[39m     url=httpcore.URL(\n\u001b[32m   (...)\u001b[39m\u001b[32m    247\u001b[39m     extensions=request.extensions,\n\u001b[32m    248\u001b[39m )\n\u001b[32m    249\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[32m--> \u001b[39m\u001b[32m250\u001b[39m     resp = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_pool\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreq\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    252\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(resp.stream, typing.Iterable)\n\u001b[32m    254\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m Response(\n\u001b[32m    255\u001b[39m     status_code=resp.status,\n\u001b[32m    256\u001b[39m     headers=resp.headers,\n\u001b[32m    257\u001b[39m     stream=ResponseStream(resp.stream),\n\u001b[32m    258\u001b[39m     extensions=resp.extensions,\n\u001b[32m    259\u001b[39m )\n",1100      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\connection_pool.py:256\u001b[39m, in \u001b[36mConnectionPool.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    253\u001b[39m         closing = \u001b[38;5;28mself\u001b[39m._assign_requests_to_connections()\n\u001b[32m    255\u001b[39m     \u001b[38;5;28mself\u001b[39m._close_connections(closing)\n\u001b[32m--> \u001b[39m\u001b[32m256\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m exc \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m    258\u001b[39m \u001b[38;5;66;03m# Return the response. Note that in this case we still have to manage\u001b[39;00m\n\u001b[32m    259\u001b[39m \u001b[38;5;66;03m# the point at which the response is closed.\u001b[39;00m\n\u001b[32m    260\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response.stream, typing.Iterable)\n",1101      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\connection_pool.py:236\u001b[39m, in \u001b[36mConnectionPool.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    232\u001b[39m connection = pool_request.wait_for_connection(timeout=timeout)\n\u001b[32m    234\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m    235\u001b[39m     \u001b[38;5;66;03m# Send the request on the assigned connection.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m236\u001b[39m     response = \u001b[43mconnection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    237\u001b[39m \u001b[43m        \u001b[49m\u001b[43mpool_request\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrequest\u001b[49m\n\u001b[32m    238\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    239\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m ConnectionNotAvailable:\n\u001b[32m    240\u001b[39m     \u001b[38;5;66;03m# In some cases a connection may initially be available to\u001b[39;00m\n\u001b[32m    241\u001b[39m     \u001b[38;5;66;03m# handle a request, but then become unavailable.\u001b[39;00m\n\u001b[32m    242\u001b[39m     \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m    243\u001b[39m     \u001b[38;5;66;03m# In this case we clear the connection and try again.\u001b[39;00m\n\u001b[32m    244\u001b[39m     pool_request.clear_connection()\n",1102      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\connection.py:103\u001b[39m, in \u001b[36mHTTPConnection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    100\u001b[39m     \u001b[38;5;28mself\u001b[39m._connect_failed = \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[32m    101\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m exc\n\u001b[32m--> \u001b[39m\u001b[32m103\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n",1103      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\http11.py:136\u001b[39m, in \u001b[36mHTTP11Connection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    134\u001b[39m     \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[33m\"\u001b[39m\u001b[33mresponse_closed\u001b[39m\u001b[33m\"\u001b[39m, logger, request) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[32m    135\u001b[39m         \u001b[38;5;28mself\u001b[39m._response_closed()\n\u001b[32m--> \u001b[39m\u001b[32m136\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc\n",1104      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\http11.py:106\u001b[39m, in \u001b[36mHTTP11Connection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m     95\u001b[39m     \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[32m     97\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\n\u001b[32m     98\u001b[39m     \u001b[33m\"\u001b[39m\u001b[33mreceive_response_headers\u001b[39m\u001b[33m\"\u001b[39m, logger, request, kwargs\n\u001b[32m     99\u001b[39m ) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[32m    100\u001b[39m     (\n\u001b[32m    101\u001b[39m         http_version,\n\u001b[32m    102\u001b[39m         status,\n\u001b[32m    103\u001b[39m         reason_phrase,\n\u001b[32m    104\u001b[39m         headers,\n\u001b[32m    105\u001b[39m         trailing_data,\n\u001b[32m--> \u001b[39m\u001b[32m106\u001b[39m     ) = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_response_headers\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    107\u001b[39m     trace.return_value = (\n\u001b[32m    108\u001b[39m         http_version,\n\u001b[32m    109\u001b[39m         status,\n\u001b[32m    110\u001b[39m         reason_phrase,\n\u001b[32m    111\u001b[39m         headers,\n\u001b[32m    112\u001b[39m     )\n\u001b[32m    114\u001b[39m network_stream = \u001b[38;5;28mself\u001b[39m._network_stream\n",1105      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\http11.py:177\u001b[39m, in \u001b[36mHTTP11Connection._receive_response_headers\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m    174\u001b[39m timeout = timeouts.get(\u001b[33m\"\u001b[39m\u001b[33mread\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m    176\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m177\u001b[39m     event = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_event\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    178\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(event, h11.Response):\n\u001b[32m    179\u001b[39m         \u001b[38;5;28;01mbreak\u001b[39;00m\n",1106      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_sync\\http11.py:217\u001b[39m, in \u001b[36mHTTP11Connection._receive_event\u001b[39m\u001b[34m(self, timeout)\u001b[39m\n\u001b[32m    214\u001b[39m     event = \u001b[38;5;28mself\u001b[39m._h11_state.next_event()\n\u001b[32m    216\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m event \u001b[38;5;129;01mis\u001b[39;00m h11.NEED_DATA:\n\u001b[32m--> \u001b[39m\u001b[32m217\u001b[39m     data = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_network_stream\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m    218\u001b[39m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mREAD_NUM_BYTES\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m    219\u001b[39m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    221\u001b[39m     \u001b[38;5;66;03m# If we feed this case through h11 we'll raise an exception like:\u001b[39;00m\n\u001b[32m    222\u001b[39m     \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m    223\u001b[39m     \u001b[38;5;66;03m#     httpcore.RemoteProtocolError: can't handle event type\u001b[39;00m\n\u001b[32m   (...)\u001b[39m\u001b[32m    227\u001b[39m     \u001b[38;5;66;03m# perspective. Instead we handle this case distinctly and treat\u001b[39;00m\n\u001b[32m    228\u001b[39m     \u001b[38;5;66;03m# it as a ConnectError.\u001b[39;00m\n\u001b[32m    229\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m data == \u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m._h11_state.their_state == h11.SEND_RESPONSE:\n",1107      "\u001b[36mFile \u001b[39m\u001b[32md:\\REGNUM_SPECTRARUM\\.venv\\Lib\\site-packages\\httpcore\\_backends\\sync.py:128\u001b[39m, in \u001b[36mSyncStream.read\u001b[39m\u001b[34m(self, max_bytes, timeout)\u001b[39m\n\u001b[32m    126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[32m    127\u001b[39m     \u001b[38;5;28mself\u001b[39m._sock.settimeout(timeout)\n\u001b[32m--> \u001b[39m\u001b[32m128\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sock\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrecv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmax_bytes\u001b[49m\u001b[43m)\u001b[49m\n",1108      "\u001b[36mFile \u001b[39m\u001b[32mD:\\Anaconda\\Lib\\ssl.py:1296\u001b[39m, in \u001b[36mSSLSocket.recv\u001b[39m\u001b[34m(self, buflen, flags)\u001b[39m\n\u001b[32m   1292\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m flags != \u001b[32m0\u001b[39m:\n\u001b[32m   1293\u001b[39m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m   1294\u001b[39m             \u001b[33m\"\u001b[39m\u001b[33mnon-zero flags not allowed in calls to recv() on \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[33m\"\u001b[39m %\n\u001b[32m   1295\u001b[39m             \u001b[38;5;28mself\u001b[39m.\u001b[34m__class__\u001b[39m)\n\u001b[32m-> \u001b[39m\u001b[32m1296\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbuflen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   1297\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m   1298\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28msuper\u001b[39m().recv(buflen, flags)\n",1109      "\u001b[36mFile \u001b[39m\u001b[32mD:\\Anaconda\\Lib\\ssl.py:1169\u001b[39m, in \u001b[36mSSLSocket.read\u001b[39m\u001b[34m(self, len, buffer)\u001b[39m\n\u001b[32m   1167\u001b[39m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._sslobj.read(\u001b[38;5;28mlen\u001b[39m, buffer)\n\u001b[32m   1168\u001b[39m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1169\u001b[39m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sslobj\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m   1170\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m SSLError \u001b[38;5;28;01mas\u001b[39;00m x:\n\u001b[32m   1171\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m x.args[\u001b[32m0\u001b[39m] == SSL_ERROR_EOF \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m.suppress_ragged_eofs:\n",1110      "\u001b[31mKeyboardInterrupt\u001b[39m: "1111     ]1112    }1113   ],1114   "source": [1115    "workflow = system.invoke({\"query\" : \"How many cumulative milliliters of fluid is in all the opaque-capped vials without stickers in the 114 version of the kit that was used for the PromethION long-read sequencing in the paper De Novo-Whole Genome Assembly of the Roborovski Dwarf Hamster (Phodopus roborovskii) Genome?\", \"current_step\": 0, \"reasoning_done\": False, \"files\" : [], \"files_contents\" : {}, \"iteration_count\" : 0, \"max_iterations\" : 10, \"plan\" : None} , config = config)"1116   ]1117  },1118  {1119   "cell_type": "code",1120   "execution_count": null,1121   "metadata": {},1122   "outputs": [1123    {1124     "name": "stdout",1125     "output_type": "stream",1126     "text": [1127      "================================\u001b[1m System Message \u001b[0m================================\n",1128      "\n",1129      "You are a COMPLEXITY ASSESSOR for a multi-tool agent system.\n",1130      "Your job is to analyze user queries and determine their complexity level and processing requirements.\n",1131      "\n",1132      "COMPLEXITY LEVELS:\n",1133      "1. SIMPLE: Direct questions that can be answered immediately without tools or with single tool use\n",1134      "   - Examples: \"What is 2+2?\", \"Define photosynthesis\", \"What's the capital of France?\"\n",1135      "\n",1136      "2. MODERATE: Questions requiring 1-3 tool calls or basic analysis\n",1137      "   - Examples: \"Search for recent news about AI\", \"Analyze this CSV file\", \"What's the weather tomorrow?\"\n",1138      "\n",1139      "3. COMPLEX: Multi-step problems requiring planning, multiple tools, or sophisticated reasoning\n",1140      "   - Examples: Research tasks, multi-file analysis, calculations with dependencies, creative projects\n",1141      "\n",1142      "ASSESSMENT CRITERIA:\n",1143      "- Number of steps likely needed\n",1144      "- Tool complexity and dependencies\n",1145      "- Data processing requirements\n",1146      "- Need for intermediate reasoning\n",1147      "- Risk of failure without proper planning\n",1148      "\n",1149      "RULES:\n",1150      "- SIMPLE queries bypass planning entirely\n",1151      "- MODERATE queries may use lightweight planning\n",1152      "- COMPLEX queries require full planning with fallbacks\n",1153      "- When in doubt, err toward higher complexity\n",1154      "\n",1155      "Analyze the query and respond with your assessment.\n",1156      "================================\u001b[1m Human Message \u001b[0m=================================\n",1157      "\n",1158      "Query: How many cumulative milliliters of fluid is in all the opaque-capped vials without stickers in the 114 version of the kit that was used for the PromethION long-read sequencing in the paper De Novo-Whole Genome Assembly of the Roborovski Dwarf Hamster (Phodopus roborovskii) Genome?\n",1159      "================================\u001b[1m System Message \u001b[0m================================\n",1160      "\n",1161      "You are the PLANNER of a multi-tool agent (GAIA I–II level). \n",1162      "Your job is to produce a minimal, reliable, reproducible plan to solve the user’s request using available tools.\n",1163      "You DO NOT call tools yourself; you only output a plan. The executor will run the plan.\n",1164      "Tools are already bound to the model via .bind_tools(), so use EXACT tool names.\n",1165      "\n",1166      "Principles\n",1167      "- Goal: a correct, verifiable answer (with citations/artifacts where appropriate).\n",1168      "- Minimality: use as few steps/tool calls as possible.\n",1169      "- Proper routing: pick the right branch: info | calc | table | doc_qa | image_qa | multi_hop.\n",1170      "- Files first: never send raw files to the code interpreter. First extract with specialized tools (CSV/XLSX/PDF/DOCX/TXT/IMG). \n",1171      "  Only then compute on the extracted data (if needed) with the safe code interpreter.\n",1172      "- Units & rounding: be explicit about units and rounding rules when numbers are involved.\n",1173      "- Evidence: require sources (URL/page/figure caption) for external facts.\n",1174      "- Fallbacks: define success criteria per step and a failure policy (“replan”, “stop”, or jump to another step-id).\n",1175      "- Cost aware: start with cheap preview/metadata tools before heavy steps.\n",1176      "\n",1177      "\n",1178      "Patterns / Routing\n",1179      "- info/web: web_search/wiki_search/arxiv_search → gather citations.\n",1180      "- calc: ensure data is available → safe_code_run only on extracted data; request plots/dataframes only if needed.\n",1181      "- table (CSV/XLSX): analyze_* to confirm columns/shape → aggregate via safe_code_run (or SQL tool if available).\n",1182      "- doc_qa (PDF/DOCX/TXT): analyze_* for pages/preview → extract_text or OCR if needed → answer with page/quote.\n",1183      "- image_qa: analyze_image_* for metadata/OCR, or vision_qa_* for visual questions; for chart numbers, convert figure→table and verify with computation.\n",1184      "- multi_hop: decompose into sub-queries, retrieve per modality, then synthesize with citations.\n",1185      "\n",1186      "Output format\n",1187      "Return ONLY a single JSON object following this schema:\n",1188      "{\n",1189      "  \"task_type\": \"info | calc | table | doc_qa | image_qa | multi_hop\",\n",1190      "  \"assumptions\": [\"string\", \"...\"],\n",1191      "  \"plan_rationale\": \"why this route and which tools are needed\",\n",1192      "  \"steps\": [\n",1193      "    {\n",1194      "      \"id\": \"s1\",\n",1195      "      \"description\": \"what and why\",\n",1196      "      \"evidence_needed\": [\"citations|page_numbers|figure_captions|stats_check|unit_check\"],\n",1197      "      \"success_criteria\": \"how we know the step succeeded\",\n",1198      "      \"on_fail\": \"replan | stop | sN\",\n",1199      "      \"outputs_to_state\": [\"what we expect to store for later steps\"]\n",1200      "    }\n",

Showing the first 1,200 of 1441 lines. Download the file for the rest.