mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 01:53:21 +08:00
feat: add conversationTitle to context enhancement
Pass inbound group titles into <dsh_im_source> without extra platform API lookups. DingTalk uses conversationTitle; Telegram groups use chat.title.
This commit is contained in:
parent
13fc85cdce
commit
7a68e94f54
11 changed files with 82 additions and 30 deletions
|
|
@ -16,15 +16,28 @@ const FIELD_LABELS = Object.freeze({
|
|||
conversationType: '会话类型',
|
||||
senderId: '发送者标识',
|
||||
senderName: '发送者昵称',
|
||||
conversationTitle: '会话标题',
|
||||
botId: '机器人标识',
|
||||
});
|
||||
|
||||
const FIELD_HELP = Object.freeze({
|
||||
senderName: Object.freeze({
|
||||
labelKey: 'senderNameHelpLabel',
|
||||
text: '该字段不是每个渠道都能提供。当前消息没有发送者昵称时,即使已选择该字段,<dsh_im_source> 中也会省略 senderName。',
|
||||
}),
|
||||
conversationTitle: Object.freeze({
|
||||
labelKey: 'conversationTitleHelpLabel',
|
||||
text: '该字段不是每个渠道都能提供。钉钉群聊会带上群名。当前消息没有会话标题时,即使已选择该字段,<dsh_im_source> 中也会省略 conversationTitle。',
|
||||
}),
|
||||
});
|
||||
|
||||
const SCOPE_COPY = Object.freeze({
|
||||
group: Object.freeze({
|
||||
title: '群聊',
|
||||
enable: '启用',
|
||||
fieldsHelpLabel: '查看群聊来源字段说明',
|
||||
senderNameHelpLabel: '查看群聊发送者昵称字段说明',
|
||||
conversationTitleHelpLabel: '查看群聊会话标题字段说明',
|
||||
guidanceLabel: '增强提示词',
|
||||
guidanceHelpLabel: '查看群聊增强提示词使用说明',
|
||||
guidanceUsage: '用于告诉模型如何使用当前群聊消息的 <dsh_im_source> 来源字段。只填写正文,插件会自动添加 <dsh_im_source_guidance> 成对标签。',
|
||||
|
|
@ -35,6 +48,7 @@ const SCOPE_COPY = Object.freeze({
|
|||
enable: '启用',
|
||||
fieldsHelpLabel: '查看私聊来源字段说明',
|
||||
senderNameHelpLabel: '查看私聊发送者昵称字段说明',
|
||||
conversationTitleHelpLabel: '查看私聊会话标题字段说明',
|
||||
guidanceLabel: '增强提示词',
|
||||
guidanceHelpLabel: '查看私聊增强提示词使用说明',
|
||||
guidanceUsage: '用于告诉模型如何使用当前私聊消息的 <dsh_im_source> 来源字段。只填写正文,插件会自动添加 <dsh_im_source_guidance> 成对标签。',
|
||||
|
|
@ -73,7 +87,6 @@ function ContextEnhancementScopeEditor({
|
|||
const copy = SCOPE_COPY[kind];
|
||||
const unavailableId = `${idPrefix}-${kind}-unavailable`;
|
||||
const fieldsHelpId = `${idPrefix}-${kind}-fields-help`;
|
||||
const senderNameHelpId = `${idPrefix}-${kind}-sender-name-help`;
|
||||
const guidanceId = `${idPrefix}-${kind}-guidance`;
|
||||
const guidanceHelpId = `${idPrefix}-${kind}-guidance-help`;
|
||||
const disabled = busy || !supported;
|
||||
|
|
@ -118,16 +131,17 @@ function ContextEnhancementScopeEditor({
|
|||
}),
|
||||
h('span', { className: 'dim-contextFieldText' },
|
||||
h('label', { className: 'dim-contextFieldName', htmlFor: fieldId }, FIELD_LABELS[field]),
|
||||
field === 'senderName' ? h('span', { className: 'dim-contextHelp dim-contextFieldHelp' },
|
||||
FIELD_HELP[field] ? h('span', { className: 'dim-contextHelp dim-contextFieldHelp' },
|
||||
h('button', {
|
||||
type: 'button', className: 'dim-contextHelpButton dim-contextFieldHelpButton', disabled,
|
||||
'aria-label': copy.senderNameHelpLabel, 'aria-describedby': senderNameHelpId,
|
||||
'aria-label': copy[FIELD_HELP[field].labelKey],
|
||||
'aria-describedby': `${idPrefix}-${kind}-${field}-help`,
|
||||
}, h('span', { 'aria-hidden': 'true' }, '?')),
|
||||
h('span', {
|
||||
id: senderNameHelpId,
|
||||
id: `${idPrefix}-${kind}-${field}-help`,
|
||||
className: 'dim-contextTooltip dim-contextFieldTooltip',
|
||||
role: 'tooltip',
|
||||
}, '该字段不是每个渠道都能提供。当前消息没有发送者昵称时,即使已选择该字段,<dsh_im_source> 中也会省略 senderName。')) : null,
|
||||
}, FIELD_HELP[field].text)) : null,
|
||||
h('label', { className: 'dim-contextFieldKey', htmlFor: fieldId }, field)));
|
||||
}))),
|
||||
h('div', { className: 'dim-contextGuidance dim-contextScopeBlock' },
|
||||
|
|
|
|||
|
|
@ -288,6 +288,10 @@ const EN = Object.freeze({
|
|||
'查看群聊发送者昵称字段说明': 'View group sender name field details',
|
||||
'查看私聊发送者昵称字段说明': 'View direct 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.',
|
||||
'会话标题': 'Conversation title',
|
||||
'查看群聊会话标题字段说明': 'View group conversation title field details',
|
||||
'查看私聊会话标题字段说明': 'View direct conversation title field details',
|
||||
'该字段不是每个渠道都能提供。钉钉群聊会带上群名。当前消息没有会话标题时,即使已选择该字段,<dsh_im_source> 中也会省略 conversationTitle。': 'This field is not available on every channel. DingTalk group chats include the group name. If the current message has no conversation title, <dsh_im_source> omits conversationTitle even when the field is selected.',
|
||||
'机器人标识': 'Bot ID',
|
||||
'增强提示词': 'Guidance',
|
||||
'查看增强提示词使用说明': 'View guidance instructions',
|
||||
|
|
@ -315,7 +319,7 @@ const EN = Object.freeze({
|
|||
'上下文增强保存失败,请重试。': '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.',
|
||||
'来源字段只能选择已定义的六个字段。': 'Source fields must be chosen from the six defined fields.',
|
||||
'保存中…': 'Saving…',
|
||||
'未设置': 'Not set',
|
||||
'工作区修改失败,请重试。': 'Could not update the workspace. Try again.',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue