115 lines
4.0 KiB
Python
115 lines
4.0 KiB
Python
"""环境配置(从 .env 读取,见 .env.example)。"""
|
||
|
||
from decimal import Decimal
|
||
|
||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||
|
||
app_env: str = "development"
|
||
|
||
mysql_host: str = "127.0.0.1"
|
||
mysql_port: int = 3306
|
||
mysql_database: str = "jinrong_agent"
|
||
mysql_core_database: str = "jinrong_core"
|
||
mysql_user: str = "root"
|
||
mysql_password: str = ""
|
||
|
||
redis_url: str = "redis://127.0.0.1:6379/0"
|
||
|
||
neo4j_uri: str = "bolt://localhost:7687"
|
||
neo4j_user: str = "neo4j"
|
||
neo4j_password: str = ""
|
||
|
||
milvus_uri: str = "./data/milvus.db"
|
||
kb_root_dir: str = "./data/kb_collections"
|
||
|
||
ollama_base_url: str = "http://127.0.0.1:11434"
|
||
embed_model: str = "bge-m3"
|
||
embed_dim: int = 1024
|
||
embed_timeout_seconds: float = 60.0
|
||
|
||
deepseek_api_key: str = ""
|
||
deepseek_base_url: str = "https://api.deepseek.com"
|
||
deepseek_model: str = "deepseek-chat"
|
||
deepseek_temperature: float = 0.3
|
||
deepseek_max_tokens: int = 1024
|
||
|
||
# ===== 游客 Agent(客服线 · redis-keys §2.2)=====
|
||
visitor_session_ttl: int = 1800
|
||
visitor_chitchat_max_rounds: int = 15
|
||
visitor_consult_max_rounds: int = 25
|
||
visitor_rate_window_seconds: int = 60
|
||
visitor_rate_max_requests: int = 30
|
||
|
||
# ===== 客户 Agent 会话/画像/归档(客服线 CS Wave 3~5)=====
|
||
customer_session_ttl: int = 7200
|
||
customer_chitchat_max_rounds: int = 15
|
||
customer_consult_max_rounds: int = 25
|
||
profile_extract_every_rounds: int = 5
|
||
profile_confidence_high: float = 0.9
|
||
profile_confidence_default: float = 0.7
|
||
profile_window_max_msgs: int = 40
|
||
archive_idle_minutes: int = 120
|
||
archive_idle_scan_limit: int = 3
|
||
archive_summary_max_msgs: int = 30
|
||
note_max_inject: int = 5
|
||
note_content_max_len: int = 500
|
||
|
||
# ===== JWT(T-01 · JWT 手册 §4/§11)=====
|
||
jwt_public_key_path: str = ""
|
||
jwt_dev_secret: str = "change-me-in-dev-only"
|
||
jwt_dev_algorithm: str = "HS256"
|
||
jwt_dev_expire_hours: int = 8
|
||
jwt_issuer: str = "https://idp.jinrong.internal"
|
||
jwt_audience: str = "agent-gateway"
|
||
|
||
# ===== Risk 阈值(默认值=冻结规则 · docs/PRD/附-风控规则表.md)=====
|
||
risk_large_amount: Decimal = Decimal("500000")
|
||
risk_daily_total: Decimal = Decimal("500000")
|
||
risk_freq_count: int = 3
|
||
risk_probe_window_minutes: int = 5
|
||
risk_probe_count: int = 3
|
||
risk_probe_amount: Decimal = Decimal("400000")
|
||
risk_small_amount: Decimal = Decimal("10000")
|
||
risk_small_count: int = 3
|
||
risk_aml_default_threshold: Decimal = Decimal("0.85")
|
||
|
||
# ===== 风控追加 v1.1(FR-8/9/10 · PRD §4A · C4~C6 共用)=====
|
||
risk_concentration_threshold: float = 0.80
|
||
risk_escalation_scan_minutes: int = 15
|
||
risk_escalation_l1_hours: int = 4
|
||
risk_escalation_l2_hours: int = 24
|
||
risk_escalation_aml_l1_hours: int = 1
|
||
risk_escalation_aml_l2_hours: int = 4
|
||
risk_agent_behavior_scan_minutes: int = 30
|
||
risk_agent_behavior_a_window_hours: int = 24
|
||
risk_agent_behavior_a_count: int = 3
|
||
risk_agent_behavior_b_window_hours: int = 72
|
||
risk_agent_behavior_b_count: int = 5
|
||
risk_agent_behavior_c_window_hours: int = 24
|
||
risk_agent_behavior_c_count: int = 10
|
||
|
||
# ===== 输入防护(T-03 · F-03)=====
|
||
guard_rate_limit_max: int = 30
|
||
guard_rate_limit_window_seconds: int = 60
|
||
|
||
# ===== 画像 Redis 热缓存(redis-keys 手册 · cache-aside)=====
|
||
profile_l1_cache_ttl_seconds: int = 600 # profile:l1:{customer_id} · 10m
|
||
profile_l3_cache_ttl_seconds: int = 300 # profile:l3:{customer_id} · 5m
|
||
|
||
# ===== 代销平台 API(v0.1)=====
|
||
platform_response_desensitize: bool = False
|
||
|
||
# 数据分析 Agent
|
||
jwt_dev_secret: str = "dev-only-change-me"
|
||
jwt_token_ttl_hours: int = 24
|
||
sql_max_rows: int = 1000
|
||
sql_timeout_s: int = 10
|
||
guardrail_retry_times: int = 1
|
||
|
||
|
||
settings = Settings()
|