Skip to content

Commit

Permalink
fix: linting in model.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aleneum committed Dec 1, 2024
1 parent 507da9e commit 12b9cf5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gerd/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,20 @@ def validate_field(cls, data: Any) -> Any: # noqa: ANN401
and f"{env_name}_URL" in os.environ
and f"{env_name}_TYPE" in os.environ
):
# Check if the endpoint type is valid
# Since MyPy does not correctly infer the type of `os.environ`
# we need to use `type: ignore`
if os.environ[f"{env_name}_TYPE"] not in ["llama.cpp", "openai"]:
msg = f"Unknown endpoint type: {os.environ[f'{env_name}_TYPE']}"
raise ValueError(msg)
setattr(
data,
field,
ModelEndpoint(
url=os.environ[f"{env_name}_URL"],
type=os.environ[f"{env_name}_TYPE"],
type=os.environ[f"{env_name}_TYPE"], # type: ignore[arg-type]
key=(
SecretStr(os.environ.get(f"{env_name}_KEY"))
SecretStr(os.environ.get(f"{env_name}_KEY") or "")
if f"{env_name}_KEY" in os.environ
else None
),
Expand Down

0 comments on commit 12b9cf5

Please sign in to comment.