mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 11:00:47 +02:00
# Description of Changes Redesign the Python AI engine to be properly agentic and make use of `pydantic-ai` instead of `langchain` for correctness and ergonomics. This should be a good foundation for us to build our AI engine on going forwards.
27 lines
888 B
Python
27 lines
888 B
Python
from __future__ import annotations
|
|
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
ENGINE_ROOT = Path(__file__).resolve().parents[3]
|
|
ENV_FILE = ENGINE_ROOT / ".env"
|
|
|
|
|
|
class AppSettings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_file=ENV_FILE, extra="ignore", populate_by_name=True)
|
|
|
|
smart_model_name: str = Field(validation_alias="STIRLING_SMART_MODEL")
|
|
fast_model_name: str = Field(validation_alias="STIRLING_FAST_MODEL")
|
|
smart_model_max_tokens: int = Field(validation_alias="STIRLING_SMART_MODEL_MAX_TOKENS")
|
|
fast_model_max_tokens: int = Field(validation_alias="STIRLING_FAST_MODEL_MAX_TOKENS")
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def load_settings() -> AppSettings:
|
|
load_dotenv(ENV_FILE)
|
|
return AppSettings.model_validate({})
|