refactor: Move RetrieverToolComponent to langchain_utilities and add legacy support (#5003)

* ✨ (langchain_utilities): add RetrieverToolComponent to langchain_utilities package
♻️ (tools): remove RetrieverToolComponent from tools package to avoid duplication and improve organization

* style: fix import block un-sorted

* 🔧 (twoEdges.spec.ts): remove unnecessary click on "input-inspection-retriever" element to improve test clarity and efficiency

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2024-12-03 15:21:26 -03:00 • committed by GitHub
commit 728a86aab0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 2 deletions

View file

@ -15,6 +15,7 @@ from .openai_tools import OpenAIToolsAgentComponent
from .openapi import OpenAPIAgentComponent
from .recursive_character import RecursiveCharacterTextSplitterComponent
from .retrieval_qa import RetrievalQAComponent
from .retriever import RetrieverToolComponent
from .runnable_executor import RunnableExecComponent
from .self_query import SelfQueryRetrieverComponent
from .spider import SpiderTool
@ -56,4 +57,5 @@ __all__ = [
"VectorStoreInfoComponent",
"VectorStoreRouterAgentComponent",
"XMLAgentComponent",
"RetrieverToolComponent",
]

View file

@ -0,0 +1,32 @@
from langchain_core.tools import create_retriever_tool
from langflow.custom import CustomComponent
from langflow.field_typing import BaseRetriever, Tool
class RetrieverToolComponent(CustomComponent):
display_name = "RetrieverTool"
description = "Tool for interacting with retriever"
name = "RetrieverTool"
legacy = True
icon = "LangChain"
def build_config(self):
return {
"retriever": {
"display_name": "Retriever",
"info": "Retriever to interact with",
"type": BaseRetriever,
"input_types": ["Retriever"],
},
"name": {"display_name": "Name", "info": "Name of the tool"},
"description": {"display_name": "Description", "info": "Description of the tool"},
}
def build(self, retriever: BaseRetriever, name: str, description: str, **kwargs) -> Tool:
_ = kwargs
return create_retriever_tool(
retriever=retriever,
name=name,
description=description,
)