chore: Updating Courchbase Vector Store parameters format
This commit is contained in:
parent
49ca6c5bf1
commit
a97b5eee75
1 changed files with 27 additions and 39 deletions
|
|
@ -12,29 +12,26 @@ from langflow.schema import Data
|
||||||
class CouchbaseVectorStoreComponent(LCVectorStoreComponent):
|
class CouchbaseVectorStoreComponent(LCVectorStoreComponent):
|
||||||
display_name = "Couchbase"
|
display_name = "Couchbase"
|
||||||
description = "Couchbase Vector Store with search capabilities"
|
description = "Couchbase Vector Store with search capabilities"
|
||||||
documentation = "https://python.langchain.com/docs/modules/data_connection/vectorstores/integrations/couchbase"
|
documentation = "https://python.langchain.com/v0.1/docs/integrations/document_loaders/couchbase/"
|
||||||
icon = "Couchbase"
|
icon = "Couchbase"
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
StrInput(name="couchbase_connection_string", display_name="Couchbase Cluster connection string", required=True),
|
SecretStrInput(
|
||||||
|
name="couchbase_connection_string", display_name="Couchbase Cluster connection string", required=True
|
||||||
|
),
|
||||||
StrInput(name="couchbase_username", display_name="Couchbase username", required=True),
|
StrInput(name="couchbase_username", display_name="Couchbase username", required=True),
|
||||||
SecretStrInput(name="couchbase_password", display_name="Couchbase password", required=True),
|
SecretStrInput(name="couchbase_password", display_name="Couchbase password", required=True),
|
||||||
StrInput(name="bucket_name", display_name="Bucket Name", required=True),
|
StrInput(name="bucket_name", display_name="Bucket Name", required=True),
|
||||||
StrInput(name="scope_name", display_name="Scope Name", required=True),
|
StrInput(name="scope_name", display_name="Scope Name", required=True),
|
||||||
StrInput(name="collection_name", display_name="Collection Name", required=True),
|
StrInput(name="collection_name", display_name="Collection Name", required=True),
|
||||||
StrInput(name="index_name", display_name="Index Name", required=True),
|
StrInput(name="index_name", display_name="Index Name", required=True),
|
||||||
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
MultilineInput(name="search_query", display_name="Search Query"),
|
||||||
DataInput(
|
DataInput(
|
||||||
name="vector_store_inputs",
|
name="ingest_data",
|
||||||
display_name="Vector Store Inputs",
|
display_name="Ingest Data",
|
||||||
is_list=True,
|
is_list=True,
|
||||||
),
|
),
|
||||||
BoolInput(
|
HandleInput(name="embedding", display_name="Embedding", input_types=["Embeddings"]),
|
||||||
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",
|
||||||
|
|
@ -66,33 +63,24 @@ class CouchbaseVectorStoreComponent(LCVectorStoreComponent):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"Failed to connect to Couchbase: {e}")
|
raise ValueError(f"Failed to connect to Couchbase: {e}")
|
||||||
|
|
||||||
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:
|
|
||||||
couchbase_vs = CouchbaseVectorStore.from_documents(
|
|
||||||
documents=documents,
|
|
||||||
cluster=cluster,
|
|
||||||
bucket_name=self.bucket_name,
|
|
||||||
scope_name=self.scope_name,
|
|
||||||
collection_name=self.collection_name,
|
|
||||||
embedding=self.embedding,
|
|
||||||
index_name=self.index_name,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
couchbase_vs = CouchbaseVectorStore(
|
documents.append(_input)
|
||||||
cluster=cluster,
|
|
||||||
bucket_name=self.bucket_name,
|
if documents:
|
||||||
scope_name=self.scope_name,
|
couchbase_vs = CouchbaseVectorStore.from_documents(
|
||||||
collection_name=self.collection_name,
|
documents=documents,
|
||||||
embedding=self.embedding,
|
cluster=cluster,
|
||||||
index_name=self.index_name,
|
bucket_name=self.bucket_name,
|
||||||
)
|
scope_name=self.scope_name,
|
||||||
|
collection_name=self.collection_name,
|
||||||
|
embedding=self.embedding,
|
||||||
|
index_name=self.index_name,
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
couchbase_vs = CouchbaseVectorStore(
|
couchbase_vs = CouchbaseVectorStore(
|
||||||
cluster=cluster,
|
cluster=cluster,
|
||||||
|
|
@ -108,9 +96,9 @@ class CouchbaseVectorStoreComponent(LCVectorStoreComponent):
|
||||||
def search_documents(self) -> List[Data]:
|
def search_documents(self) -> List[Data]:
|
||||||
vector_store = self._build_couchbase()
|
vector_store = self._build_couchbase()
|
||||||
|
|
||||||
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