[Feature] 用户识别标识的位置:内联前缀 vs 尾部 system_reminder

Đang mở
#10,887 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
ai, backend

Hướng nghiên cứu

Read astrbot/core/config/default.py and astrbot/core/astr_main_agent.py to compare the identifier hint with where the reminder is added; then inspect openai_source.py and builtin_stars/astrbot/group_chat_context.py for the content-block and formatting context. This issue is explicitly for discussion, not a PR, and leaves the desired behavior undecided, so there is no implementation or test-defined completion criterion yet.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
功能描述

功能描述

provider_settings.identifier(面板:配置 → AI → 用户识别)的 UI 文案与实现不一致,且实现位置对"让模型区分发言人"这个目标可能不是最优。想就此发起一次讨论。

文案(astrbot/core/config/default.py:4173,v4.29.3 与 master 一致):

"provider_settings.identifier": {
    "description": "用户识别",
    "type": "bool",
    "hint": "在用户提示词前带上用户 ID 信息。",
},

实现(astrbot/core/astr_main_agent.py → _append_system_reminders):

if cfg.get("identifier"):
    user_id = event.message_obj.sender.user_id
    user_nickname = event.message_obj.sender.nickname
    system_parts.append(f"User ID: {user_id}, Nickname: {user_nickname}")

system_parts 最终拼成 <system_reminder>...</system_reminder>,经 req.extra_user_content_parts 走 assemble_context() 追加到 content_blocks 末尾。openai_source.py 里对应位置也注明「用户原始发言在前,额外内容块在后」。

也就是说,实际位置在用户原话之后,与文案写的"前"相反。

(group_name_display 的 hint 同样写"前",实现同理,属于同一模式,可一并考虑。)

使用场景

群聊里希望模型准确判断"这句话是谁说的"。

两种位置的差异:

  • 尾部独立块:标识与消息内容在结构上分离(同一条 message 的不同 content block),模型需要做相邻关联。群里连续多条发言、交叉对话、互相引用时,存在错配的空间。
  • 内联前缀:标识与内容在同一字符串内,物理上不可分离,关联更直接。

补充一点实测数据,供讨论参考。若改为内联 f"{nickname}: {prompt}",昵称自带冒号会产生歧义。某 700 条真实群聊记录里,29 位发言人中有 4 位昵称含冒号(约 14%):

增强:123sdx53228
求崩:Cartethyia_Ni
增强🆔:doro994645(职业进度21
增强:芣婹説話,閉仩觜妑

拼出来是 增强:123sdx53228: 我来了,可被读作「'增强' 说:123sdx53228: 我来了」。

而群聊上下文注入用的 _format_message(builtin_stars/astrbot/group_chat_context.py)是 [昵称/时间]: 内容,方括号把昵称整体框住,恰好规避了这类歧义——同样是内联,包装方式值得对齐。

建议(供参考,不代表必须这么做)

  1. 最低成本:让文案与实现一致。要么改 hint 的"前",要么改实现位置。
  2. 若倾向内联,建议用 [昵称]: 内容,与注入块 [昵称/时间]: 保持同一套包装,避免昵称含冒号时的歧义。
  3. 无论选哪种,都可以考虑在 system prompt 补一句格式说明(例如「[昵称]: 前缀表示发言人,昵称可能重复」),让模型知道如何解读,收益比单纯换位置更大。
  4. 附带说明:位置不影响前缀缓存。两种做法都在当前 user message 内部,不改变历史前缀,只影响模型对发言人的归因。

声明

本 issue 由AI代写,仅为讨论与建议,不打算提交 PR。是否调整、怎么调整,交由维护者判断。

使用场景

No response

检查清单
  • 我已在 Issue 列表中搜索过相关功能,确认该功能想法从未被提出过。
  • 我建议的功能与 AstrBot 本体相关,而非在建议某一插件的功能。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助实现该功能。
Ngôn ngữ chính
Python
Star
46.4k
Fork
3.4k
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
120

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AstrBotDevs/AstrBot

Tất cả issue của AstrBotDevs/AstrBot

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.