mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2026-02-04 16:50:38 +03:00
add queue tests
This commit is contained in:
@@ -3,8 +3,19 @@ STAGE="runtests"
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
POSTGRES_HOST="postgres"
|
||||
POSTGRES_PORT="5432"
|
||||
POSTGRES_DB="relevancer"
|
||||
POSTGRES_USER="user"
|
||||
POSTGRES_PASSWORD="postgrespwd"
|
||||
USER="web"
|
||||
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="true"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT=1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD="true"
|
||||
DEBUG="true"
|
||||
|
||||
@@ -1 +1,21 @@
|
||||
STAGE="runtests"
|
||||
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
USER="web"
|
||||
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="true"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT=1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD="true"
|
||||
DEBUG="true"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
POSTGRES_HOST="postgres"
|
||||
POSTGRES_PORT="5432"
|
||||
POSTGRES_DB="relevancer"
|
||||
POSTGRES_USER="user"
|
||||
POSTGRES_PASSWORD="postgrespwd"
|
||||
@@ -8,7 +8,7 @@ USER="web"
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
WEBHOOK_HOST="https://mydomain.com"
|
||||
DOMAIN="https://mydomain.com"
|
||||
URL_PREFIX="/gpt"
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
|
||||
@@ -5,6 +5,8 @@ from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
from app.constants import API_PREFIX
|
||||
|
||||
BASE_DIR = Path(__file__).parent.parent
|
||||
SHARED_DIR = BASE_DIR.resolve().joinpath("shared")
|
||||
SHARED_DIR.mkdir(exist_ok=True)
|
||||
@@ -23,10 +25,10 @@ if environ.get("STAGE") == "runtests":
|
||||
load_dotenv(env_path, override=True)
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
class AppSettings(BaseSettings):
|
||||
"""Application settings."""
|
||||
|
||||
PROJECT_NAME: str = "healthcheck bot"
|
||||
PROJECT_NAME: str = "chat gpt bot"
|
||||
APP_HOST: str = "0.0.0.0"
|
||||
APP_PORT: int = 8000
|
||||
STAGE: str = "dev"
|
||||
@@ -35,7 +37,7 @@ class Settings(BaseSettings):
|
||||
TELEGRAM_API_TOKEN: str = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
# webhook settings
|
||||
START_WITH_WEBHOOK: bool = False
|
||||
WEBHOOK_HOST: str = "https://mydomain.com"
|
||||
DOMAIN: str = "https://localhost"
|
||||
URL_PREFIX: str = ""
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
@@ -43,13 +45,19 @@ class Settings(BaseSettings):
|
||||
# Enable uvicorn reloading
|
||||
RELOAD: bool = False
|
||||
|
||||
@cached_property
|
||||
def api_prefix(self) -> str:
|
||||
if self.URL_PREFIX:
|
||||
return "/" + "/".join([self.URL_PREFIX.strip("/"), API_PREFIX.strip("/")])
|
||||
return API_PREFIX
|
||||
|
||||
@cached_property
|
||||
def bot_webhook_url(self) -> str:
|
||||
return "/" + self.TELEGRAM_API_TOKEN
|
||||
return "/".join([self.api_prefix, self.TELEGRAM_API_TOKEN])
|
||||
|
||||
class Config:
|
||||
case_sensitive = True
|
||||
|
||||
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
def get_settings() -> AppSettings:
|
||||
return AppSettings()
|
||||
|
||||
Reference in New Issue
Block a user