From a443d0aa835cd9e986c6745b2bce05a446443074 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 8 Jun 2023 18:14:03 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A8=20refactor(llms.py):=20extract?= =?UTF-8?q?=20formatting=20methods=20for=20Azure=20and=20Llama=20fields=20?= =?UTF-8?q?This=20commit=20extracts=20the=20formatting=20methods=20for=20A?= =?UTF-8?q?zure=20and=20Llama=20fields=20from=20the=20`format=5Ffield`=20m?= =?UTF-8?q?ethod=20to=20improve=20readability=20and=20maintainability=20of?= =?UTF-8?q?=20the=20code.=20The=20`format=5Fazure=5Ffield`=20method=20form?= =?UTF-8?q?ats=20the=20fields=20for=20Azure,=20while=20the=20`format=5Flla?= =?UTF-8?q?ma=5Ffield`=20method=20formats=20the=20fields=20for=20Llama.=20?= =?UTF-8?q?These=20methods=20are=20called=20conditionally=20based=20on=20t?= =?UTF-8?q?he=20name=20of=20the=20field.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/template/frontend_node/llms.py | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/template/frontend_node/llms.py b/src/backend/langflow/template/frontend_node/llms.py index e2602d2d6..ac17cf8ed 100644 --- a/src/backend/langflow/template/frontend_node/llms.py +++ b/src/backend/langflow/template/frontend_node/llms.py @@ -12,12 +12,34 @@ class LLMFrontendNode(FrontendNode): field.name.title().replace("Openai", "OpenAI").replace("_", " ") ).replace("Api", "API") + @staticmethod + def format_azure_field(field: TemplateField): + if field.name == "model_name": + field.show = False # Azure uses deployment_name instead of model_name. + elif field.name == "openai_api_type": + field.show = False + field.password = False + field.value = "azure" + elif field.name == "openai_api_version": + field.password = False + field.value = "2023-03-15-preview" + + @staticmethod + def format_llama_field(field: TemplateField): + field.show = True + field.advanced = not field.required + @staticmethod def format_field(field: TemplateField, name: Optional[str] = None) -> None: display_names_dict = { "huggingfacehub_api_token": "HuggingFace Hub API Token", } FrontendNode.format_field(field, name) + LLMFrontendNode.format_openai_field(field) + if name and "azure" in name.lower(): + LLMFrontendNode.format_azure_field(field) + if name and "llama" in name.lower(): + LLMFrontendNode.format_llama_field(field) SHOW_FIELDS = ["repo_id"] if field.name in SHOW_FIELDS: field.show = True @@ -44,8 +66,12 @@ class LLMFrontendNode(FrontendNode): field.field_type = "code" field.advanced = True field.show = True - elif field.name in ["model_name", "temperature", "model_file", "model_type"]: + elif field.name in [ + "model_name", + "temperature", + "model_file", + "model_type", + "deployment_name", + ]: field.advanced = False field.show = True - - LLMFrontendNode.format_openai_field(field) From 5484a082308eb24618f6a8329e6f95b5244bcee4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 8 Jun 2023 18:15:26 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):=20bum?= =?UTF-8?q?p=20up=20version=20to=200.0.88=20The=20version=20number=20in=20?= =?UTF-8?q?the=20pyproject.toml=20file=20has=20been=20updated=20from=200.0?= =?UTF-8?q?.87=20to=200.0.88.=20This=20is=20a=20chore=20commit=20as=20it?= =?UTF-8?q?=20does=20not=20introduce=20any=20new=20features=20or=20fix=20a?= =?UTF-8?q?ny=20bugs,=20but=20it=20is=20necessary=20to=20keep=20track=20of?= =?UTF-8?q?=20the=20package=20version.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 819ab724a..c3e8ca789 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.0.87" +version = "0.0.88" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [