| | import os |
| | import pathlib |
| | import logging |
| | from datetime import datetime, timedelta |
| |
|
| | |
| | BASE_DIR = pathlib.Path(__file__).parent.parent |
| |
|
| | |
| | FAKE_STREAMING = os.environ.get("FAKE_STREAMING", "true").lower() in ["true", "1", "yes"] |
| | |
| | FAKE_STREAMING_INTERVAL = float(os.environ.get("FAKE_STREAMING_INTERVAL", "1")) |
| |
|
| | |
| | RANDOM_STRING = os.environ.get("RANDOM_STRING", "true").lower() in ["true", "1", "yes"] |
| | RANDOM_STRING_LENGTH = int(os.environ.get("RANDOM_STRING_LENGTH", "5")) |
| |
|
| |
|
| | |
| | logging.getLogger("uvicorn").disabled = True |
| | logging.getLogger("uvicorn.access").disabled = True |
| |
|
| | |
| | PASSWORD = os.environ.get("PASSWORD", "123").strip('"') |
| | MAX_REQUESTS_PER_MINUTE = int(os.environ.get("MAX_REQUESTS_PER_MINUTE", "30")) |
| | MAX_REQUESTS_PER_DAY_PER_IP = int(os.environ.get("MAX_REQUESTS_PER_DAY_PER_IP", "600")) |
| | RETRY_DELAY = 1 |
| | MAX_RETRY_DELAY = 16 |
| |
|
| | |
| | |
| | API_KEY_DAILY_LIMIT = int(os.environ.get("API_KEY_DAILY_LIMIT", "100")) |
| |
|
| | |
| | CACHE_EXPIRY_TIME = int(os.environ.get("CACHE_EXPIRY_TIME", "1200")) |
| | MAX_CACHE_ENTRIES = int(os.environ.get("MAX_CACHE_ENTRIES", "500")) |
| | REMOVE_CACHE_AFTER_USE = os.environ.get("REMOVE_CACHE_AFTER_USE", "true").lower() in ["true", "1", "yes"] |
| |
|
| | |
| | REQUEST_HISTORY_EXPIRY_TIME = int(os.environ.get("REQUEST_HISTORY_EXPIRY_TIME", "600")) |
| | ENABLE_RECONNECT_DETECTION = os.environ.get("ENABLE_RECONNECT_DETECTION", "true").lower() in ["true", "1", "yes"] |
| |
|
| | serach={ |
| | "search_mode":os.environ.get("SERACH_MODE", "true").lower() in ["true", "1", "yes"], |
| | "search_prompt":os.environ.get("SERACH_PROMPT", "(使用搜索工具联网搜索,需要在content中结合搜索内容)").strip('"') |
| | } |
| |
|
| | version={ |
| | "local_version":"0.0.0", |
| | "remote_version":"0.0.0", |
| | "has_update":False |
| | } |
| |
|
| | |
| | api_call_stats = { |
| | 'last_24h': { |
| | 'total': {}, |
| | 'by_endpoint': {} |
| | }, |
| | 'hourly': { |
| | 'total': {}, |
| | 'by_endpoint': {} |
| | }, |
| | 'minute': { |
| | 'total': {}, |
| | 'by_endpoint': {} |
| | } |
| | } |
| |
|
| | |
| | client_request_history = {} |
| |
|
| | |
| | |
| | DEFAULT_BLOCKED_MODELS = [] |
| |
|
| | |
| | |
| | BLOCKED_MODELS = os.environ.get("BLOCKED_MODELS", ",".join(DEFAULT_BLOCKED_MODELS)) |
| | |
| | BLOCKED_MODELS = [model.strip() for model in BLOCKED_MODELS.split(",") if model.strip()] |