From 935b85a218937699fc2d9bbc3f85f45cba2b3494 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 22 Jun 2023 19:59:23 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(vectorstores.py):=20add=20s?= =?UTF-8?q?upport=20for=20FAISS=20vector=20store=20type=20The=20FAISS=20ve?= =?UTF-8?q?ctor=20store=20type=20is=20now=20supported=20and=20can=20be=20c?= =?UTF-8?q?onfigured=20with=20the=20folder=5Fpath=20and=20index=5Fname=20f?= =?UTF-8?q?ields.=20The=20folder=5Fpath=20field=20specifies=20the=20local?= =?UTF-8?q?=20path=20to=20the=20FAISS=20index,=20while=20the=20index=5Fnam?= =?UTF-8?q?e=20field=20specifies=20the=20name=20of=20the=20index.=20Additi?= =?UTF-8?q?onally,=20a=20new=20client=5Fkwargs=20field=20has=20been=20adde?= =?UTF-8?q?d=20to=20support=20additional=20client=20configuration=20option?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/frontend_node/vectorstores.py | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/template/frontend_node/vectorstores.py b/src/backend/langflow/template/frontend_node/vectorstores.py index 5e25d3403..ce2c35434 100644 --- a/src/backend/langflow/template/frontend_node/vectorstores.py +++ b/src/backend/langflow/template/frontend_node/vectorstores.py @@ -18,7 +18,18 @@ class VectorStoreFrontendNode(FrontendNode): multiline=False, value="http://localhost:8080", ) - extra_fields.append(extra_field) + # Add client_kwargs field + extra_field2 = TemplateField( + name="client_kwargs", + field_type="code", + required=False, + placeholder="", + show=True, + advanced=True, + multiline=False, + value="{}", + ) + extra_fields.extend((extra_field, extra_field2)) elif self.template.type_name == "Chroma": # New bool field for persist parameter @@ -55,6 +66,29 @@ class VectorStoreFrontendNode(FrontendNode): value="", ) extra_fields.extend((extra_field, extra_field2)) + elif self.template.type_name == "FAISS": + extra_field = TemplateField( + name="folder_path", + field_type="str", + required=False, + placeholder="", + show=True, + advanced=True, + multiline=False, + display_name="Local Path", + value="", + ) + extra_field2 = TemplateField( + name="index_name", + field_type="str", + required=False, + show=True, + advanced=False, + value="", + display_name="Index Name", + ) + extra_fields.extend((extra_field, extra_field2)) + if extra_fields: for field in extra_fields: self.template.add_field(field) @@ -76,6 +110,7 @@ class VectorStoreFrontendNode(FrontendNode): "weaviate_url", "index_name", "namespace", + "folder_path", ] advanced_fields = [ "n_dim", @@ -94,6 +129,7 @@ class VectorStoreFrontendNode(FrontendNode): "grpc_port", "pinecone_api_key", "pinecone_env", + "client_kwargs", ] # Check and set field attributes