вторая итерация
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
# executor.py
|
||||
from langchain.agents import AgentExecutor, create_tool_calling_agent
|
||||
from langchain_classic.agents import AgentExecutor
|
||||
from langchain.agents import create_agent
|
||||
from langchain_ollama import ChatOllama
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from config import LLM_HOST, MODEL_NAME
|
||||
|
||||
class ToolExecutor:
|
||||
from typing import List, Dict
|
||||
|
||||
class ExecutorAgent:
|
||||
def __init__(self, tools):
|
||||
self.tools = tools
|
||||
self.llm = llm or ChatOllama(
|
||||
self.llm = ChatOllama(
|
||||
model=MODEL_NAME,
|
||||
temperature=0.0
|
||||
temperature=0.0,
|
||||
base_url=LLM_HOST
|
||||
)
|
||||
self.agent = self._create_agent()
|
||||
|
||||
@@ -18,9 +23,15 @@ class ToolExecutor:
|
||||
("human", "{input}"),
|
||||
("placeholder", "{agent_scratchpad}")
|
||||
])
|
||||
agent = create_tool_calling_agent(self.llm, self.tools, prompt)
|
||||
agent = create_agent(self.llm, self.tools, prompt)
|
||||
return AgentExecutor(agent=agent, tools=self.tools, verbose=True)
|
||||
|
||||
"""Устаревший агент-исполнитель. Теперь используется DeveloperAgent напрямую."""
|
||||
|
||||
def __init__(self, tools=None):
|
||||
# Этот класс больше не используется, оставлен для обратной совместимости
|
||||
pass
|
||||
|
||||
def execute_plan(self, plan: List[Dict]) -> List[Dict]:
|
||||
results = []
|
||||
for step in plan:
|
||||
@@ -34,4 +45,6 @@ class ToolExecutor:
|
||||
"output": result["output"],
|
||||
"success": True # можно анализировать ошибки
|
||||
})
|
||||
return results
|
||||
return results
|
||||
"""Устаревший метод - теперь выполняется напрямую через DeveloperAgent"""
|
||||
raise NotImplementedError("Этот метод больше не используется. Используйте DeveloperAgent.develop() напрямую.")
|
||||
Reference in New Issue
Block a user