Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): name the attachments DeepSeek cannot read instead of dropping them

Elian Doran9b686aedc2c5
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html
index 2732c06f62..89c8209c80 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html
@@ -247,6 +247,9 @@ class="admonition note">
<li>SVG images (sent as raw HTML).</li>
<li>Text files.</li>
</ul>
+<p>A model that can't read an attachment receives only its name, such as <code>[attached file: report.pdf]</code>,
+ so it can tell you it doesn't see the content. DeepSeek reads no PDFs,
+ and images only with its vision models.</p>
<p>To upload an attachment:</p>
<ul>
<li>Press the dedicated <em>Attach</em> button (paperclip icon) underneath the
diff --git a/apps/server/src/services/llm/providers/acp_agent.ts b/apps/server/src/services/llm/providers/acp_agent.ts
index 878ab707ab..dab1e7d2e4 100644
--- a/apps/server/src/services/llm/providers/acp_agent.ts
+++ b/apps/server/src/services/llm/providers/acp_agent.ts
@@ -21,7 +21,7 @@
import { LLM_REASONING_EFFORTS, type LlmMessage, type LlmMessagePart, type LlmReasoningEffort, type LlmStreamChunk } from "@triliumnext/commons";
import { getLog } from "@triliumnext/core";
-import { resolveAttachmentPart } from "@triliumnext/core/src/services/llm/attachment_content.js";
+import { attachmentPlaceholder, resolveAttachmentPart } from "@triliumnext/core/src/services/llm/attachment_content.js";
import { buildNoteHint } from "@triliumnext/core/src/services/llm/note_hint.js";
import { buildSystemPrompt } from "@triliumnext/core/src/services/llm/system_prompt.js";
import type { LlmProvider, LlmProviderConfig, ModelInfo, ModelPricing, StreamResult } from "@triliumnext/core/src/services/llm/types.js";
@@ -33,7 +33,7 @@ import dataDirs from "../../data_dir.js";
import { AcpClient, AcpError } from "./acp_client.js";
import { AcpClientPool, type AcpLease, type AcpPoolConnection } from "./acp_client_pool.js";
import { getAcpMcpEndpointUrl } from "./acp_mcp_endpoint.js";
-import { attachmentPlaceholder, buildHistoryReplay, hashTranscript } from "./transcript.js";
+import { buildHistoryReplay, hashTranscript } from "./transcript.js";
/** How an ACP provider starts its agent subprocess. */
export interface AcpLaunchSpec {
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
index 4a66e5fae3..7ca487904e 100644
--- a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
+++ b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
@@ -29,7 +29,10 @@ vi.mock("./acp_hook.js", async (importOriginal) => ({
resolveCurlPath: async () => "/usr/bin/curl"
}));
vi.mock("@triliumnext/core/src/services/llm/note_hint.js", () => ({ buildNoteHint: () => null }));
-vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", () => ({ resolveAttachmentPart: vi.fn() }));
+vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@triliumnext/core/src/services/llm/attachment_content.js")>(),
+ resolveAttachmentPart: vi.fn()
+}));
class FakeAcpError extends Error {
constructor(public readonly code: number, message: string) {
diff --git a/apps/server/src/services/llm/providers/claude_agent.spec.ts b/apps/server/src/services/llm/providers/claude_agent.spec.ts
index b1477e3c03..82465ded35 100644
--- a/apps/server/src/services/llm/providers/claude_agent.spec.ts
+++ b/apps/server/src/services/llm/providers/claude_agent.spec.ts
@@ -46,7 +46,10 @@ vi.mock("./claude_binary.js", () => ({ resolveClaudeBinaryPath: resolveClaudeBin
// Attachment resolution reads bytes out of Becca, which the core mock above
// omits — stub it so the multimodal tests drive block construction directly.
const resolveAttachmentPartMock = vi.hoisted(() => vi.fn());
-vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", () => ({ resolveAttachmentPart: resolveAttachmentPartMock }));
+vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@triliumnext/core/src/services/llm/attachment_content.js")>(),
+ resolveAttachmentPart: resolveAttachmentPartMock
+}));
// The Windows `.cmd` shim delegates to child_process.spawn; the provider never
// spawns otherwise, so mocking the whole module is safe.
diff --git a/apps/server/src/services/llm/providers/claude_agent.ts b/apps/server/src/services/llm/providers/claude_agent.ts
index 4028b14a10..e9f71bdb43 100644
--- a/apps/server/src/services/llm/providers/claude_agent.ts
+++ b/apps/server/src/services/llm/providers/claude_agent.ts
@@ -24,7 +24,7 @@ import type { Options as AgentOptions, query as queryFn, SDKAssistantMessage, SD
import type { ContentBlockParam } from "@anthropic-ai/sdk/resources";
import type { LlmMessage, LlmMessagePart, LlmStreamChunk } from "@triliumnext/commons";
import { getLog } from "@triliumnext/core";
-import { resolveAttachmentPart } from "@triliumnext/core/src/services/llm/attachment_content.js";
+import { attachmentPlaceholder, resolveAttachmentPart } from "@triliumnext/core/src/services/llm/attachment_content.js";
import { buildNoteHint } from "@triliumnext/core/src/services/llm/note_hint.js";
import { anthropicRecommendedIds } from "@triliumnext/core/src/services/llm/providers/anthropic.js";
import { buildModelList, mergeModelLists, type RemoteModel } from "@triliumnext/core/src/services/llm/providers/base_provider.js";
@@ -46,7 +46,7 @@ import {
rememberSession as rememberWarmSession,
takeWarmSession
} from "./claude_session_pool.js";
-import { attachmentPlaceholder, buildHistoryReplay, flattenContent, hashTranscript } from "./transcript.js";
+import { buildHistoryReplay, flattenContent, hashTranscript } from "./transcript.js";
// Re-exported for existing importers (specs, siblings); the implementations
// now live in the shared transcript module.
diff --git a/apps/server/src/services/llm/providers/codex_agent.spec.ts b/apps/server/src/services/llm/providers/codex_agent.spec.ts
index 52a4869357..cdf04f8a33 100644
--- a/apps/server/src/services/llm/providers/codex_agent.spec.ts
+++ b/apps/server/src/services/llm/providers/codex_agent.spec.ts
@@ -31,7 +31,10 @@ vi.mock("./acp_hook.js", async (importOriginal) => ({
resolveCurlPath: async () => "/usr/bin/curl"
}));
vi.mock("@triliumnext/core/src/services/llm/note_hint.js", () => ({ buildNoteHint: () => null }));
-vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", () => ({ resolveAttachmentPart: vi.fn() }));
+vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@triliumnext/core/src/services/llm/attachment_content.js")>(),
+ resolveAttachmentPart: vi.fn()
+}));
class FakeAcpError extends Error {
constructor(public readonly code: number, message: string) {
diff --git a/apps/server/src/services/llm/providers/copilot_agent.spec.ts b/apps/server/src/services/llm/providers/copilot_agent.spec.ts
index f5d987a003..86f2501a47 100644
--- a/apps/server/src/services/llm/providers/copilot_agent.spec.ts
+++ b/apps/server/src/services/llm/providers/copilot_agent.spec.ts
@@ -33,7 +33,10 @@ const buildNoteHintMock = vi.hoisted(() => vi.fn((noteId: string): string | null
vi.mock("@triliumnext/core/src/services/llm/note_hint.js", () => ({ buildNoteHint: buildNoteHintMock }));
const resolveAttachmentPartMock = vi.hoisted(() => vi.fn());
-vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", () => ({ resolveAttachmentPart: resolveAttachmentPartMock }));
+vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", async (importOriginal) => ({
+ ...await importOriginal<typeof import("@triliumnext/core/src/services/llm/attachment_content.js")>(),
+ resolveAttachmentPart: resolveAttachmentPartMock
+}));
// A scriptable fake ACP client. `AcpClient.start` returns the active instance;
// each test scripts what `session/prompt` streams via onNotification and what
diff --git a/apps/server/src/services/llm/providers/transcript.ts b/apps/server/src/services/llm/providers/transcript.ts
index d60a76b6b7..92b4aa364c 100644
--- a/apps/server/src/services/llm/providers/transcript.ts
+++ b/apps/server/src/services/llm/providers/transcript.ts
@@ -6,7 +6,8 @@
* reseed a fresh session when it doesn't (replay).
*/
-import type { LlmFilePart, LlmImagePart, LlmMessage, LlmMessagePart, LlmTextAttachmentPart } from "@triliumnext/commons";
+import type { LlmMessage, LlmMessagePart } from "@triliumnext/commons";
+import { attachmentPlaceholder } from "@triliumnext/core/src/services/llm/attachment_content.js";
import { createHash } from "crypto";
/**
@@ -44,10 +45,3 @@ export function flattenContent(content: string | LlmMessagePart[]): string {
.map(part => (part.type === "text" ? part.text : attachmentPlaceholder(part)))
.join("\n");
}
-
-/** Short "[attached …]" stand-in used wherever an attachment's bytes aren't sent. */
-export function attachmentPlaceholder(part: LlmImagePart | LlmFilePart | LlmTextAttachmentPart): string {
- const kind = part.type === "image" ? "image" : "file";
- const name = "filename" in part ? `: ${part.filename}` : "";
- return `[attached ${kind}${name}]`;
-}
diff --git a/docs/User Guide/User Guide/AI.md b/docs/User Guide/User Guide/AI.md
index 77e526728e..ad49a4a7cd 100644
--- a/docs/User Guide/User Guide/AI.md
+++ b/docs/User Guide/User Guide/AI.md
@@ -153,6 +153,8 @@ Since Trilium v0.140.0, <a class="reference-link" href="Basic%20Concepts%20and%
* SVG images (sent as raw HTML).
* Text files.
+A model that can't read an attachment receives only its name, such as `[attached file: report.pdf]`, so it can tell you it doesn't see the content. DeepSeek reads no PDFs, and images only with its vision models.
+
To upload an attachment:
* Press the dedicated _Attach_ button (paperclip icon) underneath the text box.
diff --git a/packages/trilium-core/src/services/llm/attachment_content.ts b/packages/trilium-core/src/services/llm/attachment_content.ts
index 5ad1284365..1a667490db 100644
--- a/packages/trilium-core/src/services/llm/attachment_content.ts
+++ b/packages/trilium-core/src/services/llm/attachment_content.ts
@@ -9,7 +9,7 @@
* path then maps the neutral result into its own SDK's block shape.
*/
-import type { LlmMessagePart } from "@triliumnext/commons";
+import type { LlmFilePart, LlmImagePart, LlmMessagePart, LlmTextAttachmentPart } from "@triliumnext/commons";
import becca from "../../becca/becca.js";
import { getLog } from "../../services/log.js";
import { decodeUtf8 } from "../../services/utils/binary.js";
@@ -69,6 +69,13 @@ export function resolveAttachmentPart(part: LlmMessagePart): ResolvedAttachment
}
}
+/** Short "[attached …]" stand-in used wherever an attachment's bytes aren't sent. */
+export function attachmentPlaceholder(part: LlmImagePart | LlmFilePart | LlmTextAttachmentPart): string {
+ const kind = part.type === "image" ? "image" : "file";
+ const name = "filename" in part ? `: ${part.filename}` : "";
+ return `[attached ${kind}${name}]`;
+}
+
function wrapFile(filename: string, text: string): string {
return `<file name="${filename}">\n${text}\n</file>`;
}
diff --git a/packages/trilium-core/src/services/llm/providers/base_provider.spec.ts b/packages/trilium-core/src/services/llm/providers/base_provider.spec.ts
index e9fd8c84ae..e7e2ccc53a 100644
--- a/packages/trilium-core/src/services/llm/providers/base_provider.spec.ts
+++ b/packages/trilium-core/src/services/llm/providers/base_provider.spec.ts
@@ -98,7 +98,7 @@ class TestProvider extends BaseProvider {
return this.applyNoteHint(m, c);
}
public callBuildMessages(m: LlmMessage[]) {
- return this.buildMessages(m);
+ return this.buildMessages(m, "mid");
}
/** Reach the base implementation past this class's own override. */
public callBaseFetchRemoteModels() {
@@ -373,6 +373,25 @@ describe("buildModelMessage", () => {
expect(part.text).toContain("<svg/>");
});
+ it("names an attachment the filter rejects, but still inlines an SVG, which is text", () => {
+ beccaStub.getAttachment.mockImplementation((id: string) => makeAttachment(id === "svg1"
+ ? { mime: "image/svg+xml", title: "d.svg", getContent: () => encodeUtf8("<svg/>") }
+ : { mime: id === "f1" ? "application/pdf" : "image/png" }));
+ const msg = buildModelMessage({
+ role: "user",
+ content: [
+ { type: "image", attachmentId: "a1", mime: "image/png" },
+ { type: "file", attachmentId: "f1", mime: "application/pdf", filename: "doc.pdf" },
+ { type: "image", attachmentId: "svg1", mime: "image/svg+xml" }
+ ]
+ }, () => false);
+ const parts = msg.content as any[];
+ expect(parts.map(p => p.type)).toEqual(["text", "text", "text"]);
+ expect(parts[0].text).toContain("[attached image]");
+ expect(parts[1].text).toContain("[attached file: doc.pdf]");
+ expect(parts[2].text).toContain("<svg/>");
+ });
+
it("resolves a file attachment, using part overrides for mime and filename", () => {
beccaStub.getAttachment.mockReturnValue(makeAttachment({ mime: "application/octet-stream", title: "fallback" }));
const msg = buildModelMessage({
diff --git a/packages/trilium-core/src/services/llm/providers/base_provider.ts b/packages/trilium-core/src/services/llm/providers/base_provider.ts
index 3c5b3832aa..94b4c44131 100644
--- a/packages/trilium-core/src/services/llm/providers/base_provider.ts
+++ b/packages/trilium-core/src/services/llm/providers/base_provider.ts
@@ -7,7 +7,7 @@ import { type LlmMessage, type LlmMessagePart } from "@triliumnext/commons";
import { type FilePart, generateText, type ImagePart, type LanguageModel, type ModelMessage, stepCountIs, streamText, type SystemModelMessage, type TextPart, type ToolSet } from "ai";
import { getLog } from "../../log.js";
-import { resolveAttachmentPart } from "../attachment_content.js";
+import { attachmentPlaceholder, resolveAttachmentPart } from "../attachment_content.js";
import { llmFetch } from "./fetch.js";
import { buildNoteHint } from "../note_hint.js";
import { buildSystemPrompt as composeSystemPrompt } from "../system_prompt.js";
@@ -94,11 +94,15 @@ const MODEL_LIST_TIMEOUT_MS = 10_000;
* the provider-neutral {@link resolveAttachmentPart} result into `ai`'s block
* shapes. Returns null (and the caller drops the part) when it can't resolve.
*/
-function resolveMessagePart(part: LlmMessagePart): TextPart | ImagePart | FilePart | null {
+function resolveMessagePart(part: LlmMessagePart, accepts: AttachmentFilter): TextPart | ImagePart | FilePart | null {
const resolved = resolveAttachmentPart(part);
if (!resolved) {
return null;
}
+ if (resolved.kind !== "text" && part.type !== "text" && !accepts(resolved.kind)) {
+ // Text parts can be joined with no separator (`@ai-sdk/deepseek` does), so the placeholder carries its own line breaks.
+ return { type: "text", text: `\n${attachmentPlaceholder(part)}\n` };
+ }
switch (resolved.kind) {
case "text":
return { type: "text", text: resolved.text };
@@ -109,17 +113,21 @@ function resolveMessagePart(part: LlmMessagePart): TextPart | ImagePart | FilePa
}
}
+/** Whether a model reads an attachment of this kind natively. Text attachments are always inlined. */
+export type AttachmentFilter = (kind: "image" | "file") => boolean;
+
/**
* Build a single ModelMessage from an LlmMessage. Plain string content stays
- * as-is; multimodal content is resolved into AI SDK text/image/file parts.
+ * as-is; multimodal content is resolved into AI SDK text/image/file parts, and
+ * an attachment `accepts` rejects becomes an `[attached …]` placeholder.
*/
-export function buildModelMessage(m: LlmMessage): ModelMessage {
+export function buildModelMessage(m: LlmMessage, accepts: AttachmentFilter = () => true): ModelMessage {
const role = m.role as "user" | "assistant";
if (typeof m.content === "string") {
return { role, content: m.content };
}
const resolved = m.content
- .map(resolveMessagePart)
+ .map(part => resolveMessagePart(part, accepts))
.filter((p): p is TextPart | ImagePart | FilePart => p !== null);
// Assistant turns can only carry TextParts (per the AI SDK type), so
// strip any stray attachments — they only make sense on user turns anyway.
@@ -316,8 +324,16 @@ export abstract class BaseProvider implements LlmProvider {
* separately via the `system` option of `streamText` (see `buildSystemMessage`),
* which is resilient against prompt injection.
*/
- protected buildMessages(chatMessages: LlmMessage[]): ModelMessage[] {
- return chatMessages.map(m => buildModelMessage(m));
+ protected buildMessages(chatMessages: LlmMessage[], modelId: string): ModelMessage[] {
+ return chatMessages.map(m => buildModelMessage(m, kind => this.acceptsAttachment(kind, modelId)));
+ }
+
+ /**
+ * Whether `modelId` reads an image or file attachment natively. One it doesn't is sent as an
+ * `[attached …]` placeholder, so the model knows something was attached instead of never seeing it.
+ */
+ protected acceptsAttachment(_kind: "image" | "file", _modelId: string): boolean {
+ return true;
}
/**
@@ -397,10 +413,11 @@ export abstract class BaseProvider implements LlmProvider {
chat(messages: LlmMessage[], config: LlmProviderConfig): StreamResult {
const systemPrompt = this.buildSystemPrompt(messages, config);
const chatMessages = this.applyNoteHint(messages.filter(m => m.role !== "system"), config);
- const coreMessages = this.buildMessages(chatMessages);
+ const modelId = config.model || this.defaultModel;
+ const coreMessages = this.buildMessages(chatMessages, modelId);
const streamOptions: Parameters<typeof streamText>[0] = {
- model: this.createModel(config.model || this.defaultModel),
+ model: this.createModel(modelId),
system: this.buildSystemMessage(systemPrompt),
messages: coreMessages,
maxOutputTokens: config.maxTokens || DEFAULT_MAX_TOKENS,
diff --git a/packages/trilium-core/src/services/llm/providers/deepseek.spec.ts b/packages/trilium-core/src/services/llm/providers/deepseek.spec.ts
index 227ff56b63..fa58a02354 100644
--- a/packages/trilium-core/src/services/llm/providers/deepseek.spec.ts
+++ b/packages/trilium-core/src/services/llm/providers/deepseek.spec.ts
@@ -17,6 +17,19 @@ vi.mock("@ai-sdk/deepseek", async (importOriginal) => {
};
});
+// Attachments resolve by kind rather than from Becca: an image part to PNG bytes, a file part to a PDF.
+vi.mock("../attachment_content.js", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("../attachment_content.js")>();
+ return {
+ ...actual,
+ resolveAttachmentPart: (part: { type: string; text?: string; filename?: string }) => {
+ if (part.type === "text") return { kind: "text", text: part.text };
+ if (part.type === "image") return { kind: "image", bytes: new Uint8Array([ 137, 80, 78, 71 ]), mime: "image/png" };
+ return { kind: "file", bytes: new Uint8Array([ 37, 80, 68, 70 ]), mime: "application/pdf", filename: part.filename };
+ }
+ };
+});
+
const { generateTextMock } = vi.hoisted(() => ({
generateTextMock: vi.fn(async () => ({ text: " A generated title " }) as any)
}));
@@ -26,7 +39,7 @@ vi.mock("ai", async (importOriginal) => {
return { ...actual, generateText: generateTextMock };
});
-import type { LlmStreamChunk } from "@triliumnext/commons";
+import type { LlmMessage, LlmStreamChunk } from "@triliumnext/commons";
import { installGlobalFetchAsApiTransport } from "../../../test/request_provider.js";
import { streamToChunks } from "../stream.js";
@@ -284,6 +297,48 @@ describe("DeepSeekProvider reasoning effort", () => {
});
});
+describe("DeepSeekProvider attachments", () => {
+ const fetchMock = vi.fn();
+
+ beforeEach(() => {
+ fetchMock.mockReset();
+ fetchMock.mockImplementation(async () => sseResponse([
+ { choices: [{ index: 0, delta: { role: "assistant", content: "Ok" }, finish_reason: "stop" }] }
+ ]));
+ vi.stubGlobal("fetch", fetchMock);
+ });
+
+ const messages: LlmMessage[] = [{ role: "user", content: [
+ { type: "text", text: "What is in these?" },
+ { type: "image", attachmentId: "img1", mime: "image/png" },
+ { type: "file", attachmentId: "pdf1", mime: "application/pdf", filename: "report.pdf" }
+ ] }];
+
+ async function sentUserContent(model: string) {
+ fetchMock.mockClear();
+ for await (const _ of streamToChunks(new DeepSeekProvider("sk-deep").chat(messages, { model }))) { /* drain */ }
+ expect(fetchMock).toHaveBeenCalledOnce();
+ const body = JSON.parse(String((fetchMock.mock.calls[0][1] as RequestInit).body));
+ return body.messages.find((m: { role: string }) => m.role === "user").content;
+ }
+
+ it("names what a text-only model cannot read instead of sending or dropping it", async () => {
+ const content = await sentUserContent("deepseek-v4-pro");
+ expect(typeof content).toBe("string");
+ expect(content).toContain("What is in these?");
+ expect(content).toContain("[attached image]");
+ expect(content).toContain("[attached file: report.pdf]");
+ });
+
+ it("sends images to the vision model, and names the PDF it cannot read", async () => {
+ const content = await sentUserContent("deepseek-v4-flash-vision-exp");
+ expect(content).toEqual(expect.arrayContaining([
+ expect.objectContaining({ type: "image_url" }),
+ expect.objectContaining({ type: "text", text: expect.stringContaining("[attached file: report.pdf]") })
+ ]));
+ });
+});
+
describe("DeepSeekProvider recommendations", () => {
it("pre-selects the current line but not the superseded coder models", () => {
const provider = new DeepSeekProvider("sk-deep");
diff --git a/packages/trilium-core/src/services/llm/providers/deepseek.ts b/packages/trilium-core/src/services/llm/providers/deepseek.ts
index a16acbb8c2..e53fb4f48a 100644
--- a/packages/trilium-core/src/services/llm/providers/deepseek.ts
+++ b/packages/trilium-core/src/services/llm/providers/deepseek.ts
@@ -77,6 +77,11 @@ export class DeepSeekProvider extends BaseProvider {
return { deepseek: options };
}
+ /** DeepSeek reads no PDFs, and images only on its vision models (`deepseek-v4-flash-vision-exp`). */
+ protected override acceptsAttachment(kind: "image" | "file", modelId: string): boolean {
+ return kind === "image" && modelId.includes("vision");
+ }
+
/** Everything DeepSeek lists is a chat model, so nothing is filtered out. */
protected override async fetchRemoteModels(): Promise<RemoteModel[] | null> {
const payload = await this.fetchJson(`${this.baseURL ?? OFFICIAL_BASE_URL}/models`, {
diff --git a/packages/trilium-core/src/services/llm/providers/google.ts b/packages/trilium-core/src/services/llm/providers/google.ts
index d3dbde16a5..fc61c5de1c 100644
--- a/packages/trilium-core/src/services/llm/providers/google.ts
+++ b/packages/trilium-core/src/services/llm/providers/google.ts
@@ -96,10 +96,11 @@ export class GoogleProvider extends BaseProvider {
const systemPrompt = this.buildSystemPrompt(messages, config);
const chatMessages = this.applyNoteHint(messages.filter(m => m.role !== "system"), config);
- const coreMessages = this.buildMessages(chatMessages);
+ const modelId = config.model || this.defaultModel;
+ const coreMessages = this.buildMessages(chatMessages, modelId);
const streamOptions: Parameters<typeof streamText>[0] = {
- model: this.createModel(config.model || this.defaultModel),
+ model: this.createModel(modelId),
system: this.buildSystemMessage(systemPrompt),
messages: coreMessages,
maxOutputTokens: config.maxTokens || 8096,