aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-07-03 10:46:08 -0400
committerbobzel <zzzman@gmail.com>2025-07-03 10:46:08 -0400
commit8299e24ccd64987cb898cae74622d5bb06d9e538 (patch)
tree6d461b7bcb9271091bd30210c7622101c045e6af /src/client/views/nodes/chatbot/tools
parentc32e8f3ab21088df872d836b7eb033f4eff8d73c (diff)
fixed creating docs with ai tool to allow options to be specified.
Diffstat (limited to 'src/client/views/nodes/chatbot/tools')
-rw-r--r--src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts18
1 files changed, 14 insertions, 4 deletions
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<Parameter> = [
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<DocumentMetadataToolParamsTyp
const docType = String(args.doc_type);
const title = String(args.title);
const data = String(args.data);
+ const json = typeof args.fieldEdits === 'string' ? JSON.parse(args.fieldEdits) : {};
+ const docopts = json.length
+ ? (json as Array<{ fieldName: string; fieldValue: string | number | boolean }>).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<DocumentMetadataToolParamsTyp
Document ID: ${id}
Type: ${docType}
Title: "${title}"
+Options: ${JSON.stringify(OmitKeys(args, ['doc_type', 'data', 'title']).omit, null, 2)}
The document has been created with default dimensions and positioning.
You can now use the "edit" action to modify additional properties of this document.