Skip to content

Commit

Permalink
add typing for provider_info and provider_default
Browse files Browse the repository at this point in the history
  • Loading branch information
pkelaita committed May 14, 2024
1 parent 646004d commit a6a1b38
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions l2m2/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@

from typing import Dict, Union
from typing_extensions import TypedDict, NotRequired, TypeVar, Generic, Literal
from enum import Enum
import sys


class ProviderEntry(TypedDict):
name: str
homepage: str


T = TypeVar("T")

Marker = Enum("Marker", {"PROVIDER_DEFAULT": "<<PROVIDER_DEFAULT>>"})
PROVIDER_DEFAULT: Marker = Marker.PROVIDER_DEFAULT


class Param(TypedDict, Generic[T]):
custom_key: NotRequired[str]
default: Union[T, str]
default: Union[T, Literal[Marker.PROVIDER_DEFAULT]]
max: T


Expand All @@ -19,21 +28,21 @@ class ModelParams(TypedDict):
max_tokens: Param[int]


ParamName = Literal[
"temperature",
"max_tokens",
]


class ModelEntry(TypedDict):
model_id: str
params: ModelParams


ParamName = Literal["temperature", "max_tokens"]


INF: int = sys.maxsize


PROVIDER_DEFAULT = "<<PROVIDER_DEFAULT>>"


PROVIDER_INFO = {
PROVIDER_INFO: Dict[str, ProviderEntry] = {
"openai": {
"name": "OpenAI",
"homepage": "https://openai.com/product",
Expand Down

0 comments on commit a6a1b38

Please sign in to comment.