mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(embeddings): forward Gemini output dimensions (#1366)
Co-authored-by: GoClaw Operator <operator@goclaw>
This commit is contained in:
co-authored by
GoClaw Operator
parent
e1b821dd53
commit
7bc97eae7b
@@ -141,6 +141,51 @@ describe("buildEmbeddingsBody", () => {
|
||||
const sent = JSON.parse(init.body);
|
||||
expect(sent.encoding_format).toBe("float");
|
||||
});
|
||||
|
||||
it("gemini single input forwards dimensions as outputDimensionality", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(makeProviderResponse({
|
||||
embedding: { values: [0.1, 0.2, 0.3] },
|
||||
}));
|
||||
|
||||
await handleEmbeddingsCore(makeOptions({
|
||||
body: {
|
||||
model: "gemini/gemini-embedding-2-preview",
|
||||
input: "test",
|
||||
dimensions: 1536,
|
||||
},
|
||||
modelInfo: { provider: "gemini", model: "gemini-embedding-2-preview" },
|
||||
credentials: { apiKey: "gemini-key" },
|
||||
}));
|
||||
|
||||
const [, init] = vi.mocked(fetch).mock.calls[0];
|
||||
const sent = JSON.parse(init.body);
|
||||
expect(sent.outputDimensionality).toBe(1536);
|
||||
});
|
||||
|
||||
it("gemini batch input forwards dimensions on each request", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce(makeProviderResponse({
|
||||
embeddings: [
|
||||
{ values: [0.1, 0.2, 0.3] },
|
||||
{ values: [0.4, 0.5, 0.6] },
|
||||
],
|
||||
}));
|
||||
|
||||
await handleEmbeddingsCore(makeOptions({
|
||||
body: {
|
||||
model: "gemini/gemini-embedding-2-preview",
|
||||
input: ["hello", "world"],
|
||||
dimensions: 1536,
|
||||
},
|
||||
modelInfo: { provider: "gemini", model: "gemini-embedding-2-preview" },
|
||||
credentials: { apiKey: "gemini-key" },
|
||||
}));
|
||||
|
||||
const [, init] = vi.mocked(fetch).mock.calls[0];
|
||||
const sent = JSON.parse(init.body);
|
||||
expect(sent.requests).toHaveLength(2);
|
||||
expect(sent.requests[0].outputDimensionality).toBe(1536);
|
||||
expect(sent.requests[1].outputDimensionality).toBe(1536);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Test: buildEmbeddingsUrl ────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user