Добавлены параметры конфигурации
This commit is contained in:
+31
-4
@@ -2,17 +2,21 @@ from pathlib import Path
|
||||
from typing import Annotated, Literal
|
||||
|
||||
import yaml
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class CodexConfig(BaseModel):
|
||||
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(BaseModel):
|
||||
class OpenAiConfig(ConfigModel):
|
||||
provider: Literal["openai"]
|
||||
model: str
|
||||
|
||||
@@ -25,11 +29,34 @@ LLMConfig = Annotated[
|
||||
Field(discriminator="provider")
|
||||
]
|
||||
|
||||
# Generation
|
||||
class GenerationConfig(ConfigModel):
|
||||
temperature: float = Field(default=.7,
|
||||
ge=.0,
|
||||
le=2.0)
|
||||
max_tokens: int = Field(default=4096,
|
||||
gt=0)
|
||||
|
||||
|
||||
class AppConfig(BaseModel):
|
||||
# Runtime
|
||||
class RuntimeConfig(ConfigModel):
|
||||
concurrency: int = Field(ge=1, default=1)
|
||||
|
||||
# Prompts
|
||||
class PromptsConfig(ConfigModel):
|
||||
instructions: str
|
||||
system: str
|
||||
user: str
|
||||
|
||||
# Application
|
||||
class AppConfig(ConfigModel):
|
||||
llm: LLMConfig
|
||||
generation: GenerationConfig = GenerationConfig()
|
||||
runtime: RuntimeConfig = RuntimeConfig()
|
||||
prompts: PromptsConfig
|
||||
|
||||
|
||||
# Loader
|
||||
def load_config(path: str | Path = "config.yaml") -> AppConfig:
|
||||
path = Path(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user