























@@ -89,6 +89,19 @@ async function postEmbeddings(body: unknown, headers?: Record<string, string>) {
8989});
9090}
919192+function latestCreateEmbeddingProviderOptions(): {
93+agentDir?: string;
94+model?: string;
95+provider?: string;
96+} {
97+const calls = createEmbeddingProviderMock.mock.calls;
98+const call = calls[calls.length - 1];
99+if (!call) {
100+throw new Error("expected embedding provider create call");
101+}
102+return call[0];
103+}
104+92105describe("OpenAI-compatible embeddings HTTP API (e2e)", () => {
93106it("embeds string and array inputs", async () => {
94107const single = await postEmbeddings({
@@ -127,11 +140,9 @@ describe("OpenAI-compatible embeddings HTTP API (e2e)", () => {
127140expect(qualified.status).toBe(200);
128141const qualifiedJson = (await qualified.json()) as { model?: string };
129142expect(qualifiedJson.model).toBe("openclaw/default");
130-const lastCall = createEmbeddingProviderMock.mock.calls.at(-1)?.[0] as
131-| { provider?: string; model?: string }
132-| undefined;
133-expect(lastCall?.provider).toBe("openai");
134-expect(lastCall?.model).toBe("text-embedding-3-small");
143+const lastCall = latestCreateEmbeddingProviderOptions();
144+expect(lastCall.provider).toBe("openai");
145+expect(lastCall.model).toBe("text-embedding-3-small");
135146});
136147137148it("supports base64 encoding and agent-scoped auth/config resolution", async () => {
@@ -147,11 +158,9 @@ describe("OpenAI-compatible embeddings HTTP API (e2e)", () => {
147158const json = (await res.json()) as { data?: Array<{ embedding?: string }> };
148159expect(typeof json.data?.[0]?.embedding).toBe("string");
149160expect(createEmbeddingProviderMock).toHaveBeenCalled();
150-const lastCall = createEmbeddingProviderMock.mock.calls.at(-1)?.[0] as
151-| { provider?: string; model?: string; agentDir?: string }
152-| undefined;
153-expect(typeof lastCall?.model).toBe("string");
154-expect(lastCall?.agentDir).toBe(resolveAgentDir({}, "beta"));
161+const lastCall = latestCreateEmbeddingProviderOptions();
162+expect(typeof lastCall.model).toBe("string");
163+expect(lastCall.agentDir).toBe(resolveAgentDir({}, "beta"));
155164});
156165157166it("rejects invalid input shapes", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。