导入方式修改
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m44s

This commit is contained in:
2026-05-05 23:17:00 +08:00
parent b5c15ef445
commit 3ae9daa01a
51 changed files with 445 additions and 532 deletions

View File

@@ -20,22 +20,18 @@ class ContactAPIClient:
def __init__(self, conn=None):
"""
初始化
初始化使用延迟初始化MCP在首次使用时初始化
Args:
conn: 数据库连接(保留用于向后兼容)
"""
self.conn = conn
# 确保MCP已初始化
import asyncio
try:
asyncio.create_task(self._init_mcp())
except RuntimeError:
pass # 没有事件循环时跳过,延迟初始化
self._mcp_initialized = False # 延迟初始化标志
async def _init_mcp(self):
"""初始化MCP系统"""
"""初始化MCP系统(延迟初始化)"""
if self._mcp_initialized:
return # 已初始化,跳过
if not mcp_manager.get_adapter("contact"):
# 获取repository如果有
repo = None
@@ -45,9 +41,10 @@ class ContactAPIClient:
repo = ContactRepository(self.conn)
except Exception:
pass
mcp_manager.register_adapter(ContactAdapter(contact_repo=repo))
await mcp_manager.initialize()
self._mcp_initialized = True
async def list_contacts(self, user_id: str = "default") -> List[Contact]:
"""获取联系人列表"""