109 lines
2.5 KiB
Python
109 lines
2.5 KiB
Python
"""
|
||
MCP服务器配置文件
|
||
集中管理所有配置项
|
||
"""
|
||
|
||
from typing import Dict
|
||
from pydantic import BaseSettings
|
||
|
||
class Settings(BaseSettings):
|
||
"""应用配置"""
|
||
|
||
# 服务器配置
|
||
SERVER_HOST: str = "0.0.0.0"
|
||
SERVER_PORT: int = 8900
|
||
DEBUG: bool = True
|
||
|
||
# 后端API服务端点
|
||
NEWS_API_URL: str = "http://222.128.1.157:21891"
|
||
ROADSHOW_API_URL: str = "http://222.128.1.157:19800"
|
||
CONCEPT_API_URL: str = "http://222.128.1.157:16801"
|
||
STOCK_ANALYSIS_API_URL: str = "http://222.128.1.157:8811"
|
||
|
||
# HTTP客户端配置
|
||
HTTP_TIMEOUT: float = 60.0
|
||
HTTP_MAX_RETRIES: int = 3
|
||
|
||
# 日志配置
|
||
LOG_LEVEL: str = "INFO"
|
||
LOG_FORMAT: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||
|
||
# CORS配置
|
||
CORS_ORIGINS: list = ["*"]
|
||
CORS_CREDENTIALS: bool = True
|
||
CORS_METHODS: list = ["*"]
|
||
CORS_HEADERS: list = ["*"]
|
||
|
||
# LLM配置(如果需要集成)
|
||
LLM_PROVIDER: str = "openai" # openai, anthropic, etc.
|
||
LLM_API_KEY: str = ""
|
||
LLM_MODEL: str = "gpt-4"
|
||
LLM_BASE_URL: str = ""
|
||
|
||
# 速率限制
|
||
RATE_LIMIT_ENABLED: bool = False
|
||
RATE_LIMIT_PER_MINUTE: int = 60
|
||
|
||
# 缓存配置
|
||
CACHE_ENABLED: bool = True
|
||
CACHE_TTL: int = 300 # 秒
|
||
|
||
class Config:
|
||
env_file = ".env"
|
||
case_sensitive = True
|
||
|
||
|
||
# 全局设置实例
|
||
settings = Settings()
|
||
|
||
|
||
# 工具类别映射(用于组织和展示)
|
||
TOOL_CATEGORIES: Dict[str, list] = {
|
||
"新闻搜索": [
|
||
"search_news",
|
||
"search_china_news",
|
||
"search_medical_news"
|
||
],
|
||
"公司研究": [
|
||
"search_roadshows",
|
||
"search_research_reports"
|
||
],
|
||
"概念板块": [
|
||
"search_concepts",
|
||
"get_concept_details",
|
||
"get_stock_concepts",
|
||
"get_concept_statistics"
|
||
],
|
||
"股票分析": [
|
||
"search_limit_up_stocks",
|
||
"get_daily_stock_analysis"
|
||
]
|
||
}
|
||
|
||
|
||
# 工具优先级(用于LLM选择工具时的提示)
|
||
TOOL_PRIORITIES: Dict[str, int] = {
|
||
"search_china_news": 10, # 最常用
|
||
"search_concepts": 9,
|
||
"search_limit_up_stocks": 8,
|
||
"search_research_reports": 8,
|
||
"get_stock_concepts": 7,
|
||
"search_news": 6,
|
||
"get_daily_stock_analysis": 5,
|
||
"get_concept_statistics": 5,
|
||
"search_medical_news": 4,
|
||
"search_roadshows": 4,
|
||
"get_concept_details": 3,
|
||
}
|
||
|
||
|
||
# 默认参数配置
|
||
DEFAULT_PARAMS = {
|
||
"top_k": 20,
|
||
"page_size": 20,
|
||
"size": 10,
|
||
"sort_by": "change_pct",
|
||
"mode": "hybrid",
|
||
"exact_match": False,
|
||
}
|