feat: 完善群聊日报模板与图片理解

This commit is contained in:
Wxw-Gu
2026-07-15 16:29:25 +08:00
parent e150605c91
commit 515348b6d8
29 changed files with 3702 additions and 560 deletions
+7
View File
@@ -15,6 +15,11 @@ export interface AIProviderAuth {
export interface AIModelCapabilities {
chat: boolean
vision: boolean
/**
* OCR 是 vision 能力的派生(几乎所有 vision 模型都能 OCR)。
* 不作为用户独立配置项,UI 上显示为"图片文字识别"标签。
*/
ocr: boolean
longContext: boolean
}
@@ -66,6 +71,7 @@ export interface AIRuntimeModelConfig {
modelName: string
configured: boolean
status: AIProviderSummary['status']
timeoutMs?: number
}
export interface LegacyAIConfig {
@@ -77,6 +83,7 @@ export interface LegacyAIConfig {
export interface AIChatRequestOptions {
providerId?: string
modelId?: string
timeoutMs?: number
// Legacy compatibility only. New callers must use providerId/modelId.
apiKey?: string
baseURL?: string
+29
View File
@@ -13,6 +13,7 @@ export type ReportSectionKey =
| 'storylines'
| 'reversals'
| 'gallery'
| 'vision'
| 'voices'
| 'badges'
| 'chains'
@@ -45,6 +46,10 @@ export interface ReportTopic {
imageUrl?: string
note: string
sourceMessageIds?: string[]
/** AI 图片识别缓存 key(由 visionGallery 提供,main 渲染时按此取 base64) */
imageHash?: string
/** AI 真实识别的描述(来自 ImageInsight.description) */
aiDescription?: string
} | null
}
@@ -115,6 +120,26 @@ export interface ReportMediaGalleryItem {
replyCount?: number
}
/**
* 图片 AI 理解结果(由 ImageInsightService 提供)。
* 与 ReportMediaGalleryItem 不同:本类型不含 imageUrl(由 main 渲染时按需注入),
* description 是 AI 真实识别的结果(非基于上下文的推断)。
*/
export interface ReportVisionGalleryItem {
messageId: string
imageHash: string
sender: string
time: string
description: string
ocrText?: string
tags: string[]
category: 'screenshot' | 'photo' | 'meme' | 'document' | 'chart' | 'other'
importance: 'low' | 'medium' | 'high'
sourceMessageIds?: string[]
/** 预加载好的 dataURL,render 时直接嵌进 HTML */
imageUrl?: string
}
export interface ReportVoiceHighlight {
title: string
sender: string
@@ -220,6 +245,8 @@ export interface GroupDailyReport {
keywords: string[]
media: {
gallery: ReportMediaGalleryItem[]
/** AI 识别的图片(由 ImageInsightService 提供),渲染时由 main 按 imageHash 取原图 */
visionGallery?: ReportVisionGalleryItem[]
voiceHighlights: ReportVoiceHighlight[]
funBadges: ReportFunBadge[]
}
@@ -252,6 +279,8 @@ export interface GroupReportMetadata {
export interface GroupReportExportRequest {
report: GroupDailyReport
metadata: GroupReportMetadata
/** 模板 ID:'v1' 经典 / 'v2' 当前。缺省或未知值用默认(v2) */
templateId?: 'v1' | 'v2'
}
export interface GroupReportExportResult {
+110
View File
@@ -0,0 +1,110 @@
// src/shared/image-insight.ts
// ImageInsight:微信图片的 AI 理解结果持久化数据结构
// 与 WechatExplorer 整体 AI 知识平台定位一致 — 图片理解结果可索引、可缓存、可复用。
export type ImageCategory =
| 'screenshot' // 截图
| 'photo' // 实拍照片
| 'meme' // 表情包
| 'document' // 文档/合同/票据
| 'chart' // 图表/数据
| 'other'
export type ImageImportance = 'low' | 'medium' | 'high'
/**
* 单张微信图片的 AI 理解结果(持久化到 image-insights.json)
*
* imageHash 缓存 key 策略:
* 优先用微信原始 md5(已存在,不强制计算)
* 无 md5 才用 sha256(rawBytes).slice(0, 32)
*/
export interface ImageInsight {
id: string // UUID
messageId: string // 微信消息 ID(用于追溯)
imageHash: string // 缓存 key:微信 md5 优先,无 md5 才用 sha256
md5?: string // 微信图片 md5
datName?: string // .dat 文件名
/** AI 输出 */
description: string // 1-2 句中文描述
ocrText?: string // OCR 提取的文字(vision 模型一并返回)
tags: string[] // 关键词标签
category: ImageCategory
importance: ImageImportance
/** 元数据 */
provider: string // AI provider ID
model: string // AI model ID
createdAt: number // 首次分析时间戳
updatedAt: number // 最近更新时间
/** 关联消息信息 */
sender: string
sentAt: number
sessionId: string
}
/**
* 图片理解请求(main 进程内部使用)
*/
export interface ImageAnalysisRequest {
/** 必传,缓存 key */
imageHash: string
/** base64 dataURL,仅 main 内部使用 */
imageDataUrl: string
messageId: string
sender: string
sentAt: number
sessionId: string
/** 强制重新分析(忽略缓存) */
force?: boolean
}
/**
* 图片理解响应
*/
export interface ImageAnalysisResponse {
success: boolean
insight?: ImageInsight
/** 是否来自缓存 */
fromCache?: boolean
error?: string
}
/**
* 图片候选(日报使用)
* 主进程根据消息列表计算热度,返回 Top N + 已缓存的 Insight
*/
export interface ImageCandidate {
messageId: string
imageHash: string
md5?: string
datName?: string
sessionId: string
sender: string
sentAt: number
/** 热度分数 */
heatScore: number
/** 命中缓存时附带 */
insight?: ImageInsight
}
export interface ImageCandidateQuery {
sessionId: string
startTime: number
endTime: number
/** 取 Top N,默认 3 */
limit?: number
/** 由 renderer 从已加载消息中提取的图片候选(包含热度信息) */
inputs?: Array<{
messageId: string
md5?: string
datName?: string
sessionId: string
sender: string
sentAt: number
responseCount: number
interactionCount: number
}>
}