(source: ChunkSource, messages: ChunkMessageInput[])
| 208 | } |
| 209 | |
| 210 | function buildEmbeddingInput(source: ChunkSource, messages: ChunkMessageInput[]): string { |
| 211 | const effective = messages.filter((m) => !isSemanticVoid(m)) |
| 212 | const startTs = messages[0].ts |
| 213 | const endTs = messages[messages.length - 1].ts |
| 214 | |
| 215 | const lines: string[] = [] |
| 216 | const kindLabel = source.kind === 'group' ? '群聊' : '私聊' |
| 217 | lines.push(`[来源] ${source.title}(${kindLabel})`) |
| 218 | lines.push(`[时间范围] ${formatTimeRange(startTs, endTs)}`) |
| 219 | if (source.kind === 'group') { |
| 220 | const participants = [...new Set(effective.map((m) => m.senderName))] |
| 221 | lines.push(`[参与者] ${participants.join('、')}`) |
| 222 | } |
| 223 | lines.push('') |
| 224 | for (const m of effective) { |
| 225 | lines.push(`${m.senderName}: ${(m.content ?? '').trim()}`) |
| 226 | } |
| 227 | return lines.join('\n') |
| 228 | } |
| 229 | |
| 230 | function rawContentHashOf(messages: ChunkMessageInput[]): string { |
| 231 | return sha256Hex(messages.map((m) => `${m.id}:${m.content ?? ''}`).join('\n')) |
no test coverage detected