From 262e3bd3ccc876d321694e73df75eb41f38ce319 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Thu, 12 Dec 2024 09:08:04 -0300 Subject: [PATCH] fix: use SecretStr get_secret_value for LMStudio API key handling (#5200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 (lmstudiomodel.py): fix issue with accessing secret value in api_key variable to prevent potential errors * ♻️ (lmstudiomodel.py): refactor api_key assignment to simplify code and improve readability * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/backend/base/langflow/components/models/lmstudiomodel.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/backend/base/langflow/components/models/lmstudiomodel.py b/src/backend/base/langflow/components/models/lmstudiomodel.py index a61b51391..7c4bfdce0 100644 --- a/src/backend/base/langflow/components/models/lmstudiomodel.py +++ b/src/backend/base/langflow/components/models/lmstudiomodel.py @@ -3,7 +3,6 @@ from urllib.parse import urljoin import httpx from langchain_openai import ChatOpenAI -from pydantic.v1 import SecretStr from typing_extensions import override from langflow.base.models.model import LCModelComponent @@ -103,14 +102,12 @@ class LMStudioModelComponent(LCModelComponent): base_url = self.base_url or "http://localhost:1234/v1" seed = self.seed - api_key = SecretStr(lmstudio_api_key) if lmstudio_api_key else None - return ChatOpenAI( max_tokens=max_tokens or None, model_kwargs=model_kwargs, model=model_name, base_url=base_url, - api_key=api_key, + api_key=lmstudio_api_key, temperature=temperature if temperature is not None else 0.1, seed=seed, )