feat: add message source context enhancement

This commit is contained in:
xmanrui 2026-08-29 10:46:06 +08:00
parent 5928b33057
commit 0cb79f74e9
69 changed files with 6217 additions and 597 deletions

View file

@ -208,6 +208,44 @@ const EN = Object.freeze({
'/绝对路径/到/工作区': '/absolute/path/to/workspace',
'修改': 'Change',
'保存': 'Save',
'上下文增强': 'Context enhancement',
'未开启': 'Not enabled',
'仅群聊': 'Groups only',
'仅私聊': 'Direct only',
'群聊和私聊': 'Groups and direct',
'关闭弹窗': 'Close dialog',
'查看上下文增强说明': 'View context enhancement details',
'启用范围': 'Enable in',
'群聊中启用': 'Enable in group chats',
'私聊中启用': 'Enable in direct chats',
'(当前渠道不支持群聊)': '(This channel does not support group chats)',
'来源字段': 'Source fields',
'查看来源字段说明': 'View source field details',
'渠道': 'Channel',
'会话类型': 'Conversation type',
'发送者标识': 'Sender ID',
'发送者昵称': 'Sender name',
'查看发送者昵称字段说明': 'View sender name field details',
'该字段不是每个渠道都能提供。当前消息没有发送者昵称时,即使已选择该字段,<dsh_im_source> 中也会省略 senderName。': 'This field is not available on every channel. If the current message has no sender name, <dsh_im_source> omits senderName even when the field is selected.',
'机器人标识': 'Bot ID',
'增强提示词': 'Guidance',
'查看增强提示词使用说明': 'View guidance instructions',
'使用说明': 'How to use',
'用于告诉模型如何使用 <dsh_im_source> 中已选择的来源字段。只填写正文,插件会自动添加 <dsh_im_source_guidance> 成对标签。': 'Tell the model how to use the selected fields in <dsh_im_source>. Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags.',
'生效规则': 'Behavior',
'隐私提示': 'Privacy',
'使用示例': 'Example',
'仅依据当前消息的 <dsh_im_source> 中实际提供的字段理解来源;没有提供的字段不要猜测或补全。\nconversationType是群聊时回复严肃一点,conversationType是私聊时回复一定要幽默搞笑,像周星驰的电影一样搞笑': 'Understand the source only from fields actually present in <dsh_im_source> for the current message; do not guess or fill in missing fields.\nWhen conversationType is group, reply more seriously. When conversationType is direct, make the reply humorous and funny.',
'填入示例': 'Use example',
'清空': 'Clear',
'选择在哪些会话中启用、提供哪些来源字段,以及如何使用这些信息。仅使用已有消息元数据,不查询平台 API。': 'Choose which conversations to enhance, which source fields to include, and how to use them. Only existing message metadata is used; no platform APIs are queried.',
'增强提示词中请使用字段名(如 senderId、conversationType)引用这些信息。只发送勾选且当前消息中可用的字段,不会额外查询或补全。': 'Reference these values by field name (such as senderId or conversationType) in the guidance. Only selected fields available in the current message are sent; no extra lookups are made.',
'只需填写正文,插件自动添加 <dsh_im_source_guidance> 成对标签。清空并保存后,不再附加增强提示词,已选来源字段仍按开关设置发送。': 'Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags. Clear and save to omit guidance. Selected source fields still follow the conversation switches.',
'发送者标识可能包含平台用户 ID 或电话号码形式的标识。关闭开关不会删除已经写入会话历史的信息。': 'Sender IDs may contain platform user IDs or phone-number-like identifiers. Turning this off does not remove information already saved in conversation history.',
'上下文增强保存失败,请重试。': 'Could not save context enhancement. Try again.',
'请提交完整的上下文增强设置。': 'Submit the complete context enhancement settings.',
'群聊和私聊开关必须是布尔值。': 'Group and direct switches must be booleans.',
'来源字段只能选择已定义的五个字段。': 'Source fields must be chosen from the five defined fields.',
'保存中…': 'Saving…',
'未设置': 'Not set',
'工作区修改失败,请重试。': 'Could not update the workspace. Try again.',
@ -657,6 +695,8 @@ function channelName(value) {
}
function translateDynamic(text) {
const guidanceLimit = /^增强提示词不得超过 (\d+) 个字符。$/.exec(text);
if (guidanceLimit) return `Guidance must not exceed ${guidanceLimit[1]} characters.`;
let match = /^(\d+) \/ (\d+) 在线$/.exec(text);
if (match) return `${match[1]}/${match[2]} online`;
match = /^已接入 (\d+) 个机器人,其中 (\d+) 个在线$/.exec(text);