From 8299e24ccd64987cb898cae74622d5bb06d9e538 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 3 Jul 2025 10:46:08 -0400 Subject: fixed creating docs with ai tool to allow options to be specified. --- .../views/nodes/chatbot/tools/DocumentMetadataTool.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/client/views/nodes/chatbot/tools') diff --git a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts index da4a4ae29..fd44cc60f 100644 --- a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts +++ b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts @@ -1,3 +1,5 @@ +import { OmitKeys } from '../../../../../ClientUtils'; +import { DocumentOptions } from '../../../../documents/Documents'; import { Parameter, ParametersType, supportedDocTypes, ToolInfo } from '../types/tool_types'; import { Observation } from '../types/types'; import { AgentDocumentManager } from '../utils/AgentDocumentManager'; @@ -21,8 +23,7 @@ const parameterDefinitions: ReadonlyArray = [ name: 'fieldEdits', type: 'string', required: false, - description: - 'JSON array of field edits for editing fields. Each item should have fieldName and fieldValue. For single field edits, use an array with one item. Example: [{"fieldName":"layout_autoHeight","fieldValue":false},{"fieldName":"height","fieldValue":300}]', + description: `JSON array of field edits for editing fields. Each item should have fieldName and fieldValue. For single field edits, use an array with one item. fieldName values MUST be in this list: [${Object.keys(DocumentOptions)}]. Example: [{"fieldName":"layout_autoHeight","fieldValue":false},{"fieldName":"height","fieldValue":300}]`, }, { name: 'title', @@ -402,7 +403,8 @@ To CREATE a new document: - title: The title of the document to create - data: The content data for the document (text content, URL, etc.) - doc_type: The type of document to create (text, web, image, etc.) -- Example: {...inputs: { action: "create", title: "My Notes", data: "This is the content", doc_type: "text" }} + - fieldEdits: Optional JSON array of fields to set during creation +- Example: {...inputs: { action: "create", title: "My Notes", data: "This is the content", doc_type: "text", fieldEdits: [{ fieldName: "text", fieldValue: "Hello world" }] }} - After creation, you can edit the document with more specific properties To EDIT document metadata: @@ -694,8 +696,15 @@ export class DocumentMetadataTool extends BaseTool).reduce((opts, opt) => { + opts[opt.fieldName] = opt.fieldValue; + return opts; + }, {} as DocumentOptions) + : {}; - const id = await this._docManager.createDocInDash(docType, data, { title: title }); + const id = await this._docManager.createDocInDash(docType, data, docopts); if (!id) { return [ @@ -715,6 +724,7 @@ export class DocumentMetadataTool extends BaseTool