aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-01-21 18:13:39 -0500
committerbobzel <zzzman@gmail.com>2025-01-21 18:13:39 -0500
commitd72977ad8b67f2575cad8aea988fcfa7c04f794a (patch)
tree2b87cab8eade12394cb19f7168e0a9c5e5ff07f3 /src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
parentec0ab50aad9fbb55477476998c6932488b149f45 (diff)
more attempts to cleanup typing, etc in chat box
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts')
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
index 63a6004a7..f0f2fe703 100644
--- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
+++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
@@ -3,6 +3,7 @@ import { BaseTool } from './BaseTool';
import { Observation } from '../types/types';
import { ParametersType } from '../types/tool_types';
import { DocumentOptions } from '../../../../documents/Documents';
+import { supportedDocumentTypes } from './CreateAnyDocTool';
/**
* Tthe CreateDocTool class is responsible for creating
@@ -343,9 +344,9 @@ type CreateListDocToolParamsType = typeof createListDocToolParams;
// Tool class for creating documents
export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {
- private _addLinkedDoc: (doc_type: string, data: string, options: DocumentOptions, id: string) => void;
+ private _addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void;
- constructor(addLinkedDoc: (doc_type: string, data: string, options: DocumentOptions, id: string) => void) {
+ constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void) {
super(
'createDoc',
'Creates one or more documents that best fit the user’s request. If the user requests a "dashboard," first call the search tool and then generate a variety of document types individually, with absolutely a minimum of 20 documents with two stacks of flashcards that are small and it should have a couple nested freeform collections of things, each with different content and color schemes. For example, create multiple individual documents like "text," "deck," "web", "equation," and "comparison." Use decks instead of flashcards for dashboards. Decks should have at least three flashcards. Really think about what documents are useful to the user. If they ask for a dashboard about the skeletal system, include flashcards, as they would be helpful. Arrange the documents in a grid layout, ensuring that the x and y coordinates are calculated so no documents overlap but they should be directly next to each other with 20 padding in between. Take into account the width and height of each document, spacing them appropriately to prevent collisions. Use a systematic approach, such as placing each document in a grid cell based on its order, where cell dimensions match the document dimensions plus a fixed margin for spacing. Do not nest all documents within a single collection unless explicitly requested by the user. Instead, create a set of independent documents with diverse document types. Each type should appear separately unless specified otherwise.',
@@ -363,27 +364,27 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {
async execute(args: ParametersType<CreateListDocToolParamsType>): Promise<Observation[]> {
try {
console.log('EXE' + args.docs);
- const parsedDoc = JSON.parse(args.docs);
+ const parsedDoc = JSON.parse(args.docs) as ({ doc_type: supportedDocumentTypes; data: unknown } & DocumentOptions)[];
console.log('parsed' + parsedDoc);
- parsedDoc.forEach(doc => {
+ parsedDoc.forEach(doc =>
this._addLinkedDoc(
- doc['doc_type'],
- doc['data'],
+ doc.doc_type,
+ doc.data,
{
- title: doc['title'],
- backgroundColor: doc['backgroundColor'],
- text_fontColor: doc['font_color'],
- _width: doc['width'],
- _height: doc['height'],
- type_collection: doc['type_collection'],
+ 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'],
+ x: doc.x,
+ y: doc.y,
},
uuidv4()
- );
- });
+ )
+ );
return [{ type: 'text', text: 'Created document.' }];
} catch (error) {
return [{ type: 'text', text: 'Error creating text document, ' + error }];