(memoryId: string, summary: string, content: string)
| 256 | } |
| 257 | |
| 258 | private embedMemoryAsync(memoryId: string, summary: string, content: string): void { |
| 259 | const embedder = this.opts.embedder; |
| 260 | if (!embedder) return; |
| 261 | const text = (summary || content || "").slice(0, 500); |
| 262 | if (!text) return; |
| 263 | embedder.embed([text]).then((vectors) => { |
| 264 | if (vectors[0]) { |
| 265 | this.opts.store.upsertHubMemoryEmbedding(memoryId, new Float32Array(vectors[0])); |
| 266 | this.opts.log.info(`hub: embedded shared memory ${memoryId}`); |
| 267 | } |
| 268 | }).catch((err) => { |
| 269 | this.opts.log.warn(`hub: embedding shared memory failed: ${err}`); |
| 270 | }); |
| 271 | } |
| 272 | |
| 273 | private async handle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> { |
| 274 | const url = new URL(req.url || "/", `http://127.0.0.1:${this.port}`); |
no test coverage detected