remove retriever component and outputs (#4979)
* remove retriever component and outputs * [autofix.ci] apply automated fixes * ruff check fix * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: cristhianzl <cristhian.lousa@gmail.com> Co-authored-by: Eric Hare <ericrhare@gmail.com>
This commit is contained in:
parent
8e09cf3335
commit
53e00c8092
5 changed files with 1 additions and 59 deletions
|
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
|||
from loguru import logger
|
||||
|
||||
from langflow.custom import Component
|
||||
from langflow.field_typing import Retriever, Text, VectorStore
|
||||
from langflow.field_typing import Text, VectorStore
|
||||
from langflow.helpers.data import docs_to_data
|
||||
from langflow.io import Output
|
||||
from langflow.schema import Data
|
||||
|
|
@ -54,11 +54,6 @@ class LCVectorStoreComponent(Component):
|
|||
|
||||
trace_type = "retriever"
|
||||
outputs = [
|
||||
Output(
|
||||
display_name="Retriever",
|
||||
name="base_retriever",
|
||||
method="build_base_retriever",
|
||||
),
|
||||
Output(
|
||||
display_name="Search Results",
|
||||
name="search_results",
|
||||
|
|
@ -69,7 +64,6 @@ class LCVectorStoreComponent(Component):
|
|||
def _validate_outputs(self) -> None:
|
||||
# At least these three outputs must be defined
|
||||
required_output_methods = [
|
||||
"build_base_retriever",
|
||||
"search_documents",
|
||||
"build_vector_store",
|
||||
]
|
||||
|
|
@ -115,22 +109,6 @@ class LCVectorStoreComponent(Component):
|
|||
self.status = data
|
||||
return data
|
||||
|
||||
def build_base_retriever(self) -> Retriever: # type: ignore[type-var]
|
||||
"""Builds the BaseRetriever object."""
|
||||
if self._cached_vector_store is not None:
|
||||
vector_store = self._cached_vector_store
|
||||
else:
|
||||
vector_store = self.build_vector_store()
|
||||
self._cached_vector_store = vector_store
|
||||
|
||||
if hasattr(vector_store, "as_retriever"):
|
||||
retriever = vector_store.as_retriever(**self.get_retriever_kwargs())
|
||||
if self.status is None:
|
||||
self.status = "Retriever built successfully."
|
||||
return retriever
|
||||
msg = f"Vector Store {vector_store.__class__.__name__} does not have an as_retriever method."
|
||||
raise ValueError(msg)
|
||||
|
||||
def search_documents(self) -> list[Data]:
|
||||
"""Search for documents in the vector store."""
|
||||
search_query: str = self.search_query
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from .google_search_api import GoogleSearchAPIComponent
|
|||
from .google_serper_api import GoogleSerperAPIComponent
|
||||
from .python_code_structured_tool import PythonCodeStructuredTool
|
||||
from .python_repl import PythonREPLToolComponent
|
||||
from .retriever import RetrieverToolComponent
|
||||
from .search_api import SearchAPIComponent
|
||||
from .searxng import SearXNGToolComponent
|
||||
from .serp_api import SerpAPIComponent
|
||||
|
|
@ -39,7 +38,6 @@ __all__ = [
|
|||
"GoogleSerperAPIComponent",
|
||||
"PythonCodeStructuredTool",
|
||||
"PythonREPLToolComponent",
|
||||
"RetrieverToolComponent",
|
||||
"SearXNGToolComponent",
|
||||
"SearchAPIComponent",
|
||||
"SerpAPIComponent",
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
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"
|
||||
|
||||
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,
|
||||
)
|
||||
|
|
@ -55,9 +55,7 @@ async def test_base(astradb_client: AstraDB):
|
|||
),
|
||||
},
|
||||
)
|
||||
from langchain_core.vectorstores import VectorStoreRetriever
|
||||
|
||||
assert isinstance(results["base_retriever"], VectorStoreRetriever)
|
||||
assert results["vector_store"] is not None
|
||||
assert results["search_results"] == []
|
||||
assert astradb_client.collection(BASIC_COLLECTION)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ def ingestion_graph():
|
|||
api_endpoint="https://astra.example.com",
|
||||
token="token", # noqa: S106
|
||||
)
|
||||
vector_store.set_on_output(name="base_retriever", value="mock_retriever", cache=True)
|
||||
vector_store.set_on_output(name="search_results", value=[Data(text="This is a test file.")], cache=True)
|
||||
|
||||
return Graph(file_component, vector_store)
|
||||
|
|
@ -64,7 +63,6 @@ def rag_graph():
|
|||
],
|
||||
cache=True,
|
||||
)
|
||||
rag_vector_store.set_on_output(name="base_retriever", value="mock_retriever", cache=True)
|
||||
parse_data = ParseDataComponent(_id="parse-data-123")
|
||||
parse_data.set(data=rag_vector_store.search_documents)
|
||||
prompt_component = PromptComponent(_id="prompt-123")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue