mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2025-12-16 21:20:39 +03:00
add logging to file (#24)
This commit is contained in:
@@ -1,24 +1,20 @@
|
||||
STAGE="runtests"
|
||||
|
||||
# ==== start app settings ====
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
USER="web"
|
||||
TZ="Europe/Moscow"
|
||||
|
||||
# ==== telegram settings ====
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
GPT_BASE_HOST="http://localhost"
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="false"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT=1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD="true"
|
||||
DEBUG="true"
|
||||
# ==== domain settings ====
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
# ==== gpt settings ====
|
||||
GPT_BASE_HOST="http://localhost"
|
||||
|
||||
# ==== other settings ====
|
||||
USER="web"
|
||||
@@ -1,24 +1,20 @@
|
||||
STAGE="runtests"
|
||||
|
||||
# ==== start app settings ====
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
USER="web"
|
||||
TZ="Europe/Moscow"
|
||||
|
||||
# ==== telegram settings ====
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
GPT_BASE_HOST="http://localhost"
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="false"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT=1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD="true"
|
||||
DEBUG="true"
|
||||
# ==== domain settings ====
|
||||
DOMAIN="http://localhost"
|
||||
URL_PREFIX=
|
||||
|
||||
# ==== gpt settings ====
|
||||
GPT_BASE_HOST="http://localhost"
|
||||
|
||||
# ==== other settings ====
|
||||
USER="web"
|
||||
@@ -1,35 +1,43 @@
|
||||
STAGE="dev"
|
||||
|
||||
# ==== start app settings ====
|
||||
APP_HOST="0.0.0.0"
|
||||
APP_PORT="8000"
|
||||
|
||||
# SENTRY_DSN=
|
||||
SENTRY_TRACES_SAMPLE_RATE="0.95"
|
||||
|
||||
# GRAYLOG_HOST=
|
||||
|
||||
USER="web"
|
||||
TZ="Europe/Moscow"
|
||||
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
|
||||
# webhook settings
|
||||
DOMAIN="https://mydomain.com"
|
||||
URL_PREFIX="/gpt"
|
||||
|
||||
GPT_BASE_HOST="http://chat_service:8858"
|
||||
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="false"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT=1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD="true"
|
||||
DEBUG="true"
|
||||
|
||||
# ==== sentry ====
|
||||
SENTRY_DSN=
|
||||
SENTRY_TRACES_SAMPLE_RATE="0.95"
|
||||
DEPLOY_ENVIRONMENT="stage"
|
||||
|
||||
# ==== logs ====:
|
||||
ENABLE_JSON_LOGS="true"
|
||||
ENABLE_SENTRY_LOGS="false"
|
||||
GRAYLOG_HOST=
|
||||
GRAYLOG_PORT=
|
||||
LOG_TO_FILE="example.log"
|
||||
|
||||
# ==== telegram settings ====
|
||||
TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="false"
|
||||
|
||||
# ==== domain settings ====
|
||||
DOMAIN="https://mydomain.com"
|
||||
URL_PREFIX="/gpt"
|
||||
|
||||
# ==== gpt settings ====
|
||||
GPT_BASE_HOST="http://chat_service:8858"
|
||||
GPT_MODEL="gpt-3.5-turbo-stream-DeepAi"
|
||||
|
||||
# ==== other settings ====
|
||||
USER="web"
|
||||
TZ="Europe/Moscow"
|
||||
|
||||
# "gpt-3.5-turbo-stream-openai"
|
||||
# "gpt-3.5-turbo-Aichat"
|
||||
# "gpt-4-ChatgptAi"
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import HttpUrl, ValidationInfo, field_validator
|
||||
from pydantic import model_validator
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
from constants import API_PREFIX
|
||||
@@ -28,7 +28,7 @@ load_dotenv(env_path, override=True)
|
||||
|
||||
|
||||
class SentrySettings(BaseSettings):
|
||||
SENTRY_DSN: HttpUrl | None = None
|
||||
SENTRY_DSN: str | None = None
|
||||
DEPLOY_ENVIRONMENT: str | None = None
|
||||
SENTRY_TRACES_SAMPLE_RATE: float = 0.95
|
||||
|
||||
@@ -41,6 +41,10 @@ class AppSettings(SentrySettings, BaseSettings):
|
||||
APP_PORT: int = 8000
|
||||
STAGE: str = "dev"
|
||||
DEBUG: bool = False
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT: int = 1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD: bool = False
|
||||
|
||||
TELEGRAM_API_TOKEN: str = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
||||
# webhook settings
|
||||
@@ -48,21 +52,28 @@ class AppSettings(SentrySettings, BaseSettings):
|
||||
DOMAIN: str = "https://localhost"
|
||||
URL_PREFIX: str = ""
|
||||
|
||||
GRAYLOG_HOST: str | None = None
|
||||
|
||||
GPT_MODEL: str = "gpt-3.5-turbo-stream-AItianhuSpace"
|
||||
# ==== gpt settings ====
|
||||
GPT_MODEL: str = "gpt-3.5-turbo-stream-DeepAi"
|
||||
GPT_BASE_HOST: str = "http://chat_service:8858"
|
||||
|
||||
# quantity of workers for uvicorn
|
||||
WORKERS_COUNT: int = 1
|
||||
# Enable uvicorn reloading
|
||||
RELOAD: bool = False
|
||||
ENABLE_JSON_LOGS: bool = True
|
||||
ENABLE_SENTRY_LOGS: bool = False
|
||||
GRAYLOG_HOST: str | None = None
|
||||
GRAYLOG_PORT: int | None = None
|
||||
LOG_TO_FILE: str | None = None
|
||||
|
||||
@field_validator("START_WITH_WEBHOOK")
|
||||
def star_with_webhook_validator(cls, field_value: Any, info: ValidationInfo) -> Any:
|
||||
if field_value == "false":
|
||||
return False
|
||||
return field_value
|
||||
@model_validator(mode="before") # type: ignore[arg-type]
|
||||
def validate_boolean_fields(self) -> Any:
|
||||
for value in (
|
||||
"ENABLE_JSON_LOGS",
|
||||
"ENABLE_SENTRY_LOGS",
|
||||
"START_WITH_WEBHOOK",
|
||||
"RELOAD",
|
||||
"DEBUG",
|
||||
):
|
||||
if self.get(value).lower() == "false": # type: ignore[attr-defined]
|
||||
self[value] = False # type: ignore[index]
|
||||
return self
|
||||
|
||||
@cached_property
|
||||
def api_prefix(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user