mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2025-12-16 21:20:39 +03:00
add database and migration logic (#27)
* update chat_microservice * reformat logger_conf * add database * add service and repository logic * fix constants gpt base url * add models endpoints
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import Any
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import model_validator
|
||||
from pydantic_settings import BaseSettings
|
||||
from yarl import URL
|
||||
|
||||
from constants import API_PREFIX
|
||||
|
||||
@@ -52,6 +53,9 @@ class AppSettings(SentrySettings, BaseSettings):
|
||||
DOMAIN: str = "https://localhost"
|
||||
URL_PREFIX: str = ""
|
||||
|
||||
DB_FILE: Path = SHARED_DIR / "chat_gpt.db"
|
||||
DB_ECHO: bool = False
|
||||
|
||||
# ==== gpt settings ====
|
||||
GPT_MODEL: str = "gpt-3.5-turbo-stream-DeepAi"
|
||||
GPT_BASE_HOST: str = "http://chat_service:8858"
|
||||
@@ -91,6 +95,18 @@ class AppSettings(SentrySettings, BaseSettings):
|
||||
def bot_webhook_url(self) -> str:
|
||||
return "/".join([self.api_prefix, self.token_part])
|
||||
|
||||
@cached_property
|
||||
def db_url(self) -> URL:
|
||||
"""
|
||||
Assemble database URL from settings.
|
||||
|
||||
:return: database URL.
|
||||
"""
|
||||
return URL.build(
|
||||
scheme="sqlite+aiosqlite",
|
||||
path=f"///{self.DB_FILE}",
|
||||
)
|
||||
|
||||
class Config:
|
||||
case_sensitive = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user