diff options
author | bobzel <zzzman@gmail.com> | 2025-02-10 10:54:48 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2025-02-10 10:54:48 -0500 |
commit | 1a6a53eeca4eea46af2dbd3e0778a18497d7b3a8 (patch) | |
tree | 369e3a3f5027752065e81993822e88471669b338 /src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts | |
parent | 9cee38a2bceb2871cf3fda32e0df18d14f8c8c8e (diff) |
more cleanup of createDoc and chatbox
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts b/src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts index efc66880f..7ec39704a 100644 --- a/src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateAnyDocTool.ts @@ -1,10 +1,10 @@ import { toLower } from 'lodash'; -import { v4 as uuidv4 } from 'uuid'; import { DocumentOptions } from '../../../../documents/Documents'; import { ParametersType } from '../types/tool_types'; import { Observation } from '../types/types'; import { BaseTool } from './BaseTool'; import { supportedDocumentTypes } from './CreateDocumentTool'; +import { Id } from '../../../../../fields/FieldSymbols'; const standardOptions = ['title', 'backgroundColor']; /** @@ -76,9 +76,9 @@ const createAnyDocumentToolParams = [ type CreateAnyDocumentToolParamsType = typeof createAnyDocumentToolParams; export class CreateAnyDocumentTool extends BaseTool<CreateAnyDocumentToolParamsType> { - private _addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void; + private _addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions) => void; - constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void) { + constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions) => void) { // prettier-ignore super( 'createAnyDocument', @@ -113,13 +113,12 @@ export class CreateAnyDocumentTool extends BaseTool<CreateAnyDocumentToolParamsT throw new Error(`Data is required for ${documentType} documents. ${info.dataDescription}`); } - const id = uuidv4(); const options: DocumentOptions = !args.options ? {} : JSON.parse(args.options); // Call the function to add the linked document (add default title that can be overriden if set in options) - this._addLinkedDoc(documentType, args.data, { title: `New ${documentType.charAt(0).toUpperCase() + documentType.slice(1)} Document`, ...options }, id); + const doc = this._addLinkedDoc(documentType, args.data, { title: `New ${documentType.charAt(0).toUpperCase() + documentType.slice(1)} Document`, ...options }); - return [{ type: 'text', text: `Created ${documentType} document with ID ${id}.` }]; + return [{ type: 'text', text: `Created ${documentType} document with ID ${doc?.[Id]}.` }]; } catch (error) { return [{ type: 'text', text: 'Error creating document: ' + (error as Error).message }]; } |