newtw
This commit is contained in:
42
scripts/check_garbled.py
Normal file
42
scripts/check_garbled.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import pymysql
|
||||
import re
|
||||
|
||||
conn = pymysql.connect(
|
||||
host='1.12.50.92',
|
||||
port=3306,
|
||||
user='ai_cs_user',
|
||||
password='Zuowei1216',
|
||||
database='ai_cs',
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor
|
||||
)
|
||||
cur = conn.cursor()
|
||||
|
||||
# 查昨晚18:00到今早的AI回复
|
||||
cur.execute("""
|
||||
SELECT customer_name, message, timestamp FROM chat_logs
|
||||
WHERE timestamp >= '2026-03-05 18:00:00' AND timestamp <= '2026-03-06 09:00:00'
|
||||
AND direction = 'out'
|
||||
ORDER BY timestamp
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
print(f"共 {len(rows)} 条AI回复,检查乱码...")
|
||||
|
||||
for r in rows:
|
||||
msg = r['message'] or ''
|
||||
# 检查是否有乱码特征
|
||||
has_code = any([
|
||||
re.search(r'\[\]<\|', msg),
|
||||
re.search(r'<\|[A-Za-z]+\|>', msg),
|
||||
'Function' in msg,
|
||||
'```' in msg,
|
||||
re.search(r'\{["\']', msg), # JSON格式
|
||||
re.search(r'\\n', msg), # 转义字符
|
||||
])
|
||||
if has_code:
|
||||
print(f"\n[{r['timestamp']}] {r['customer_name']}:")
|
||||
print(f" {msg[:150]}")
|
||||
|
||||
conn.close()
|
||||
print("\n检查完成")
|
||||
Reference in New Issue
Block a user