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:
parent
39027e3d5a
commit
728a86aab0
4 changed files with 45 additions and 2 deletions
|
|
@ -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",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
@ -49,7 +49,6 @@ test(
|
|||
await page.getByTestId("zoom_out").click();
|
||||
await page.getByTestId("zoom_out").click();
|
||||
|
||||
await page.getByTestId("input-inspection-retriever").first().click();
|
||||
await page.getByText("Retriever", { exact: true }).first().isHidden();
|
||||
await page.getByTestId("icon-ChevronDown").last().isVisible();
|
||||
await page.getByTestId("icon-ChevronDown").last().click();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,17 @@ test(
|
|||
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
let modelElement = await page.getByTestId("toolsRetrieverTool");
|
||||
await page.getByTestId("sidebar-options-trigger").click();
|
||||
await page
|
||||
.getByTestId("sidebar-legacy-switch")
|
||||
.isVisible({ timeout: 5000 });
|
||||
await page.getByTestId("sidebar-legacy-switch").click();
|
||||
await expect(page.getByTestId("sidebar-legacy-switch")).toBeChecked();
|
||||
await page.getByTestId("sidebar-options-trigger").click();
|
||||
|
||||
let modelElement = await page.getByTestId(
|
||||
"langchain_utilitiesRetrieverTool",
|
||||
);
|
||||
let targetElement = await page.locator('//*[@id="react-flow-id"]');
|
||||
await modelElement.dragTo(targetElement);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue