fix: make agent work with new tool mode backend updates (#7314)
* update tools in agents * fix: update tool status check to default to True * refactor: rename to_toolkit method to _get_tools and remove deprecated code * [autofix.ci] apply automated fixes * fix: makes agent tool metadata be correctly generated * Update agent JSON files with new code for Agent component * Enhance Financial Agent JSON configuration with updated code for the Agent component, including improved memory handling, tool validation, and error logging for better robustness and async functionality. --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
7ff6b1ae34
commit
58b12b40e1
20 changed files with 23 additions and 48 deletions
|
|
@ -238,7 +238,7 @@ class LCToolsAgentComponent(LCAgentComponent):
|
|||
tools_names = ", ".join([tool.name for tool in self.tools])
|
||||
return tools_names
|
||||
|
||||
async def to_toolkit(self) -> list[Tool]:
|
||||
async def _get_tools(self) -> list[Tool]:
|
||||
component_toolkit = _get_component_toolkit()
|
||||
tools_names = self._build_tools_names()
|
||||
agent_description = self.get_tool_description()
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ class ComponentToolkit:
|
|||
if tag in metadata_dict:
|
||||
tool_metadata = metadata_dict[tag]
|
||||
# Only include tools with status=True
|
||||
if tool_metadata.get("status", False):
|
||||
if tool_metadata.get("status", True):
|
||||
tool.name = tool_metadata.get("name", tool.name)
|
||||
tool.description = tool_metadata.get("description", tool.description)
|
||||
if tool_metadata.get("commands"):
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ from langflow.base.models.model_utils import get_model_name
|
|||
from langflow.components.helpers import CurrentDateComponent
|
||||
from langflow.components.helpers.memory import MemoryComponent
|
||||
from langflow.components.langchain_utilities.tool_calling import ToolCallingAgentComponent
|
||||
from langflow.custom.custom_component.component import _get_component_toolkit
|
||||
from langflow.custom.utils import update_component_build_config
|
||||
from langflow.field_typing import Tool
|
||||
from langflow.io import BoolInput, DropdownInput, MultilineInput, Output
|
||||
from langflow.logging import logger
|
||||
from langflow.schema.dotdict import dotdict
|
||||
|
|
@ -270,16 +268,3 @@ class AgentComponent(ToolCallingAgentComponent):
|
|||
component_class, build_config, field_value, "model_name"
|
||||
)
|
||||
return dotdict({k: v.to_dict() if hasattr(v, "to_dict") else v for k, v in build_config.items()})
|
||||
|
||||
async def to_toolkit(self) -> list[Tool]:
|
||||
component_toolkit = _get_component_toolkit()
|
||||
tools_names = self._build_tools_names()
|
||||
agent_description = self.get_tool_description()
|
||||
# TODO: Agent Description Depreciated Feature to be removed
|
||||
description = f"{agent_description}{tools_names}"
|
||||
tools = component_toolkit(component=self).get_tools(
|
||||
tool_name=self.get_tool_name(), tool_description=description, callbacks=self.get_langchain_callbacks()
|
||||
)
|
||||
if hasattr(self, "tools_metadata"):
|
||||
tools = component_toolkit(component=self, metadata=self.tools_metadata).update_tools_metadata(tools=tools)
|
||||
return tools
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ from langchain.agents import create_tool_calling_agent
|
|||
from langchain_core.prompts import ChatPromptTemplate
|
||||
|
||||
from langflow.base.agents.agent import LCToolsAgentComponent
|
||||
from langflow.custom.custom_component.component import _get_component_toolkit
|
||||
from langflow.field_typing import Tool
|
||||
from langflow.inputs import MessageTextInput
|
||||
from langflow.inputs.inputs import DataInput, HandleInput
|
||||
from langflow.schema import Data
|
||||
|
|
@ -56,11 +54,3 @@ class ToolCallingAgentComponent(LCToolsAgentComponent):
|
|||
except NotImplementedError as e:
|
||||
message = f"{self.display_name} does not support tool calling. Please try using a compatible model."
|
||||
raise NotImplementedError(message) from e
|
||||
|
||||
async def to_toolkit(self) -> list[Tool]:
|
||||
component_toolkit = _get_component_toolkit()
|
||||
toolkit = component_toolkit(component=self)
|
||||
tools = toolkit.get_tools(callbacks=self.get_langchain_callbacks())
|
||||
if hasattr(self, "tools_metadata"):
|
||||
tools = toolkit.update_tools_metadata(tools=tools)
|
||||
return tools
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue