初始化:记忆系统源代码上传(已脱敏)
- 排除 .env / *.bak / 内部运维文档(README_INTERNAL.html) - config.py 默认密码已替换为占位符 CHANGE_ME_* - init_db.sql 移除生产数据库用户 GRANT 段 - README.html 数据库用户名已脱敏 - 保留:源码 + 公网 API 文档 + 建表 SQL(无授权语句)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Memory System Configuration"""
|
||||
import os
|
||||
import json
|
||||
|
||||
|
||||
class Config:
|
||||
# MySQL
|
||||
MYSQL_HOST = os.getenv("MYSQL_HOST", "127.0.0.1")
|
||||
MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
|
||||
MYSQL_USER = os.getenv("MYSQL_USER", "your_db_user")
|
||||
MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "CHANGE_ME_MYSQL_PASSWORD")
|
||||
MYSQL_DATABASE = os.getenv("MYSQL_DATABASE", "memory_system")
|
||||
MYSQL_CHARSET = "utf8mb4"
|
||||
MYSQL_UNIX_SOCKET = os.getenv("MYSQL_UNIX_SOCKET", "/var/run/mysqld/mysqld.sock")
|
||||
|
||||
# Redis
|
||||
REDIS_HOST = os.getenv("REDIS_HOST", "127.0.0.1")
|
||||
REDIS_PORT = int(os.getenv("REDIS_PORT", "6379"))
|
||||
REDIS_PASSWORD = os.getenv("REDIS_PASSWORD", "CHANGE_ME_REDIS_PASSWORD")
|
||||
REDIS_DB = int(os.getenv("REDIS_DB", "0"))
|
||||
|
||||
# BGE Embedding Service
|
||||
EMBEDDING_SERVICE_URL = os.getenv("EMBEDDING_SERVICE_URL", "http://127.0.0.1:8080")
|
||||
EMBEDDING_DIM = 512
|
||||
|
||||
# Working memory TTL (seconds)
|
||||
WORKING_MEMORY_TTL = int(os.getenv("WORKING_MEMORY_TTL", "259200")) # 72h
|
||||
|
||||
# Cleanup defaults
|
||||
CLEANUP_MAX_AGE_DAYS = 90
|
||||
CLEANUP_MIN_IMPORTANCE = 0.2
|
||||
|
||||
# API
|
||||
API_HOST = os.getenv("API_HOST", "127.0.0.1")
|
||||
API_PORT = int(os.getenv("API_PORT", "8081"))
|
||||
|
||||
# LLM providers (JSON list, priority=1 is primary, higher = fallback)
|
||||
LLM_PROVIDERS_JSON = os.getenv("LLM_PROVIDERS", "[]")
|
||||
|
||||
@property
|
||||
def llm_providers(self) -> list:
|
||||
try:
|
||||
val = self.LLM_PROVIDERS_JSON
|
||||
providers = json.loads(val) if val else []
|
||||
for p in providers:
|
||||
key = p.get("api_key", "")
|
||||
if isinstance(key, str) and key.startswith("${") and key.endswith("}"):
|
||||
p["api_key"] = os.getenv(key[2:-1], "") or ""
|
||||
return providers
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
return []
|
||||
Reference in New Issue
Block a user