From 101a99616edec2032da29f0bceaa2be4e03dcddf Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Fri, 20 Mar 2026 14:11:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=88=86=E6=9E=90prompt=E5=A2=9E=E5=8A=A0=E7=A6=BB=E5=B2=97?= =?UTF-8?q?=E8=AF=86=E5=88=AB=20+=20=E5=88=9B=E5=BB=BA=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E5=B8=A6=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. IMAGE_ANALYZE_PROMPT 增加"岗位无人值守"等异常类型 2. create_work_order 意图支持直接提取 location,有位置则跳过追问 3. 减少图片+文字同时发送时的消息顺序混乱 --- app/services/agent_dispatcher.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/app/services/agent_dispatcher.py b/app/services/agent_dispatcher.py index 8ae87fa..898e91e 100644 --- a/app/services/agent_dispatcher.py +++ b/app/services/agent_dispatcher.py @@ -40,6 +40,7 @@ SYSTEM_PROMPT = """你是物业安防AI助手。你可以: 可选意图(仅在用户明确请求时使用): - create_work_order: 用户明确要创建工单或上报问题 + params: {title: 工单标题, description: 问题描述, location: 位置(如果用户提到了)} - query_alarm: 用户要查询告警统计/概况(如"今天有多少告警""告警统计") params: {time_range: today/week/month, alarm_type: leave_post/intrusion/all} - list_alarm: 用户要查看具体告警列表/详情(如"展示今天所有告警""未处理的告警有哪些""今天的离岗告警") @@ -47,9 +48,18 @@ SYSTEM_PROMPT = """你是物业安防AI助手。你可以: - export_report: 用户要导出报表(params: time_range=today/week/month) - 普通对话不要附加任何标记""" -IMAGE_ANALYZE_PROMPT = """分析这张图片,判断是否存在安全隐患或异常情况。 +IMAGE_ANALYZE_PROMPT = """你是物业安防图片分析员。分析这张图片,判断是否存在安全隐患或需要上报的情况。 + +需要关注的异常包括: +- 岗位无人值守(前台、监控室、门岗等应有人但没人) +- 人员入侵(非授权区域出现人员) +- 车辆违停(禁停区域有车辆) +- 消防隐患(灭火器缺失、通道堵塞、线路杂乱) +- 设施损坏(门窗破损、设备故障) +- 物品遗留(可疑包裹、危险物品) + 请用JSON格式回复: -{"has_anomaly": true/false, "description": "异常描述", "alarm_type": "告警类型(fire/intrusion/damage/leak/other/none)"} +{"has_anomaly": true/false, "description": "异常描述", "alarm_type": "告警类型(leave_post/intrusion/illegal_parking/fire/damage/other/none)"} 只输出JSON,不要其他内容。""" CLOSE_ANALYZE_PROMPT = """这是一张处理后的现场照片。请判断之前的异常是否已经消除。 @@ -383,10 +393,19 @@ class AgentDispatcher: elif intent == "export_report": return await self._handle_export_report(user_id, params) elif intent == "create_work_order": - # 文字创建工单 → 进入等待位置状态 session = get_session_manager().get(user_id) - session.pending_analysis = params.get("description", "") - session.pending_alarm_type = params.get("title", "人工上报") + description = params.get("description", "") + title = params.get("title", "人工上报") + location = params.get("location", "") + + session.pending_analysis = description + session.pending_alarm_type = title + + # 如果参数中已有位置,直接创建工单 + if location and self._looks_like_location(location): + return await self._handle_location_reply(user_id, session, location) + + # 否则追问位置 session.state = "waiting_location" return "请提供具体位置(如:A栋3层东侧走廊)" return ""