From 4d72c92e4cb01bb46f4f4fc7a4c7df0cba03ae51 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 30 Jun 2023 09:00:18 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(llms.py):=20add=20extra=20?= =?UTF-8?q?fields=20for=20VertexAI=20template=20and=20modify=20field=20typ?= =?UTF-8?q?e=20for=20"credentials"=20=F0=9F=93=9D=20chore(llms.py):=20impr?= =?UTF-8?q?ove=20field=20configuration=20for=20VertexAI=20template=20and?= =?UTF-8?q?=20modify=20field=20type=20for=20"credentials"=20The=20`add=5Fe?= =?UTF-8?q?xtra=5Ffields`=20method=20is=20modified=20to=20add=20an=20addit?= =?UTF-8?q?ional=20field=20called=20"credentials"=20for=20the=20VertexAI?= =?UTF-8?q?=20template.=20The=20field=20is=20of=20type=20"file"=20and=20is?= =?UTF-8?q?=20required.=20It=20allows=20the=20user=20to=20upload=20a=20JSO?= =?UTF-8?q?N=20file=20as=20credentials.=20The=20`format=5Fopenai=5Ffield`?= =?UTF-8?q?=20method=20is=20also=20updated=20to=20handle=20the=20new=20"cr?= =?UTF-8?q?edentials"=20field.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/template/frontend_node/llms.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backend/langflow/template/frontend_node/llms.py b/src/backend/langflow/template/frontend_node/llms.py index 65bffc303..a1b1af3f3 100644 --- a/src/backend/langflow/template/frontend_node/llms.py +++ b/src/backend/langflow/template/frontend_node/llms.py @@ -6,6 +6,21 @@ from langflow.template.frontend_node.constants import OPENAI_API_BASE_INFO class LLMFrontendNode(FrontendNode): + def add_extra_fields(self) -> None: + if self.template.type_name == "VertexAI": + # Add credentials field which should of type file. + self.template.add_field( + TemplateField( + field_type="file", + required=True, + show=True, + name="credentials", + value="", + suffixes=[".json"], + fileTypes=["json"], + ) + ) + @staticmethod def format_openai_field(field: TemplateField): if "openai" in field.name.lower(): @@ -81,6 +96,9 @@ class LLMFrontendNode(FrontendNode): "model_file", "model_type", "deployment_name", + "credentials", ]: field.advanced = False field.show = True + if field.name == "credentials": + field.field_type = "file"