fix: Deleted strategy Registry to register tools

This commit is contained in:
2026-02-16 10:43:25 -05:00
parent 00d7c111d5
commit 5d1e0d2984
4 changed files with 6 additions and 354 deletions

View File

@@ -1,9 +1,8 @@
from langgraph.graph import StateGraph, START, END
from langchain_core.messages import SystemMessage, ToolMessage, BaseMessage
from typing import Literal, Callable, Any, Union
from typing import Literal, Callable, Any
from .schemas import MessagesState
from dataclasses import dataclass
from ..tools.tool_registry import ToolRegistry, BaseTool
@dataclass
@@ -20,15 +19,14 @@ class Agent:
"""
Agente conversacional basado en LangGraph.
Soporta tools usando el patrón Registry para una gestión centralizada
y extensible de herramientas.
Soporta tools pasadas como lista de instancias.
"""
def __init__(
self,
model: Any,
config: AgentConfig | None = None,
tools: Union[list, ToolRegistry, None] = None
tools: list | None = None
):
"""
Inicializa el agente.
@@ -36,19 +34,15 @@ class Agent:
Args:
model: Modelo LLM a usar
config: Configuración del agente (AgentConfig)
tools: Lista de tools, ToolRegistry, o None
tools: Lista de instancias de herramientas o None
- Si es None: sin herramientas
- Si es list: lista de herramientas
- Si es ToolRegistry: se extrae la lista de herramientas
"""
self._model = model
self._config = config or AgentConfig()
# Normalizar tools: convertir ToolRegistry a lista si es necesario
if isinstance(tools, ToolRegistry):
self._tools = tools.get_all_tools()
else:
self._tools = tools or []
# Normalizar tools: usar la lista proporcionada o lista vacía
self._tools = tools or []
self._tools_by_name: dict[str, Any] = {
tool.name: tool for tool in self._tools