2023-08-14 11:37:20 +00:00
|
|
|
from enum import StrEnum
|
2023-08-24 17:01:34 +00:00
|
|
|
from pathlib import Path
|
2023-08-14 11:37:20 +00:00
|
|
|
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
|
|
|
|
|
|
class Model(StrEnum):
|
|
|
|
"""Model to use for the LLM Chat application."""
|
|
|
|
|
|
|
|
GPT3 = "gpt-3.5-turbo"
|
|
|
|
GPT4 = "gpt-4"
|
|
|
|
|
|
|
|
|
2023-08-19 14:58:54 +00:00
|
|
|
DEFAULT_MODEL = Model.GPT3
|
|
|
|
DEFAULT_TEMPERATURE = 0.7
|
|
|
|
|
|
|
|
|
2023-08-14 11:37:20 +00:00
|
|
|
class OpenAISettings(BaseSettings):
|
|
|
|
"""Settings for the LLM Chat application."""
|
|
|
|
|
2023-08-16 09:10:06 +00:00
|
|
|
api_key: str = ""
|
2023-08-19 14:58:54 +00:00
|
|
|
model: Model = DEFAULT_MODEL
|
|
|
|
temperature: float = DEFAULT_TEMPERATURE
|
2023-08-24 17:01:34 +00:00
|
|
|
history_dir: Path = Path().absolute() / ".history"
|
2023-08-14 11:37:20 +00:00
|
|
|
|
2023-08-16 09:10:06 +00:00
|
|
|
model_config: SettingsConfigDict = SettingsConfigDict( # type: ignore[misc]
|
2023-08-14 11:37:20 +00:00
|
|
|
env_file=".env",
|
|
|
|
env_file_encoding="utf-8",
|
|
|
|
env_prefix="OPENAI_",
|
|
|
|
frozen=True,
|
|
|
|
use_enum_values=True,
|
|
|
|
)
|