chore: Updating Upstash Vector Store parameters format
This commit is contained in:
parent
02c8251727
commit
23eaccd339
1 changed files with 27 additions and 40 deletions
|
|
@ -11,7 +11,7 @@ from langflow.schema import Data
|
||||||
class UpstashVectorStoreComponent(LCVectorStoreComponent):
|
class UpstashVectorStoreComponent(LCVectorStoreComponent):
|
||||||
display_name = "Upstash"
|
display_name = "Upstash"
|
||||||
description = "Upstash Vector Store with search capabilities"
|
description = "Upstash Vector Store with search capabilities"
|
||||||
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/upstash"
|
documentation = "https://python.langchain.com/v0.2/docs/integrations/vectorstores/upstash/"
|
||||||
icon = "Upstash"
|
icon = "Upstash"
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
|
@ -26,23 +26,18 @@ class UpstashVectorStoreComponent(LCVectorStoreComponent):
|
||||||
value="text",
|
value="text",
|
||||||
advanced=True,
|
advanced=True,
|
||||||
),
|
),
|
||||||
|
MultilineInput(name="search_query", display_name="Search Query"),
|
||||||
|
DataInput(
|
||||||
|
name="ingest_data",
|
||||||
|
display_name="Ingest Data",
|
||||||
|
is_list=True,
|
||||||
|
),
|
||||||
HandleInput(
|
HandleInput(
|
||||||
name="embedding",
|
name="embedding",
|
||||||
display_name="Embedding",
|
display_name="Embedding",
|
||||||
input_types=["Embeddings"],
|
input_types=["Embeddings"],
|
||||||
info="To use Upstash's embeddings, don't provide an embedding.",
|
info="To use Upstash's embeddings, don't provide an embedding.",
|
||||||
),
|
),
|
||||||
DataInput(
|
|
||||||
name="vector_store_inputs",
|
|
||||||
display_name="Vector Store Inputs",
|
|
||||||
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"),
|
|
||||||
IntInput(
|
IntInput(
|
||||||
name="number_of_results",
|
name="number_of_results",
|
||||||
display_name="Number of Results",
|
display_name="Number of Results",
|
||||||
|
|
@ -58,34 +53,26 @@ class UpstashVectorStoreComponent(LCVectorStoreComponent):
|
||||||
def _build_upstash(self) -> UpstashVectorStore:
|
def _build_upstash(self) -> UpstashVectorStore:
|
||||||
use_upstash_embedding = self.embedding is None
|
use_upstash_embedding = self.embedding is None
|
||||||
|
|
||||||
if self.add_to_vector_store:
|
documents = []
|
||||||
documents = []
|
for _input in self.ingest_data or []:
|
||||||
for _input in self.vector_store_inputs or []:
|
if isinstance(_input, Data):
|
||||||
if isinstance(_input, Data):
|
documents.append(_input.to_lc_document())
|
||||||
documents.append(_input.to_lc_document())
|
|
||||||
else:
|
|
||||||
documents.append(_input)
|
|
||||||
|
|
||||||
if documents:
|
|
||||||
if use_upstash_embedding:
|
|
||||||
upstash_vs = UpstashVectorStore(
|
|
||||||
embedding=use_upstash_embedding,
|
|
||||||
text_key=self.text_key,
|
|
||||||
index_url=self.index_url,
|
|
||||||
index_token=self.index_token,
|
|
||||||
)
|
|
||||||
upstash_vs.add_documents(documents)
|
|
||||||
else:
|
|
||||||
upstash_vs = UpstashVectorStore.from_documents(
|
|
||||||
documents=documents,
|
|
||||||
embedding=self.embedding,
|
|
||||||
text_key=self.text_key,
|
|
||||||
index_url=self.index_url,
|
|
||||||
index_token=self.index_token,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
|
documents.append(_input)
|
||||||
|
|
||||||
|
if documents:
|
||||||
|
if use_upstash_embedding:
|
||||||
upstash_vs = UpstashVectorStore(
|
upstash_vs = UpstashVectorStore(
|
||||||
embedding=self.embedding or use_upstash_embedding,
|
embedding=use_upstash_embedding,
|
||||||
|
text_key=self.text_key,
|
||||||
|
index_url=self.index_url,
|
||||||
|
index_token=self.index_token,
|
||||||
|
)
|
||||||
|
upstash_vs.add_documents(documents)
|
||||||
|
else:
|
||||||
|
upstash_vs = UpstashVectorStore.from_documents(
|
||||||
|
documents=documents,
|
||||||
|
embedding=self.embedding,
|
||||||
text_key=self.text_key,
|
text_key=self.text_key,
|
||||||
index_url=self.index_url,
|
index_url=self.index_url,
|
||||||
index_token=self.index_token,
|
index_token=self.index_token,
|
||||||
|
|
@ -103,9 +90,9 @@ class UpstashVectorStoreComponent(LCVectorStoreComponent):
|
||||||
def search_documents(self) -> List[Data]:
|
def search_documents(self) -> List[Data]:
|
||||||
vector_store = self._build_upstash()
|
vector_store = self._build_upstash()
|
||||||
|
|
||||||
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(
|
docs = vector_store.similarity_search(
|
||||||
query=self.search_input,
|
query=self.search_query,
|
||||||
k=self.number_of_results,
|
k=self.number_of_results,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue