MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / buildEmbeddingInput

Function buildEmbeddingInput

packages/node-runtime/src/semantic-index/chunker.ts:210–228  ·  view source on GitHub ↗
(source: ChunkSource, messages: ChunkMessageInput[])

Source from the content-addressed store, hash-verified

208}
209
210function 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
230function rawContentHashOf(messages: ChunkMessageInput[]): string {
231 return sha256Hex(messages.map((m) => `${m.id}:${m.content ?? ''}`).join('\n'))

Callers 1

chunkMessagesFunction · 0.85

Calls 2

isSemanticVoidFunction · 0.85
formatTimeRangeFunction · 0.70

Tested by

no test coverage detected