Files
tw/run_with_tianwang.py
ZuoWei a6c42d505a 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
2026-02-28 11:20:40 +08:00

85 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""
AI 客服系统 - 天网协作版启动器
支持 HTTP API 接收天网任务
"""
import sys
import os
import signal
import logging
from pathlib import Path
# 确保项目根目录在 sys.path 首位
_root = Path(__file__).resolve().parent
if str(_root) not in sys.path:
sys.path.insert(0, str(_root))
# 配置日志
logging.basicConfig(
level=logging.INFO,
format='[%(asctime)s] %(levelname)s: %(message)s'
)
logger = logging.getLogger(__name__)
def main():
logger.info("=" * 60)
logger.info("AI 客服系统 - 天网协作版")
logger.info("=" * 60)
# 1. 启动 HTTP API 服务器
logger.info("正在启动 HTTP API 服务器...")
from api.http_server import start_http_server
http_thread = start_http_server(host='0.0.0.0', port=5678)
logger.info("HTTP API 服务器已启动http://0.0.0.0:5678")
logger.info("")
logger.info("天网任务接口:")
logger.info(" POST /api/task/receive - 接收任务")
logger.info(" POST /api/task/cancel - 取消任务")
logger.info(" GET /api/task/status/:id - 查询任务状态")
logger.info(" GET /api/task/list - 任务列表")
logger.info(" GET /api/health - 健康检查")
logger.info("=" * 60)
# 2. 启动 WebSocket 客服客户端
logger.info("正在连接轻简 API...")
from core.websocket_client import QingjianAPIClient
import argparse
parser = argparse.ArgumentParser(description='AI 客服系统 - 天网协作版')
parser.add_argument('--no-agent', action='store_true', help='不启用 AI Agent')
args = parser.parse_args()
enable_agent = not args.no_agent
client = QingjianAPIClient(enable_agent=enable_agent)
logger.info(f"AI Agent: {'已启用' if enable_agent else '未启用'}")
logger.info("=" * 60)
logger.info("系统已就绪,等待消息和任务...")
logger.info("")
# 注册信号处理
def signal_handler(signum, frame):
logger.info("收到退出信号,正在停止...")
if hasattr(client, 'task_scheduler'):
import asyncio
asyncio.run(client.task_scheduler.stop())
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
# 启动客户端
import asyncio
try:
asyncio.run(client.connect())
except KeyboardInterrupt:
logger.info("已停止")
except Exception as e:
logger.error(f"运行异常:{e}")
sys.exit(1)
if __name__ == "__main__":
main()