优化对话转工单功能,添加重试机制以提高稳定性,限制处理会话数量为前2000个,更新示例查询和文件路径,增强代码可读性和维护性。同时新增数据库客户端功能,支持批量处理会话数据并导出至Excel。

This commit is contained in:
2025-06-17 19:46:04 +08:00
parent a5c1548240
commit 22d48c951f
10 changed files with 718 additions and 96 deletions
+15 -2
View File
@@ -6,10 +6,23 @@ import json
import time
import threading
import datetime
import logging
# 加载环境变量
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
logging.getLogger('httpx').setLevel(logging.WARNING)
logging.getLogger('openai').setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
app = Flask(__name__)
# 创建线程锁,用于保护共享资源
@@ -50,8 +63,8 @@ def intent_recognize():
end_time = time.time()
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S %z")
print(f"[{current_time}] [{os.getpid()}] [INFO] 意图识别耗时: {end_time - start_time:.2f}")
logger.info(f"[{os.getpid()}] 意图识别耗时: {end_time - start_time:.2f}")
# 提取分类信息
classification = result["classification"]