refactor(memory): consolidate embeddings and batch helpers

This commit is contained in:
Peter Steinberger
2026-02-17 00:10:32 +00:00
parent 423b7a0f28
commit 9bfd3ca195
11 changed files with 443 additions and 423 deletions

View File

@@ -0,0 +1,21 @@
export async function fetchRemoteEmbeddingVectors(params: {
url: string;
headers: Record<string, string>;
body: unknown;
errorPrefix: string;
}): Promise<number[][]> {
const res = await fetch(params.url, {
method: "POST",
headers: params.headers,
body: JSON.stringify(params.body),
});
if (!res.ok) {
const text = await res.text();
throw new Error(`${params.errorPrefix}: ${res.status} ${text}`);
}
const payload = (await res.json()) as {
data?: Array<{ embedding?: number[] }>;
};
const data = payload.data ?? [];
return data.map((entry) => entry.embedding ?? []);
}