Files
assistant/agent/config.py

61 lines
2.7 KiB
Python
Raw Normal View History

"""
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")
# ============ 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")
# ============ 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}"