


























@@ -150,7 +150,7 @@ describe("createConfiguredOllamaCompatStreamWrapper", () => {
150150);
151151});
152152153-it("forwards think=true on native Ollama chat requests when thinking is enabled", async () => {
153+it("forwards the native think effort on native Ollama chat requests when thinking is enabled", async () => {
154154await withMockNdjsonFetch(
155155[
156156'{"model":"m","created_at":"t","message":{"role":"assistant","content":"ok"},"done":false}',
@@ -193,10 +193,63 @@ describe("createConfiguredOllamaCompatStreamWrapper", () => {
193193throw new Error("Expected string request body");
194194}
195195const requestBody = JSON.parse(requestInit.body) as {
196-think?: boolean;
197-options?: { think?: boolean; num_ctx?: number };
196+think?: boolean | string;
197+options?: { think?: boolean | string; num_ctx?: number };
198+};
199+expect(requestBody.think).toBe("low");
200+expect(requestBody.options?.think).toBeUndefined();
201+expect(requestBody.options?.num_ctx).toBe(131072);
202+},
203+);
204+});
205+206+it("maps native Ollama max thinking to think=high on the wire", async () => {
207+await withMockNdjsonFetch(
208+[
209+'{"model":"m","created_at":"t","message":{"role":"assistant","content":"ok"},"done":false}',
210+'{"model":"m","created_at":"t","message":{"role":"assistant","content":""},"done":true,"prompt_eval_count":1,"eval_count":1}',
211+],
212+async (fetchMock) => {
213+const baseStreamFn = createOllamaStreamFn("http://ollama-host:11434");
214+const model = {
215+api: "ollama",
216+provider: "ollama",
217+id: "gpt-oss:20b",
218+contextWindow: 131072,
219+};
220+221+const wrapped = createConfiguredOllamaCompatStreamWrapper({
222+provider: "ollama",
223+modelId: "gpt-oss:20b",
224+ model,
225+streamFn: baseStreamFn,
226+thinkingLevel: "max",
227+} as never);
228+if (!wrapped) {
229+throw new Error("Expected wrapped Ollama stream function");
230+}
231+232+const stream = await Promise.resolve(
233+wrapped(
234+model as never,
235+{
236+messages: [{ role: "user", content: "hello" }],
237+} as never,
238+{} as never,
239+),
240+);
241+242+await collectStreamEvents(stream);
243+244+const requestInit = getGuardedFetchCall(fetchMock).init ?? {};
245+if (typeof requestInit.body !== "string") {
246+throw new Error("Expected string request body");
247+}
248+const requestBody = JSON.parse(requestInit.body) as {
249+think?: boolean | string;
250+options?: { think?: boolean | string; num_ctx?: number };
198251};
199-expect(requestBody.think).toBe(true);
252+expect(requestBody.think).toBe("high");
200253expect(requestBody.options?.think).toBeUndefined();
201254expect(requestBody.options?.num_ctx).toBe(131072);
202255},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。