| 199 | } |
| 200 | |
| 201 | private embedChunksAsync(chunkIds: string[], chunks: Array<{ id: string; summary?: string; content?: string }>): void { |
| 202 | const embedder = this.opts.embedder; |
| 203 | if (!embedder) return; |
| 204 | const texts = chunks.map(c => c.summary || (c.content ? c.content.slice(0, 500) : "")); |
| 205 | embedder.embed(texts).then((vectors) => { |
| 206 | for (let i = 0; i < vectors.length; i++) { |
| 207 | if (vectors[i]) { |
| 208 | this.opts.store.upsertHubEmbedding(chunkIds[i], new Float32Array(vectors[i])); |
| 209 | } |
| 210 | } |
| 211 | this.opts.log.info(`hub: embedded ${vectors.filter(Boolean).length}/${chunkIds.length} shared chunks`); |
| 212 | }).catch((err) => { |
| 213 | this.opts.log.warn(`hub: embedding shared chunks failed: ${err}`); |
| 214 | }); |
| 215 | } |
| 216 | |
| 217 | private embedSkillAsync(skillId: string, name: string, description: string, sourceUserId: string, sourceSkillId: string): void { |
| 218 | const embedder = this.opts.embedder; |