refactor: disable type-var error code (#2868)
* fix: disable error code "type-var" in mypy configuration * refactor(VertexAiModel.py): restructure the return statement to improve readability and maintainability by using type casting for LanguageModel
This commit is contained in:
parent
724f54067f
commit
decc979e99
3 changed files with 19 additions and 12 deletions
|
|
@ -192,6 +192,7 @@ line-length = 120
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
plugins = ["pydantic.mypy"]
|
plugins = ["pydantic.mypy"]
|
||||||
follow_imports = "silent"
|
follow_imports = "silent"
|
||||||
|
disable_error_code = ["type-var"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
from langflow.field_typing import LanguageModel
|
from langflow.field_typing import LanguageModel
|
||||||
from langflow.inputs import MessageTextInput
|
from langflow.inputs import MessageTextInput
|
||||||
|
|
@ -37,8 +39,8 @@ class ChatVertexAIComponent(LCModelComponent):
|
||||||
)
|
)
|
||||||
location = self.location or None
|
location = self.location or None
|
||||||
if self.credentials:
|
if self.credentials:
|
||||||
from google.oauth2 import service_account
|
|
||||||
from google.cloud import aiplatform
|
from google.cloud import aiplatform
|
||||||
|
from google.oauth2 import service_account
|
||||||
|
|
||||||
credentials = service_account.Credentials.from_service_account_file(self.credentials)
|
credentials = service_account.Credentials.from_service_account_file(self.credentials)
|
||||||
project = self.project or credentials.project_id
|
project = self.project or credentials.project_id
|
||||||
|
|
@ -52,15 +54,18 @@ class ChatVertexAIComponent(LCModelComponent):
|
||||||
project = self.project or None
|
project = self.project or None
|
||||||
credentials = None
|
credentials = None
|
||||||
|
|
||||||
return ChatVertexAI(
|
return cast(
|
||||||
credentials=credentials,
|
LanguageModel,
|
||||||
location=location,
|
ChatVertexAI(
|
||||||
project=project,
|
credentials=credentials,
|
||||||
max_output_tokens=self.max_output_tokens,
|
location=location,
|
||||||
max_retries=self.max_retries,
|
project=project,
|
||||||
model_name=self.model_name,
|
max_output_tokens=self.max_output_tokens,
|
||||||
temperature=self.temperature,
|
max_retries=self.max_retries,
|
||||||
top_k=self.top_k,
|
model_name=self.model_name,
|
||||||
top_p=self.top_p,
|
temperature=self.temperature,
|
||||||
verbose=self.verbose,
|
top_k=self.top_k,
|
||||||
|
top_p=self.top_p,
|
||||||
|
verbose=self.verbose,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ markers = ["async_test"]
|
||||||
namespace_packages = true
|
namespace_packages = true
|
||||||
mypy_path = "langflow"
|
mypy_path = "langflow"
|
||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
disable_error_code = ["type-var"]
|
||||||
|
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue