mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-11-30 16:02:58 +08:00
fix: 问问微信恢复引用编号,日报修复成员头像与 hero 溢出
- 问问微信:Host 分配稳定 citationId 并注入模型上下文,正文 [E#] 与证据按钮同号 - 问问微信:回答返回前校验引用,幻觉编号移除并提示,不再出现不可信的引用按钮 - Agent Hub:收紧「最近会话」快捷路由,内容查询交回 Query Agent
This commit is contained in:
1 parent
4b2395a8d2
commit
b97e1f4bc6
23 files changed
+1635
-228
No files matched your search
@@ -7,6 +7,66 @@ import type { ReportTemplateRef } from './report-template-package'
|
||||
export const selectHeroParticipantNames = (names: string[]): string[] =>
|
||||
Array.from(new Set(names.map((name) => name.trim()).filter(Boolean))).slice(0, 4)
|
||||
|
||||
/**
|
||||
* 群成员快照里可以用来关联报告显示名的全部别名。
|
||||
*
|
||||
* 报告里的显示名取决于 `memberNameMode`(默认是**群昵称**),而快照的 `nickname`
|
||||
* 字段是 `wechatNickname || groupNickname || username`。一个成员同时有微信昵称与群昵称、
|
||||
* 且两者不同时,只按 `nickname` 建索引会**全部对不上** —— 头像 enrichment 会静默失效,
|
||||
* 用户看到的就是首字 fallback。
|
||||
*/
|
||||
export const REPORT_AVATAR_ALIAS_FIELDS = [
|
||||
'nickname',
|
||||
'groupNickname',
|
||||
'wechatNickname',
|
||||
'remark',
|
||||
'wxid'
|
||||
] as const
|
||||
|
||||
export interface ReportAvatarMember {
|
||||
wxid: string
|
||||
nickname?: string
|
||||
groupNickname?: string
|
||||
wechatNickname?: string
|
||||
remark?: string
|
||||
avatar?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立「显示名别名 → 头像 URL」索引:每个成员的所有可用显示名都指向同一头像。
|
||||
* 同名先到先得(P2 风险:群里两人同名)。
|
||||
*/
|
||||
export const buildReportAvatarAliasIndex = (
|
||||
members: readonly ReportAvatarMember[]
|
||||
): Map<string, string> => {
|
||||
const index = new Map<string, string>()
|
||||
for (const member of members) {
|
||||
if (!member.avatar) continue
|
||||
for (const field of REPORT_AVATAR_ALIAS_FIELDS) {
|
||||
const name = String(member[field] || '').trim()
|
||||
if (name && !index.has(name)) index.set(name, member.avatar)
|
||||
}
|
||||
}
|
||||
return index
|
||||
}
|
||||
|
||||
/**
|
||||
* 把别名索引合并进 `metadata.avatars`,返回实际补充的条数。
|
||||
* 调用方已经给出的有效头像一律保留,绝不被快照覆盖。
|
||||
*/
|
||||
export const mergeReportAvatars = (
|
||||
avatars: Record<string, string | undefined>,
|
||||
index: ReadonlyMap<string, string>
|
||||
): number => {
|
||||
let filled = 0
|
||||
for (const [name, url] of index) {
|
||||
if (avatars[name]) continue
|
||||
avatars[name] = url
|
||||
filled += 1
|
||||
}
|
||||
return filled
|
||||
}
|
||||
|
||||
export type ReportSectionKey =
|
||||
| 'hero'
|
||||
| 'topics'
|
||||
|
||||
@@ -26,6 +26,15 @@ export interface AskWechatScope {
|
||||
|
||||
/** 展示用证据:只含可读字段,不含 wxid / md5 / DB id / raw Tool JSON。 */
|
||||
export interface AskWechatEvidenceItem {
|
||||
/**
|
||||
* Host 分配的稳定引用编号(`E1`、`E2`…)。
|
||||
*
|
||||
* 由 Runtime 的 EvidenceCollector 在**模型调用之前**按首次命中顺序分配,并随 Tool Result
|
||||
* 进入模型可见上下文 —— 因此正文里的 `[E#]` 与 UI 证据卡 / 底部引用按钮用的是同一个编号。
|
||||
* UI **不得**再用数组下标自行合成编号:那会在证据被过滤、分页或重排时漂移,
|
||||
* 而且模型无从知道它(inline citation 会因此失效)。
|
||||
*/
|
||||
citationId: string
|
||||
messageRef: string
|
||||
conversationName?: string
|
||||
conversationType?: 'user' | 'group'
|
||||
@@ -197,6 +206,13 @@ export type AskWechatQueryResult =
|
||||
answer: string
|
||||
/** 本次回答实际依据的证据(去重、限量);UI 不允许从 answer 反解析。 */
|
||||
evidence: AskWechatEvidenceItem[]
|
||||
/**
|
||||
* Host 侧 citation 校验中被移除的非法编号(additive)。
|
||||
*
|
||||
* 非空表示模型引用了不存在的 `[E#]`,已从 answer 中移除 —— UI 可据此提示
|
||||
* "已移除无法对应证据的引用",而不是把幻觉编号渲染成可点击的引用。
|
||||
*/
|
||||
invalidCitationIds?: string[]
|
||||
stats: AskWechatStats
|
||||
diagnostics: QueryAgentDiagnostics
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user