Skip to content

Commit

Permalink
Restoring validation functionality after #383 turns out to not work f…
Browse files Browse the repository at this point in the history
…or Python 3.11
  • Loading branch information
jamesbraza committed Sep 12, 2024
1 parent 57fb356 commit bd9bb7a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions paperqa/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections.abc import AsyncIterable, Awaitable, Callable, Iterable, Sequence
from enum import StrEnum
from inspect import signature
from sys import version_info
from typing import Any

import numpy as np
Expand Down Expand Up @@ -390,11 +391,13 @@ def maybe_set_config_attribute(cls, data: dict[str, Any]) -> dict[str, Any]:
"router_kwargs": {"num_retries": 3, "retry_after": 5},
}
# we only support one "model name" for now, here we validate
_DeploymentTypedDictValidator.validate_python(data["config"]["model_list"])
if (
"config" in data
and len({m["model_name"] for m in data["config"]["model_list"]}) > 1
):
model_list = data["config"]["model_list"]
if version_info >= (3, 12):
_DeploymentTypedDictValidator.validate_python(model_list)
elif not isinstance(model_list, list):
# Work around https://github.com/BerriAI/litellm/issues/5664
raise TypeError(f"model_list must be a list, not a {type(model_list)}.")
if "config" in data and len({m["model_name"] for m in model_list}) > 1:
raise ValueError("Only one model name per router is supported for now.")
return data

Expand Down

0 comments on commit bd9bb7a

Please sign in to comment.