优化对话到工单的处理逻辑,新增进度条显示,调整日期参数的默认值,并修复日志目录创建的冗余代码。同时,更新DifyExporter类以支持按日期范围过滤消息,重构查询日志加载逻辑,新增备注提取功能,提升代码可读性和可维护性。
This commit is contained in:
@@ -14,6 +14,7 @@ import httpx
|
||||
import traceback
|
||||
import re
|
||||
import logging
|
||||
from tqdm import tqdm
|
||||
|
||||
# 将项目根目录添加到Python路径
|
||||
sys.path.append(os.getcwd())
|
||||
@@ -469,9 +470,10 @@ class DialogueToWorkorder:
|
||||
"客户问题": user_question_str,
|
||||
"问题类型": problem_type,
|
||||
"是否抱怨": "是" if is_dissatisfaction else '否',
|
||||
"抱怨内容": dissatisfaction_reasoning if is_dissatisfaction else '',
|
||||
"抱怨级别": dissatisfaction_level if is_dissatisfaction else '',
|
||||
"是否投诉": "是" if is_complaint else '否',
|
||||
"解决方案": (solution_str + '\n存在抱怨:' + dissatisfaction_reasoning) if is_dissatisfaction else solution_str
|
||||
"解决方案": solution_str
|
||||
})
|
||||
workorder_list.append(base_workorder_dict)
|
||||
# for user_question in user_question_list:
|
||||
@@ -544,7 +546,7 @@ class DialogueToWorkorder:
|
||||
}
|
||||
|
||||
# 获取结果
|
||||
for future in concurrent.futures.as_completed(future_to_conversation):
|
||||
for future in tqdm(concurrent.futures.as_completed(future_to_conversation), total=len(future_to_conversation), desc="处理会话进度"):
|
||||
conversation_id = future_to_conversation[future]
|
||||
try:
|
||||
result_workorders = future.result()
|
||||
@@ -637,9 +639,9 @@ def parse_arguments():
|
||||
help='产品详情Excel文件路径')
|
||||
parser.add_argument('--max_workers', type=int, default=16,
|
||||
help='并发处理线程数,默认为16')
|
||||
parser.add_argument('--start_date', type=str, required=False,
|
||||
parser.add_argument('--start_date', type=str, required=False,default="2025-05-25 00:00:00",
|
||||
help='开始日期,格式为YYYY-MM-DD')
|
||||
parser.add_argument('--end_date', type=str, required=False,
|
||||
parser.add_argument('--end_date', type=str, required=False,default="2025-05-30 15:54",
|
||||
help='结束日期,格式为YYYY-MM-DD')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -23,6 +23,7 @@ from tqdm import tqdm
|
||||
import concurrent.futures
|
||||
import sys
|
||||
|
||||
os.makedirs('./data/log', exist_ok=True)
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -33,7 +34,7 @@ logging.basicConfig(
|
||||
]
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
os.makedirs('./data/log', exist_ok=True)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DatabaseConfig:
|
||||
@@ -492,8 +493,8 @@ def main() -> None:
|
||||
# 创建数据库客户端
|
||||
with MariaDBClient(config, max_connections=12) as db_client:
|
||||
# 查询会话数据
|
||||
start_date = '2025-01-01 00:00:00'
|
||||
end_date = '2025-06-12 00:00:00'
|
||||
start_date = '2025-06-12 00:00:00'
|
||||
end_date = '2025-07-01 00:00:00'
|
||||
|
||||
logger.info(f"查询时间范围: {start_date} 到 {end_date}")
|
||||
# 创建会话处理器
|
||||
|
||||
Reference in New Issue
Block a user