feat: 完整功能部署 v1.0
新增功能: - 天网协作系统 (HTTP API 端口 6060) - 三种工作流 (查找图片/处理图片/转人工派单) - 图片任务数据库 (支持客户后续增加需求) - 图绘派单系统集成 (API: 8005) - 文字检测与加价 (60-80 元高价值订单) - 风险评估与接单判断 - 作图失败自动转人工 新增文档: - 项目功能汇总.md - 三种工作流功能说明.md - 文字加价功能说明.md - 风险评估功能说明.md - 图片任务数据库功能说明.md - 图绘派单系统集成说明.md - 作图失败转接人工说明.md - DEPLOYMENT.md - TIANWANG_INTEGRATION.md 核心修改: - core/pydantic_ai_agent.py - core/workflow.py - core/websocket_client.py - image/image_analyzer.py - services/service_tuhui_dispatch.py - db/image_tasks_db.py 版本:v1.0 日期:2026-02-28
This commit is contained in:
82
run.py
Normal file → Executable file
82
run.py
Normal file → Executable file
@@ -2,10 +2,14 @@
|
||||
"""
|
||||
项目入口 - 启动 WebSocket 客服客户端
|
||||
用法:
|
||||
python run.py # 正常启动(含 AI Agent)
|
||||
python run.py --no-agent # 仅基础回复,不启用 AI
|
||||
python run.py # 单进程模式(默认)
|
||||
python run.py --no-agent # 仅基础回复,不启用 AI
|
||||
python run.py --multi # 多进程模式
|
||||
python run.py --multi -w 4 # 多进程模式,指定 4 个进程
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
# 确保项目根目录在 sys.path 首位
|
||||
@@ -13,13 +17,81 @@ _root = Path(__file__).resolve().parent
|
||||
if str(_root) not in sys.path:
|
||||
sys.path.insert(0, str(_root))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def run_single_process(enable_agent: bool):
|
||||
"""单进程模式"""
|
||||
from core.websocket_client import QingjianAPIClient
|
||||
import asyncio
|
||||
|
||||
enable_agent = "--no-agent" not in sys.argv
|
||||
|
||||
print("=" * 60)
|
||||
print("AI 客服系统 - 单进程模式")
|
||||
print("=" * 60)
|
||||
print(f"AI Agent: {'已启用' if enable_agent else '未启用'}")
|
||||
print("=" * 60)
|
||||
|
||||
client = QingjianAPIClient(enable_agent=enable_agent)
|
||||
try:
|
||||
asyncio.run(client.run())
|
||||
except KeyboardInterrupt:
|
||||
print("\n已停止")
|
||||
|
||||
|
||||
def run_multi_process(num_workers: int, enable_agent: bool):
|
||||
"""多进程模式"""
|
||||
from scripts.multi_process_launcher import Coordinator
|
||||
|
||||
print("=" * 60)
|
||||
print("AI 客服系统 - 多进程异步并行模式")
|
||||
print("=" * 60)
|
||||
print(f"工作进程数:{num_workers}")
|
||||
print(f"AI Agent: {'已启用' if enable_agent else '未启用'}")
|
||||
print("=" * 60)
|
||||
|
||||
coordinator = Coordinator(num_workers=num_workers)
|
||||
|
||||
try:
|
||||
coordinator.start()
|
||||
except KeyboardInterrupt:
|
||||
print("\n已停止")
|
||||
coordinator.stop()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='AI 客服系统启动器')
|
||||
|
||||
parser.add_argument(
|
||||
'--no-agent',
|
||||
action='store_true',
|
||||
help='不启用 AI Agent,仅基础回复'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--multi',
|
||||
action='store_true',
|
||||
help='多进程模式'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-w', '--workers',
|
||||
type=int,
|
||||
default=None,
|
||||
help='工作进程数(默认:CPU 核心数,仅多进程模式有效)'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
enable_agent = not args.no_agent
|
||||
|
||||
if args.multi:
|
||||
# 多进程模式
|
||||
run_multi_process(
|
||||
num_workers=args.workers,
|
||||
enable_agent=enable_agent
|
||||
)
|
||||
else:
|
||||
# 单进程模式(默认)
|
||||
run_single_process(enable_agent=enable_agent)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user