Files
assistant/agent/config.py
wangliang 0b5d0a8086 feat: 重构订单和物流信息展示格式
主要改动:
- 订单列表:使用 order_list 格式,展示 5 个订单(全部状态)
- 订单详情:使用 order_detail 格式,优化价格和时间显示
- 物流信息:使用 logistics 格式,根据 track id 动态生成步骤
- 商品图片:从 orderProduct.imageUrl 字段获取
- 时间格式:统一为 YYYY-MM-DD HH:MM:SS
- 多语言支持:amountLabel、orderTime 支持中英文
- 配置管理:新增 FRONTEND_URL 环境变量
- API 集成:改进 Mall API tracks 数据解析
- 认证优化:account_id 从 webhook 动态获取

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-23 18:49:40 +08:00

66 lines
3.1 KiB
Python

"""
Configuration management for B2B Shopping AI Assistant
"""
from typing import Optional
from pydantic_settings import BaseSettings
from pydantic import Field
class Settings(BaseSettings):
"""Application settings loaded from environment variables"""
# ============ AI Model ============
zhipu_api_key: str = Field(..., description="ZhipuAI API Key")
zhipu_model: str = Field(default="glm-4", description="ZhipuAI Model name")
enable_reasoning_mode: bool = Field(default=False, description="Enable AI reasoning/thinking mode (slower but more thoughtful)")
reasoning_mode_for_complex: bool = Field(default=True, description="Enable reasoning mode only for complex queries")
# ============ Redis ============
redis_host: str = Field(default="localhost", description="Redis host")
redis_port: int = Field(default=6379, description="Redis port")
redis_password: Optional[str] = Field(default=None, description="Redis password")
redis_db: int = Field(default=0, description="Redis database number")
# ============ Chatwoot ============
chatwoot_api_url: str = Field(..., description="Chatwoot API URL")
chatwoot_api_token: str = Field(..., description="Chatwoot API Token")
chatwoot_webhook_secret: Optional[str] = Field(default=None, description="Chatwoot Webhook Secret")
# ============ Strapi CMS ============
strapi_api_url: str = Field(..., description="Strapi API URL")
strapi_api_token: str = Field(..., description="Strapi API Token")
# ============ Hyperf API ============
hyperf_api_url: str = Field(..., description="Hyperf API URL")
hyperf_api_token: str = Field(..., description="Hyperf API Token")
# ============ Frontend URLs ============
frontend_url: str = Field(default="https://www.qa1.gaia888.com", description="Frontend URL for order details")
# ============ MCP Servers ============
strapi_mcp_url: str = Field(default="http://localhost:8001", description="Strapi MCP URL")
order_mcp_url: str = Field(default="http://localhost:8002", description="Order MCP URL")
aftersale_mcp_url: str = Field(default="http://localhost:8003", description="Aftersale MCP URL")
product_mcp_url: str = Field(default="http://localhost:8004", description="Product MCP URL")
# ============ Application Config ============
log_level: str = Field(default="INFO", description="Log level")
max_conversation_steps: int = Field(default=10, description="Max steps in conversation")
conversation_timeout: int = Field(default=3600, description="Conversation timeout in seconds")
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
case_sensitive = False
# Global settings instance
settings = Settings()
def get_redis_url() -> str:
"""Get Redis connection URL"""
if settings.redis_password and settings.redis_password.strip():
return f"redis://:{settings.redis_password}@{settings.redis_host}:{settings.redis_port}/{settings.redis_db}"
return f"redis://{settings.redis_host}:{settings.redis_port}/{settings.redis_db}"