From cd3088f28e60f64c6d115dee0c86ee1c3f4d9aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=9A=D1=83=D1=82?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= Date: Thu, 28 May 2026 17:05:49 +0000 Subject: [PATCH] overwrite main.py --- main.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 1c6834a..57d94f6 100644 --- a/main.py +++ b/main.py @@ -17,7 +17,7 @@ from __future__ import annotations import os from typing import List -from langgraph.graph import StateGraph, START, END +from langgraph.graph import StateGraph, END from langchain_core.messages import HumanMessage, SystemMessage from langchain_openai import ChatOpenAI from rich.console import Console @@ -40,10 +40,6 @@ llm = ChatOpenAI( # 2. Planning node – split task into steps # --------------------------------------------------------------------------- def planning(state: PlanningState) -> PlanningState: - """Ask the LLM to produce a numbered list of steps. - - The prompt forces JSON output for reliable parsing. - """ system = SystemMessage( content="You are a helpful assistant that splits a task into clear, actionable steps. Return a JSON array of strings under the key `plan`." ) @@ -52,7 +48,6 @@ def planning(state: PlanningState) -> PlanningState: response = llm.invoke([system, user]) text = response.content.strip() - # Try to parse JSON; if fails, fall back to simple split by lines. try: import json data = json.loads(text) @@ -63,7 +58,6 @@ def planning(state: PlanningState) -> PlanningState: line = line.strip() if not line: continue - # Remove leading numbers like "1. " or "- " if line[0].isdigit() and (len(line) > 2 and line[1] in ".-"): line = line.split("", 1)[1] plan.append(line) @@ -125,8 +119,8 @@ def run_agent(task: str) -> None: state: PlanningState = {"task": task, "plan": None, "current_step": 0, "results": []} config = {"configurable": {"thread_id": f"{task[:8]}"}} - for event in agent.stream(state, config): - pass # we only need final state + final_state = agent.invoke(state, config) + state = final_state console.print("\n[bold underline]Task:[/]", task) if state.get("plan"):