diff options
| author | Adam Malczewski <[email protected]> | 2026-03-29 17:51:22 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-03-29 17:51:22 +0900 |
| commit | 73c25761f6b879d78ebd8ecddac35881848831db (patch) | |
| tree | 10c3e7e585e44dbd38aeef07295c39d93c9d1fec /src/ollama-client.ts | |
| parent | e8d107e454b3804e089a33ce5fe7c931040d4647 (diff) | |
| download | ai-pulse-obsidian-plugin-73c25761f6b879d78ebd8ecddac35881848831db.tar.gz ai-pulse-obsidian-plugin-73c25761f6b879d78ebd8ecddac35881848831db.zip | |
Diffstat (limited to 'src/ollama-client.ts')
| -rw-r--r-- | src/ollama-client.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ollama-client.ts b/src/ollama-client.ts index b778798..f86e5e7 100644 --- a/src/ollama-client.ts +++ b/src/ollama-client.ts @@ -2,6 +2,7 @@ import { Platform, requestUrl, TFile } from "obsidian"; import type { App } from "obsidian"; import type { OllamaToolDefinition } from "./tools"; import { findToolByName } from "./tools"; +import { hasCurrentAttachments } from "./image-attachments"; import systemPromptData from "./context/system-prompt.json"; import markdownRulesData from "./context/obsidian-markdown-rules.json"; @@ -293,6 +294,8 @@ function preValidateTool( return preValidateBatchMoveFile(app, args); case "batch_set_frontmatter": return preValidateBatchSetFrontmatter(app, args); + case "save_image": + return preValidateSaveImage(args); default: return null; } @@ -401,6 +404,19 @@ function preValidateSetFrontmatter(app: App, args: Record<string, unknown>): str return null; } +function preValidateSaveImage(args: Record<string, unknown>): string | null { + const filePath = typeof args["file_path"] === "string" ? args["file_path"] : ""; + if (filePath === "") { + return "Error: file_path parameter is required."; + } + + if (!hasCurrentAttachments()) { + return "Error: No images are attached to the current message. The user must attach images before you can save them."; + } + + return null; +} + // -- Batch tool validators ----------------------------------------------------- function preValidateBatchEditFile(app: App, args: Record<string, unknown>): string | null { |
