优化对话转工单功能,添加重试机制以提高稳定性,限制处理会话数量为前2000个,更新示例查询和文件路径,增强代码可读性和维护性。同时新增数据库客户端功能,支持批量处理会话数据并导出至Excel。
This commit is contained in:
@@ -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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user