From b7eab506724f19a04a17ab4c73766561ef7ce8cd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 21 Jun 2023 17:27:40 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(vectorstores.py):=20add=20s?= =?UTF-8?q?upport=20for=20Chroma=20vector=20store=20type=20=F0=9F=90=9B=20?= =?UTF-8?q?fix(vectorstores.py):=20add=20persist=20field=20to=20Weaviate?= =?UTF-8?q?=20vector=20store=20type=20The=20`VectorStoreFrontendNode`=20cl?= =?UTF-8?q?ass=20now=20supports=20the=20Chroma=20vector=20store=20type.=20?= =?UTF-8?q?A=20new=20boolean=20field=20`persist`=20has=20been=20added=20to?= =?UTF-8?q?=20the=20Chroma=20vector=20store=20type.=20The=20`add=5Fextra?= =?UTF-8?q?=5Ffields`=20method=20has=20been=20updated=20to=20add=20the=20`?= =?UTF-8?q?persist`=20field=20to=20the=20Chroma=20vector=20store=20type.?= =?UTF-8?q?=20The=20`format=5Ffield`=20method=20has=20been=20updated=20to?= =?UTF-8?q?=20include=20the=20`persist`=20field=20in=20the=20basic=20field?= =?UTF-8?q?s.=20Additionally,=20the=20`add=5Fextra=5Ffields`=20method=20ha?= =?UTF-8?q?s=20been=20updated=20to=20add=20the=20`weaviate=5Furl`=20field?= =?UTF-8?q?=20to=20the=20Weaviate=20vector=20store=20type.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/frontend_node/vectorstores.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/template/frontend_node/vectorstores.py b/src/backend/langflow/template/frontend_node/vectorstores.py index d04936a8b..0d6fb2467 100644 --- a/src/backend/langflow/template/frontend_node/vectorstores.py +++ b/src/backend/langflow/template/frontend_node/vectorstores.py @@ -6,6 +6,7 @@ from langflow.template.frontend_node.base import FrontendNode class VectorStoreFrontendNode(FrontendNode): def add_extra_fields(self) -> None: + extra_field = None if self.template.type_name == "Weaviate": extra_field = TemplateField( name="weaviate_url", @@ -18,6 +19,18 @@ class VectorStoreFrontendNode(FrontendNode): value="http://localhost:8080", ) + elif self.template.type_name == "Chroma": + # New bool field for persist parameter + extra_field = TemplateField( + name="persist", + field_type="bool", + required=False, + show=True, + advanced=False, + value=True, + display_name="Persist", + ) + if extra_field is not None: self.template.add_field(extra_field) def add_extra_base_classes(self) -> None: @@ -27,7 +40,14 @@ class VectorStoreFrontendNode(FrontendNode): def format_field(field: TemplateField, name: Optional[str] = None) -> None: FrontendNode.format_field(field, name) # Define common field attributes - basic_fields = ["work_dir", "collection_name", "api_key", "location"] + basic_fields = [ + "work_dir", + "collection_name", + "api_key", + "location", + "persist_directory", + "persist", + ] advanced_fields = [ "n_dim", "key", @@ -78,5 +98,3 @@ class VectorStoreFrontendNode(FrontendNode): field.advanced = True if "key" in field.name: field.password = False - # TODO: Weaviate requires weaviate_url to be passed as it is not part of - # the class or from_texts method. We need the add_extra_fields to fix this