mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-07-28 05:00:38 +03:00
wip: implement websocket chat service with Pydantic models and session management
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, PostgresDsn, RedisDsn, computed_field
|
||||
from pydantic_core import MultiHostUrl
|
||||
@@ -13,6 +14,25 @@ class SMTPConfig(BaseModel):
|
||||
template_path: str = os.getenv("EMAIL_TEMPLATE_PATH", "templates")
|
||||
|
||||
|
||||
class ChatConfig(BaseModel):
|
||||
"""Configuration for the websocket chat service's model-client adapter.
|
||||
|
||||
``backend`` selects which :class:`~app.services.chat_agent.ChatAgent`
|
||||
implementation is built by
|
||||
:func:`~app.services.chat_agent.build_chat_agent` during app startup:
|
||||
|
||||
- ``"stub"``: a local, dependency-free echo agent (default, no network
|
||||
calls, ideal for local dev/tests).
|
||||
- ``"ollama"``: streams completions from an OpenAI-compatible endpoint
|
||||
(e.g. a local Ollama server), reusing the same adapter interface.
|
||||
"""
|
||||
|
||||
backend: Literal["stub", "ollama"] = os.getenv("CHAT_BACKEND", "stub")
|
||||
base_url: str = os.getenv("CHAT_BASE_URL", "http://localhost:11434/v1")
|
||||
model: str = os.getenv("CHAT_MODEL", "llama3.2")
|
||||
stream_delay_seconds: float = float(os.getenv("CHAT_STREAM_DELAY", "0.02"))
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env", env_ignore_empty=True, extra="ignore"
|
||||
@@ -21,6 +41,7 @@ class Settings(BaseSettings):
|
||||
jwt_expire: int = os.getenv("JWT_EXPIRE")
|
||||
|
||||
smtp: SMTPConfig = SMTPConfig()
|
||||
chat: ChatConfig = ChatConfig()
|
||||
|
||||
REDIS_HOST: str
|
||||
REDIS_PORT: int
|
||||
|
||||
Reference in New Issue
Block a user