fix(confidence-engine): use configured model for chat detection
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("OllamaLlmProvider chat capability detection", () => {
|
||||
it("uses the configured model for the chat probe and keeps the chat path", async () => {
|
||||
const originalBaseUrl = process.env.OLLAMA_BASE_URL;
|
||||
const fetchSpy = vi.fn()
|
||||
.mockResolvedValueOnce({ ok: true, body: { consume: vi.fn() } })
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ message: { content: "{}" } }),
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchSpy);
|
||||
process.env.OLLAMA_BASE_URL = "http://ollama.test";
|
||||
|
||||
try {
|
||||
const { getProvider } = await import("@/lib/llm/provider.js");
|
||||
await getProvider().generateReconstruction("prompt", "configured-model");
|
||||
|
||||
expect(JSON.parse(fetchSpy.mock.calls[0][1].body)).toMatchObject({
|
||||
model: "configured-model",
|
||||
stream: false,
|
||||
});
|
||||
expect(fetchSpy.mock.calls[0][0]).toBe("http://ollama.test/api/chat");
|
||||
expect(fetchSpy.mock.calls[1][0]).toBe("http://ollama.test/api/chat");
|
||||
expect(fetchSpy.mock.calls[1][0]).not.toContain("/api/generate");
|
||||
} finally {
|
||||
vi.unstubAllGlobals();
|
||||
if (originalBaseUrl === undefined) delete process.env.OLLAMA_BASE_URL;
|
||||
else process.env.OLLAMA_BASE_URL = originalBaseUrl;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user