Files
aiagent/saars/backend/app/config.py
2026-03-07 13:59:49 +08:00

61 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Application configuration by environment.
数据库:腾讯云 MySQL (liaotian_db)
"""
import os
from datetime import timedelta
# 腾讯云 MySQL - 默认开发/生产库
DEFAULT_DATABASE_URL = (
"mysql+pymysql://root:!Rjb12191@"
"gz-cynosdbmysql-grp-d26pzce5.sql.tencentcdb.com:24936/"
"liaotian_db?charset=utf8mb4"
)
class Config:
"""Base config."""
SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-change-in-production")
SQLALCHEMY_TRACK_MODIFICATIONS = False
# 知你客服 Agent 代理:与 androidExampleDemo 一致8037 使用 admin/123456
PLATFORM_BASE_URL = os.getenv("PLATFORM_BASE_URL", "http://101.43.95.130:8037")
PLATFORM_USERNAME = os.getenv("PLATFORM_USERNAME", "admin")
PLATFORM_PASSWORD = os.getenv("PLATFORM_PASSWORD", "123456")
PLATFORM_AGENT_ID = os.getenv("PLATFORM_AGENT_ID", "7332bba7-f9e7-4e10-9af6-7a0509a3ef97")
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=7)
JWT_TOKEN_LOCATION = ["headers"]
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10MB
UPLOAD_FOLDER = os.getenv("UPLOAD_FOLDER", "/tmp/chat_uploads")
class DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", DEFAULT_DATABASE_URL)
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0")
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/1")
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = os.getenv(
"TEST_DATABASE_URL",
"mysql+pymysql://root:postgres@localhost:3306/liaotian_db_test?charset=utf8mb4"
)
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/2")
WTF_CSRF_ENABLED = False
class ProductionConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", DEFAULT_DATABASE_URL)
REDIS_URL = os.getenv("REDIS_URL")
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL") or os.getenv("REDIS_URL")
config_by_name = {
"development": DevelopmentConfig,
"testing": TestingConfig,
"production": ProductionConfig,
}