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/CreateDocumentTool.ts | |
| parent | 9cee38a2bceb2871cf3fda32e0df18d14f8c8c8e (diff) | |
more cleanup of createDoc and chatbox
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts')
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts | 18 | 
1 files changed, 5 insertions, 13 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts index 07b515fea..28c0eb32e 100644 --- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts @@ -1,8 +1,7 @@  import { BaseTool } from './BaseTool';  import { Observation } from '../types/types';  import { ParametersType } from '../types/tool_types'; -import { DocumentOptions } from '../../../../documents/Documents'; -import { OmitKeys } from '../../../../../ClientUtils'; +import { parsedDoc } from '../chatboxcomponents/ChatBox';  export enum supportedDocumentTypes {      flashcard = 'flashcard', @@ -360,9 +359,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) => void; +    private _addLinkedDoc: (doc: parsedDoc) => void; -    constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions) => void) { +    constructor(addLinkedDoc: (doc: parsedDoc) => void) {          super(              'createDoc',              `Creates one or more documents that best fit the user’s request.  @@ -394,15 +393,8 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {      // Executes the tool logic for creating documents      async execute(args: ParametersType<CreateListDocToolParamsType>): Promise<Observation[]> {          try { -            const parsedDoc = JSON.parse(args.docs) as ({ doc_type: supportedDocumentTypes; data: unknown } & DocumentOptions)[]; -            parsedDoc.forEach( -                doc => -                this._addLinkedDoc( -                    doc.doc_type, -                    doc.data, -                    {...OmitKeys(doc, ["data", "doc_type"]).omit, _layout_fitWidth: false, _layout_autoHeight: true} -                ) // prettier-ignore -            ); +            const parsedDocs = JSON.parse(args.docs) as parsedDoc[]; +            parsedDocs.forEach(doc => this._addLinkedDoc({ ...doc, _layout_fitWidth: false, _layout_autoHeight: true }));              return [{ type: 'text', text: 'Created document.' }];          } catch (error) {              return [{ type: 'text', text: 'Error creating text document, ' + error }];  | 
