MCPcopy Create free account
hub / github.com/MemTensor/MemOS / embedChunksAsync

Method embedChunksAsync

packages/memos-core/src/hub/server.ts:201–215  ·  view source on GitHub ↗
(chunkIds: string[], chunks: Array<{ id: string; summary?: string; content?: string }>)

Source from the content-addressed store, hash-verified

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;

Callers 1

handleMethod · 0.95

Calls 6

mapMethod · 0.80
filterMethod · 0.80
embedMethod · 0.65
infoMethod · 0.65
warnMethod · 0.65
upsertHubEmbeddingMethod · 0.45

Tested by

no test coverage detected