From 1e52711cf43cc5cbc4e9eb035e070e1a05b31064 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Wed, 18 Dec 2024 17:57:37 -0300 Subject: [PATCH] refactor: simplify input_types in LCToolsAgentComponent (remove BaseTool and StructuredTool) (#5084) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔧 (agent.py): remove unnecessary input_types "BaseTool" and "StructuredTool" from the HandleInput class to simplify and clarify the code. * 🔧 (sql.py): remove "BaseTool" from input_types in HandleInput to simplify the code and enhance clarity. * 🔧 Refactor starter project JSON files to simplify inputTypes by removing "BaseTool" and "StructuredTool", retaining only "Tool" for clarity and consistency across multiple agent configurations. --------- Co-authored-by: Gabriel Luiz Freitas Almeida --- .../base/langflow/base/agents/agent.py | 2 +- .../components/langchain_utilities/sql.py | 2 +- .../Instagram Copywriter.json | 10 ++----- .../starter_projects/Market Research.json | 10 ++----- .../starter_projects/Research Agent.json | 10 ++----- .../starter_projects/SaaS Pricing.json | 10 ++----- .../Sequential Tasks Agents .json | 30 ++++++------------- .../starter_projects/Simple Agent.json | 16 ++++------ .../Travel Planning Agents.json | 30 ++++++------------- 9 files changed, 37 insertions(+), 83 deletions(-) diff --git a/src/backend/base/langflow/base/agents/agent.py b/src/backend/base/langflow/base/agents/agent.py index 0bceeaded..61cf3ef9f 100644 --- a/src/backend/base/langflow/base/agents/agent.py +++ b/src/backend/base/langflow/base/agents/agent.py @@ -200,7 +200,7 @@ class LCToolsAgentComponent(LCAgentComponent): HandleInput( name="tools", display_name="Tools", - input_types=["Tool", "BaseTool", "StructuredTool"], + input_types=["Tool"], is_list=True, required=False, info="These are the tools that the agent can use to help with tasks.", diff --git a/src/backend/base/langflow/components/langchain_utilities/sql.py b/src/backend/base/langflow/components/langchain_utilities/sql.py index e018dec62..06916e252 100644 --- a/src/backend/base/langflow/components/langchain_utilities/sql.py +++ b/src/backend/base/langflow/components/langchain_utilities/sql.py @@ -19,7 +19,7 @@ class SQLAgentComponent(LCAgentComponent): HandleInput( name="extra_tools", display_name="Extra Tools", - input_types=["Tool", "BaseTool"], + input_types=["Tool"], is_list=True, advanced=True, ), diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json b/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json index 57fb147ec..27fd77945 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json @@ -100,9 +100,7 @@ "fieldName": "tools", "id": "Agent-9Wf58", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -112,7 +110,7 @@ "source": "TavilyAISearch-AN1Hv", "sourceHandle": "{œdataTypeœ: œTavilyAISearchœ, œidœ: œTavilyAISearch-AN1Hvœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-9Wf58", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9Wf58œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9Wf58œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -2099,9 +2097,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json b/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json index 003e83723..cdea2d1cd 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Market Research.json @@ -101,9 +101,7 @@ "fieldName": "tools", "id": "Agent-QSS16", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -113,7 +111,7 @@ "source": "TavilyAISearch-ghguc", "sourceHandle": "{œdataTypeœ: œTavilyAISearchœ, œidœ: œTavilyAISearch-ghgucœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-QSS16", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-QSS16œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-QSS16œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -2343,9 +2341,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json b/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json index d07deb557..8557bbdbe 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json @@ -131,9 +131,7 @@ "fieldName": "tools", "id": "Agent-9E8IU", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -143,7 +141,7 @@ "source": "TavilyAISearch-rI4aD", "sourceHandle": "{œdataTypeœ: œTavilyAISearchœ, œidœ: œTavilyAISearch-rI4aDœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-9E8IU", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9E8IUœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-9E8IUœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -2590,9 +2588,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json b/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json index dd52f6388..2d260d156 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json @@ -17,9 +17,7 @@ "fieldName": "tools", "id": "Agent-5e01q", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -28,7 +26,7 @@ "source": "CalculatorTool-DF8xQ", "sourceHandle": "{œdataTypeœ: œCalculatorToolœ, œidœ: œCalculatorTool-DF8xQœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-5e01q", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-5e01qœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-5e01qœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -1164,9 +1162,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json b/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json index dc6413f74..354d7e9e7 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents .json @@ -98,9 +98,7 @@ "fieldName": "tools", "id": "Agent-rH74C", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -109,7 +107,7 @@ "source": "CalculatorTool-xo5ux", "sourceHandle": "{œdataTypeœ: œCalculatorToolœ, œidœ: œCalculatorTool-xo5uxœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-rH74C", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-rH74Cœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-rH74Cœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -127,9 +125,7 @@ "fieldName": "tools", "id": "Agent-vIPAK", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -138,7 +134,7 @@ "source": "YahooFinanceTool-YmOKx", "sourceHandle": "{œdataTypeœ: œYahooFinanceToolœ, œidœ: œYahooFinanceTool-YmOKxœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-vIPAK", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-vIPAKœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-vIPAKœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -238,9 +234,7 @@ "fieldName": "tools", "id": "Agent-uaR2o", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -249,7 +243,7 @@ "source": "TavilyAISearch-YfG8u", "sourceHandle": "{œdataTypeœ: œTavilyAISearchœ, œidœ: œTavilyAISearch-YfG8uœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-uaR2o", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-uaR2oœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-uaR2oœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -1113,9 +1107,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", @@ -1691,9 +1683,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", @@ -3584,9 +3574,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json b/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json index 7f0bf9520..0d95a4599 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json @@ -73,9 +73,7 @@ "fieldName": "tools", "id": "Agent-yGhD2", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -85,7 +83,7 @@ "source": "CalculatorTool-IfWT1", "sourceHandle": "{œdataTypeœ: œCalculatorToolœ, œidœ: œCalculatorTool-IfWT1œ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-yGhD2", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-yGhD2œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-yGhD2œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -103,9 +101,7 @@ "fieldName": "tools", "id": "Agent-yGhD2", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -115,7 +111,7 @@ "source": "URL-FOPyh", "sourceHandle": "{œdataTypeœ: œURLœ, œidœ: œURL-FOPyhœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-yGhD2", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-yGhD2œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-yGhD2œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" } ], "nodes": [ @@ -647,9 +643,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", diff --git a/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json b/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json index eddd9087c..b3c18f2d4 100644 --- a/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json +++ b/src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json @@ -98,9 +98,7 @@ "fieldName": "tools", "id": "Agent-uVWaZ", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -109,7 +107,7 @@ "source": "SearchAPI-zMZv7", "sourceHandle": "{œdataTypeœ: œSearchAPIœ, œidœ: œSearchAPI-zMZv7œ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-uVWaZ", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-uVWaZœ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-uVWaZœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -127,9 +125,7 @@ "fieldName": "tools", "id": "Agent-qPNh7", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -138,7 +134,7 @@ "source": "url_content_fetcher-p0SUP", "sourceHandle": "{œdataTypeœ: œurl_content_fetcherœ, œidœ: œurl_content_fetcher-p0SUPœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-qPNh7", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-qPNh7œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-qPNh7œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -156,9 +152,7 @@ "fieldName": "tools", "id": "Agent-LAoR7", "inputTypes": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "type": "other" } @@ -167,7 +161,7 @@ "source": "CalculatorTool-v71XZ", "sourceHandle": "{œdataTypeœ: œCalculatorToolœ, œidœ: œCalculatorTool-v71XZœ, œnameœ: œapi_build_toolœ, œoutput_typesœ: [œToolœ]}", "target": "Agent-LAoR7", - "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-LAoR7œ, œinputTypesœ: [œToolœ, œBaseToolœ, œStructuredToolœ], œtypeœ: œotherœ}" + "targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-LAoR7œ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}" }, { "animated": false, @@ -1742,9 +1736,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", @@ -2320,9 +2312,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools", @@ -2898,9 +2888,7 @@ "dynamic": false, "info": "These are the tools that the agent can use to help with tasks.", "input_types": [ - "Tool", - "BaseTool", - "StructuredTool" + "Tool" ], "list": true, "name": "tools",