Enable automatic web search by default; improve toggle behavior and search planning.
CI / check (22) (push) Successful in 9m35s
CI / check (24) (push) Successful in 9m34s

This commit is contained in:
2026-10-06 08:50:03 +02:00
parent 674abf78f6
commit 7be654af11
17 changed files with 300 additions and 54 deletions
+5
View File
@@ -5,6 +5,7 @@ import test from "node:test";
import assert from "node:assert/strict";
import {createServer} from "node:http";
import {createApp} from "../src/app.js";
import {decideWebSearch} from "../src/services/webSearchService.js";
// Controlled protocol fixtures, not claims about real-world events or statistics.
const lifespan = {title: "Life expectancy estimates 2026", url: "https://health.example/2026", content: "The 2026 life expectancy estimate in this test dataset is 74 years."};
@@ -44,6 +45,10 @@ test("explicit/date searches ground the actual Ollama stream before any generati
eventLoopLagMonitorEnabled: false, structuredRequestLoggingEnabled: false, slowRequestLoggingEnabled: false
}, modelOverrides: {fetch: async (_url, options) => {
const body = JSON.parse(options.body);
if (body.format?.properties?.search) {
const {message} = JSON.parse(body.messages.at(-1).content);
return new Response(JSON.stringify({message: {content: JSON.stringify({search: decideWebSearch(message).shouldSearch, query: message})}, done: true}));
}
modelRequests.push(body);
if (expectedSearch) assert.equal(retrieved, true, "Search must finish before Ollama starts");
const chunks = [