38 lines
837 B
Python
38 lines
837 B
Python
from pathlib import Path
|
|
from typing import Annotated, Literal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class ConfigModel(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
# LLM
|
|
class CodexConfig(ConfigModel):
|
|
provider: Literal["codex"]
|
|
model: str = "gpt-5.6-luna"
|
|
|
|
credential_path: Path | None = None
|
|
|
|
|
|
class OpenAiConfig(ConfigModel):
|
|
provider: Literal["openai"]
|
|
model: str
|
|
|
|
api_key_env: str = "API_KEY"
|
|
base_url_env: str = "BASE_URL"
|
|
|
|
|
|
LLMConfig = Annotated[
|
|
CodexConfig | OpenAiConfig,
|
|
Field(discriminator="provider")
|
|
]
|
|
|
|
# Generation
|
|
class GenerationConfig(ConfigModel):
|
|
temperature: float | None = Field(default=None,
|
|
ge=.0,
|
|
le=2.0)
|
|
max_tokens: int = Field(default=4096,
|
|
gt=0)
|