Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): have the model read search results before answering from them

Elian Doran53d5b6b5eab2
diff --git a/packages/trilium-core/src/services/llm/web_search.spec.ts b/packages/trilium-core/src/services/llm/web_search.spec.ts
index e4b99ac781..f588e14b8e 100644
--- a/packages/trilium-core/src/services/llm/web_search.spec.ts
+++ b/packages/trilium-core/src/services/llm/web_search.spec.ts
@@ -177,6 +177,7 @@ describe("createWebSearchTool", () => {
it("returns the query, the provider that ran it and its sources", async () => {
const tool = createWebSearchTool({ provider: "tavily", name: "My Tavily", apiKey: "tk" });
+ expect(tool.description).toContain("read_web_page");
respond({ results: [ { ...PAGE, content: "Hit" } ] });
expect(await run(tool, "trilium")).toEqual({
diff --git a/packages/trilium-core/src/services/llm/web_search.ts b/packages/trilium-core/src/services/llm/web_search.ts
index 29076d98b2..9b07ffda48 100644
--- a/packages/trilium-core/src/services/llm/web_search.ts
+++ b/packages/trilium-core/src/services/llm/web_search.ts
@@ -40,7 +40,9 @@ const SEARCH_TIMEOUT_MS = 30_000;
*/
export function createWebSearchTool(setup: WebSearchSetup) {
return tool({
- description: "Search the web for current information. Returns the title, URL and an excerpt of each matching page.",
+ description: "Search the web for current information. Returns the title, URL and a short excerpt of each matching page. "
+ + "The excerpts rarely hold specific facts such as numbers, dates or versions, so before answering a factual "
+ + "question, read the most promising results with read_web_page instead of answering from the excerpts.",
inputSchema: z.object({
query: z.string().describe("The search query")
}),