chore: Updating Redis Vector Store parameters format
This commit is contained in:
parent
be9539f420
commit
9021974887
3 changed files with 35 additions and 52 deletions
|
|
@ -20,7 +20,7 @@ from langflow.schema import Data
|
|||
class PineconeVectorStoreComponent(LCVectorStoreComponent):
|
||||
display_name = "Pinecone"
|
||||
description = "Pinecone Vector Store with search capabilities"
|
||||
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/pinecone"
|
||||
documentation = "https://python.langchain.com/v0.2/docs/integrations/vectorstores/pinecone/"
|
||||
icon = "Pinecone"
|
||||
|
||||
inputs = [
|
||||
|
|
@ -34,7 +34,6 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent):
|
|||
advanced=True,
|
||||
),
|
||||
SecretStrInput(name="pinecone_api_key", display_name="Pinecone API Key", required=True),
|
||||
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
||||
StrInput(
|
||||
name="text_key",
|
||||
display_name="Text Key",
|
||||
|
|
@ -42,18 +41,13 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent):
|
|||
value="text",
|
||||
advanced=True,
|
||||
),
|
||||
MultilineInput(name="search_query", display_name="Search Query"),
|
||||
DataInput(
|
||||
name="vector_store_inputs",
|
||||
display_name="Vector Store Inputs",
|
||||
name="ingest_data",
|
||||
display_name="Ingest Data",
|
||||
is_list=True,
|
||||
),
|
||||
BoolInput(
|
||||
name="add_to_vector_store",
|
||||
display_name="Add to Vector Store",
|
||||
info="If true, the Vector Store Inputs will be added to the Vector Store.",
|
||||
value=True,
|
||||
),
|
||||
MultilineInput(name="search_input", display_name="Search Input"),
|
||||
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
||||
IntInput(
|
||||
name="number_of_results",
|
||||
display_name="Number of Results",
|
||||
|
|
@ -82,25 +76,24 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent):
|
|||
pinecone_api_key=self.pinecone_api_key,
|
||||
)
|
||||
|
||||
if self.add_to_vector_store:
|
||||
documents = []
|
||||
for _input in self.vector_store_inputs or []:
|
||||
if isinstance(_input, Data):
|
||||
documents.append(_input.to_lc_document())
|
||||
else:
|
||||
documents.append(_input)
|
||||
documents = []
|
||||
for _input in self.ingest_data or []:
|
||||
if isinstance(_input, Data):
|
||||
documents.append(_input.to_lc_document())
|
||||
else:
|
||||
documents.append(_input)
|
||||
|
||||
if documents:
|
||||
pinecone.add_documents(documents)
|
||||
if documents:
|
||||
pinecone.add_documents(documents)
|
||||
|
||||
return pinecone
|
||||
|
||||
def search_documents(self) -> List[Data]:
|
||||
vector_store = self._build_pinecone()
|
||||
|
||||
if self.search_input and isinstance(self.search_input, str) and self.search_input.strip():
|
||||
if self.search_query and isinstance(self.search_query, str) and self.search_query.strip():
|
||||
docs = vector_store.similarity_search(
|
||||
query=self.search_input,
|
||||
query=self.search_query,
|
||||
k=self.number_of_results,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from langflow.io import (
|
|||
DataInput,
|
||||
MultilineInput,
|
||||
)
|
||||
|
||||
from langflow.schema import Data
|
||||
|
||||
|
||||
|
|
@ -42,18 +43,13 @@ class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
|||
),
|
||||
StrInput(name="content_payload_key", display_name="Content Payload Key", value="page_content", advanced=True),
|
||||
StrInput(name="metadata_payload_key", display_name="Metadata Payload Key", value="metadata", advanced=True),
|
||||
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
||||
MultilineInput(name="search_query", display_name="Search Query"),
|
||||
DataInput(
|
||||
name="vector_store_inputs",
|
||||
display_name="Vector Store Inputs",
|
||||
name="ingest_data",
|
||||
display_name="Ingest Data",
|
||||
is_list=True,
|
||||
),
|
||||
BoolInput(
|
||||
name="add_to_vector_store",
|
||||
display_name="Add to Vector Store",
|
||||
info="If true, the Vector Store Inputs will be added to the Vector Store.",
|
||||
),
|
||||
MultilineInput(name="search_input", display_name="Search Input"),
|
||||
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
||||
IntInput(
|
||||
name="number_of_results",
|
||||
display_name="Number of Results",
|
||||
|
|
@ -85,23 +81,17 @@ class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
|||
"url": self.url,
|
||||
}
|
||||
|
||||
# Remove None values from server_kwargs
|
||||
server_kwargs = {k: v for k, v in server_kwargs.items() if v is not None}
|
||||
if self.add_to_vector_store:
|
||||
documents = []
|
||||
for _input in self.vector_store_inputs or []:
|
||||
if isinstance(_input, Data):
|
||||
documents.append(_input.to_lc_document())
|
||||
else:
|
||||
documents.append(_input)
|
||||
documents = []
|
||||
|
||||
if documents:
|
||||
qdrant = Qdrant.from_documents(documents, embedding=self.embedding, **qdrant_kwargs)
|
||||
for _input in self.ingest_data or []:
|
||||
if isinstance(_input, Data):
|
||||
documents.append(_input.to_lc_document())
|
||||
else:
|
||||
from qdrant_client import QdrantClient
|
||||
documents.append(_input)
|
||||
|
||||
client = QdrantClient(**server_kwargs)
|
||||
qdrant = Qdrant(embedding_function=self.embedding.embed_query, client=client, **qdrant_kwargs)
|
||||
if documents:
|
||||
qdrant = Qdrant.from_documents(documents, embedding=self.embedding, **qdrant_kwargs)
|
||||
else:
|
||||
from qdrant_client import QdrantClient
|
||||
|
||||
|
|
@ -113,9 +103,9 @@ class QdrantVectorStoreComponent(LCVectorStoreComponent):
|
|||
def search_documents(self) -> List[Data]:
|
||||
vector_store = self._build_qdrant()
|
||||
|
||||
if self.search_input and isinstance(self.search_input, str) and self.search_input.strip():
|
||||
if self.search_query and isinstance(self.search_query, str) and self.search_query.strip():
|
||||
docs = vector_store.similarity_search(
|
||||
query=self.search_input,
|
||||
query=self.search_query,
|
||||
k=self.number_of_results,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ class RedisVectorStoreComponent(LCVectorStoreComponent):
|
|||
name="schema",
|
||||
display_name="Schema",
|
||||
),
|
||||
MultilineInput(name="search_query", display_name="Search Query"),
|
||||
DataInput(
|
||||
name="vector_store_inputs",
|
||||
display_name="Vector Store Inputs",
|
||||
name="ingest_data",
|
||||
display_name="Ingest Data",
|
||||
is_list=True,
|
||||
),
|
||||
MultilineInput(name="search_input", display_name="Search Input"),
|
||||
IntInput(
|
||||
name="number_of_results",
|
||||
display_name="Number of Results",
|
||||
|
|
@ -48,7 +48,7 @@ class RedisVectorStoreComponent(LCVectorStoreComponent):
|
|||
def build_vector_store(self) -> Redis:
|
||||
documents = []
|
||||
|
||||
for _input in self.vector_store_inputs or []:
|
||||
for _input in self.ingest_data or []:
|
||||
if isinstance(_input, Data):
|
||||
documents.append(_input.to_lc_document())
|
||||
else:
|
||||
|
|
@ -80,9 +80,9 @@ class RedisVectorStoreComponent(LCVectorStoreComponent):
|
|||
def search_documents(self) -> List[Data]:
|
||||
vector_store = self.build_vector_store()
|
||||
|
||||
if self.search_input and isinstance(self.search_input, str) and self.search_input.strip():
|
||||
if self.search_query and isinstance(self.search_query, str) and self.search_query.strip():
|
||||
docs = vector_store.similarity_search(
|
||||
query=self.search_input,
|
||||
query=self.search_query,
|
||||
k=self.number_of_results,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue