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

Method embedBatch

packages/memos-core/src/embedding/index.ts:50–87  ·  view source on GitHub ↗
(texts: string[])

Source from the content-addressed store, hash-verified

48 }
49
50 private async embedBatch(texts: string[]): Promise<number[][]> {
51 const provider = this.provider;
52 const cfg = this.cfg;
53
54 const modelInfo = `${provider}/${cfg?.model ?? "default"}`;
55 try {
56 let result: number[][];
57 switch (provider) {
58 case "openai":
59 case "openai_compatible":
60 case "azure_openai":
61 case "zhipu":
62 case "siliconflow":
63 case "bailian":
64 result = await embedOpenAI(texts, cfg!, this.log); break;
65 case "gemini":
66 result = await embedGemini(texts, cfg!, this.log); break;
67 case "cohere":
68 result = await embedCohere(texts, cfg!, this.log); break;
69 case "mistral":
70 result = await embedMistral(texts, cfg!, this.log); break;
71 case "voyage":
72 result = await embedVoyage(texts, cfg!, this.log); break;
73 case "local":
74 default:
75 result = await embedLocal(texts, this.log); break;
76 }
77 modelHealth.recordSuccess("embedding", modelInfo);
78 return result;
79 } catch (err) {
80 modelHealth.recordError("embedding", modelInfo, String(err));
81 if (provider !== "local") {
82 this.log.warn(`Embedding provider '${provider}' failed, falling back to local: ${err}`);
83 return await embedLocal(texts, this.log);
84 }
85 throw err;
86 }
87 }
88
89 private async embedOpenClaw(texts: string[]): Promise<number[][]> {
90 if (!this.openclawAPI) {

Callers 2

embedMethod · 0.95
embedQueryMethod · 0.95

Calls 9

embedOpenAIFunction · 0.90
embedGeminiFunction · 0.90
embedCohereFunction · 0.90
embedMistralFunction · 0.90
embedVoyageFunction · 0.90
embedLocalFunction · 0.90
recordSuccessMethod · 0.65
warnMethod · 0.65
recordErrorMethod · 0.45

Tested by

no test coverage detected