chore: Updating Vectara Vector Store parameters format
This commit is contained in:
parent
23eaccd339
commit
43a781b001
1 changed files with 20 additions and 26 deletions
|
|
@ -12,24 +12,19 @@ from langflow.schema import Data
|
|||
class VectaraVectorStoreComponent(LCVectorStoreComponent):
|
||||
display_name = "Vectara"
|
||||
description = "Vectara Vector Store with search capabilities"
|
||||
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/vectara"
|
||||
documentation = "https://python.langchain.com/v0.2/docs/integrations/vectorstores/vectara/"
|
||||
icon = "Vectara"
|
||||
|
||||
inputs = [
|
||||
StrInput(name="vectara_customer_id", display_name="Vectara Customer ID", required=True),
|
||||
StrInput(name="vectara_corpus_id", display_name="Vectara Corpus ID", required=True),
|
||||
SecretStrInput(name="vectara_api_key", display_name="Vectara API Key", required=True),
|
||||
MultilineInput(name="search_query", display_name="Search Query"),
|
||||
DataInput(
|
||||
name="vector_store_inputs",
|
||||
name="ingest_data",
|
||||
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(
|
||||
name="number_of_results",
|
||||
display_name="Number of Results",
|
||||
|
|
@ -45,23 +40,22 @@ class VectaraVectorStoreComponent(LCVectorStoreComponent):
|
|||
def _build_vectara(self) -> Vectara:
|
||||
source = "Langflow"
|
||||
|
||||
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:
|
||||
return Vectara.from_documents(
|
||||
documents=documents,
|
||||
embedding=FakeEmbeddings(size=768),
|
||||
vectara_customer_id=self.vectara_customer_id,
|
||||
vectara_corpus_id=self.vectara_corpus_id,
|
||||
vectara_api_key=self.vectara_api_key,
|
||||
source=source,
|
||||
)
|
||||
if documents:
|
||||
return Vectara.from_documents(
|
||||
documents=documents,
|
||||
embedding=FakeEmbeddings(size=768),
|
||||
vectara_customer_id=self.vectara_customer_id,
|
||||
vectara_corpus_id=self.vectara_corpus_id,
|
||||
vectara_api_key=self.vectara_api_key,
|
||||
source=source,
|
||||
)
|
||||
|
||||
return Vectara(
|
||||
vectara_customer_id=self.vectara_customer_id,
|
||||
|
|
@ -73,9 +67,9 @@ class VectaraVectorStoreComponent(LCVectorStoreComponent):
|
|||
def search_documents(self) -> List[Data]:
|
||||
vector_store = self._build_vectara()
|
||||
|
||||
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