Add LCVectorStoreComponent to langflow components
This commit is contained in:
parent
c6b837380b
commit
257721f864
2 changed files with 27 additions and 0 deletions
27
src/backend/langflow/components/vectorstores/base/model.py
Normal file
27
src/backend/langflow/components/vectorstores/base/model.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from typing import List
|
||||
|
||||
from langchain_core.vectorstores import VectorStore
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import Text
|
||||
from langflow.schema import Record, docs_to_records
|
||||
|
||||
|
||||
class LCVectorStoreComponent(CustomComponent):
|
||||
|
||||
display_name: str = "LC Vector Store"
|
||||
description: str = "Search a LC Vector Store for similar documents."
|
||||
beta: bool = True
|
||||
|
||||
def search_with_vector_store(
|
||||
self, input_value: Text, search_type: str, vector_store: VectorStore
|
||||
) -> List[Record]:
|
||||
|
||||
docs = []
|
||||
if input_value and isinstance(input_value, str):
|
||||
docs = vector_store.search(
|
||||
query=input_value, search_type=search_type.lower()
|
||||
)
|
||||
else:
|
||||
raise ValueError("Invalid inputs provided.")
|
||||
return docs_to_records(docs)
|
||||
Loading…
Add table
Add a link
Reference in a new issue