diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts')
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts index e6c2421e5..5297292bf 100644 --- a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts +++ b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts @@ -18,13 +18,13 @@ const parameterDefinitions: ReadonlyArray<Parameter> = [ name: 'action', type: 'string', required: true, - description: 'The action to perform: "get" to retrieve metadata, "edit" to modify metadata, "list" to enumerate documents, "getFieldOptions" to retrieve all available field options, or "create" to create a new document', + description: 'The action to perform: "get" to retrieve metadata, "edit" to modify metadata, "getFieldOptions" to retrieve all available field options, or "create" to create a new document', }, { name: 'documentId', type: 'string', required: false, - description: 'The ID of the document to get or edit metadata for. Required for "edit", optional for "get", ignored for "list", "getFieldOptions", and "create"', + description: 'The ID of the document to get or edit metadata for. Required for "edit", optional for "get", ignored for "getFieldOptions", and "create"', }, { name: 'fieldEdits', @@ -68,7 +68,6 @@ This tool provides the following capabilities: - Get metadata from a specific document - Edit metadata fields on documents (in either layout or data documents) - Edit multiple fields at once (useful for updating dependent fields together) -- List all available documents in the current view - Retrieve all available field options with metadata (IMPORTANT: always call this before editing) - Understand which fields are stored where (layout vs data document) - Get detailed information about all available document fields @@ -137,8 +136,8 @@ SPECIAL FIELD HANDLING: - Width/Height: Set layout_autoHeight/layout_autoWidth to false before editing RECOMMENDED WORKFLOW: -1. First call action="list" to identify available documents -2. Then call action="getFieldOptions" to understand available fields +0. Understand the currently available documents that were provided as <available_documents> in the prompt +1. Call action="getFieldOptions" to understand available fields 3. Get document metadata with action="get" to see current values 4. Edit fields with action="edit" using proper dependencies OR @@ -159,10 +158,6 @@ HANDLING DEPENDENT FIELDS: - width → layout_autoWidth (set to false to allow manual width) - Other auto-sizing related properties -To LIST available documents: -- Use action="list" to get a simple list of all documents in the current view -- This is useful when you need to identify documents before getting details or editing them - Editing fields follows these rules: 1. First checks if the field exists on the layout document using Doc.Get 2. If it exists on the layout document, it's updated there @@ -172,7 +167,6 @@ Editing fields follows these rules: Examples: - To get field options: { action: "getFieldOptions" } -- To list all documents: { action: "list" } - To get all document metadata: { action: "get" } - To get metadata for a specific document: { action: "get", documentId: "doc123" } - To edit a single field: { action: "edit", documentId: "doc123", fieldEdits: [{ fieldName: "backgroundColor", fieldValue: "#ff0000" }] } @@ -186,7 +180,8 @@ Examples: { fieldName: "layout_autoHeight", fieldValue: false }, { fieldName: "height", fieldValue: 200 } ]} -- IMPORTANT: MULTI STEP WORKFLOWS ARE NOT ONLY ALLOWED BUT ENCOURAGED. TAKE THINGS 1 STEP AT A TIME.`; +- IMPORTANT: MULTI STEP WORKFLOWS ARE NOT ONLY ALLOWED BUT ENCOURAGED. TAKE THINGS 1 STEP AT A TIME. +- IMPORTANT: WHEN CITING A DOCUMENT, MAKE THE CHUNK ID THE DOCUMENT ID. WHENEVER YOU CITE A DOCUMENT, ALWAYS MAKE THE CITATION TYPE "text", THE "direct_text" FIELD BLANK, AND THE "chunk_id" FIELD THE DOCUMENT ID.`; const documentMetadataToolInfo: ToolInfo<DocumentMetadataToolParamsType> = { name: 'documentMetadata', description: toolDescription, @@ -232,11 +227,11 @@ export class DocumentMetadataTool extends BaseTool<DocumentMetadataToolParamsTyp // Ensure the action is valid and convert to string const action = String(args.action); - if (!['get', 'edit', 'list', 'getFieldOptions', 'create'].includes(action)) { + if (!['get', 'edit', 'getFieldOptions', 'create'].includes(action)) { return [ { type: 'text', - text: 'Error: Invalid action. Valid actions are "get", "edit", "list", "getFieldOptions", or "create".', + text: 'Error: Invalid action. Valid actions are "get", "edit", "getFieldOptions", or "create".', }, ]; } @@ -386,10 +381,6 @@ export class DocumentMetadataTool extends BaseTool<DocumentMetadataToolParamsTyp } } - case 'list': { - this._docManager.listDocs(); - } - case 'getFieldOptions': { // Get all available field options with metadata const fieldOptions = this._docManager.getAllFieldMetadata(); @@ -457,7 +448,7 @@ ${JSON.stringify(createdMetadata, null, 2)}`, return [ { type: 'text', - text: 'Error: Unknown action. Valid actions are "get", "edit", "list", "getFieldOptions", or "create".', + text: 'Error: Unknown action. Valid actions are "get", "edit", "getFieldOptions", or "create".', }, ]; } @@ -537,11 +528,6 @@ ${JSON.stringify(createdMetadata, null, 2)}`, return true; } - // list action doesn't require any additional parameters - if (params.action === 'list') { - return true; - } - return true; } @@ -552,7 +538,7 @@ ${JSON.stringify(createdMetadata, null, 2)}`, */ private getParameterRequirementsByAction(action?: string): string { if (!action) { - return 'Please specify an action: "get", "edit", "list", "getFieldOptions", or "create".'; + return 'Please specify an action: "get", "edit", "getFieldOptions", or "create".'; } switch (action.toLowerCase()) { @@ -560,14 +546,12 @@ ${JSON.stringify(createdMetadata, null, 2)}`, return 'The "get" action accepts an optional documentId parameter.'; case 'edit': return 'The "edit" action requires documentId and fieldEdits parameters. fieldEdits must be a JSON array of field edits.'; - case 'list': - return 'The "list" action does not require any additional parameters.'; case 'getFieldOptions': return 'The "getFieldOptions" action does not require any additional parameters. It returns metadata about all available document fields.'; case 'create': return 'The "create" action requires title, data, and doc_type parameters.'; default: - return `Unknown action "${action}". Valid actions are "get", "edit", "list", "getFieldOptions", or "create".`; + return `Unknown action "${action}". Valid actions are "get", "edit", "getFieldOptions", or "create".`; } } } |
