Files
group_xinghuo_jinrong/app/config/settings.py
T
zhanghongyu_0626 4b8e11c9bd feat(threshold): Implement customer loss threshold configuration and notification system
- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications.
- Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance.
- Enhanced `customer_prompts` to include new intent for querying product net values.
- Updated `customer_service` to integrate new threshold alert functionality into existing workflows.
- Implemented `sanitize_postprocess` for improved compliance handling in customer interactions.
- Enhanced course documentation to reflect updates in advisor training modules and interactive elements.

This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
2026-09-10 10:57:40 +08:00

116 lines
4.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.
"""环境配置(从 .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
profile_preference_top_k: int = 3
profile_preference_inject_ttl_days: int = 90
profile_preference_decay_half_life_days: int = 30
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(NL2SQL 问数线)=====
analyst_sql_max_rows: int = 1000
analyst_sql_timeout_s: int = 10
analyst_guardrail_retry_times: int = 1
settings = Settings()