diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts')
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts index b919b242c..07b515fea 100644 --- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts @@ -1,8 +1,8 @@ -import { v4 as uuidv4 } from 'uuid'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; import { ParametersType } from '../types/tool_types'; import { DocumentOptions } from '../../../../documents/Documents'; +import { OmitKeys } from '../../../../../ClientUtils'; export enum supportedDocumentTypes { flashcard = 'flashcard', @@ -360,9 +360,9 @@ type CreateListDocToolParamsType = typeof createListDocToolParams; // Tool class for creating documents export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> { - 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) { super( 'createDoc', `Creates one or more documents that best fit the user’s request. @@ -395,24 +395,13 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> { async execute(args: ParametersType<CreateListDocToolParamsType>): Promise<Observation[]> { try { const parsedDoc = JSON.parse(args.docs) as ({ doc_type: supportedDocumentTypes; data: unknown } & DocumentOptions)[]; - parsedDoc.forEach(doc => + parsedDoc.forEach( + doc => this._addLinkedDoc( doc.doc_type, doc.data, - { - title: doc.title, - backgroundColor: doc.backgroundColor, - text_fontColor: doc.text_fontColor, - _width: doc._width, - _height: doc._height, - type_collection: doc.type_collection, - _layout_fitWidth: false, - _layout_autoHeight: true, - x: doc.x, - y: doc.y, - }, - uuidv4() - ) + {...OmitKeys(doc, ["data", "doc_type"]).omit, _layout_fitWidth: false, _layout_autoHeight: true} + ) // prettier-ignore ); return [{ type: 'text', text: 'Created document.' }]; } catch (error) { |