aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-02-11 16:03:29 -0500
committerbobzel <zzzman@gmail.com>2025-02-11 16:03:29 -0500
commit3e531aa898492cb05e25081f422bb59adab72e8e (patch)
tree29f23fa2619cf4d9aca71f455a0e5724c52bd57a /src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
parent1ef0a2d7835c9dfa1ec9fc298562f3a052b3e817 (diff)
enabled multi-select modification of text documents from topBar buttons. fixed diagram box layout and scrolling. fixed problem with createDoc tool where it would fail when it got an array. fixed formatting of chat box errors.
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts')
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
index 34ab9206b..6dc36b0d1 100644
--- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
+++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
@@ -1,6 +1,6 @@
import { BaseTool } from './BaseTool';
import { Observation } from '../types/types';
-import { ParametersType, ToolInfo } from '../types/tool_types';
+import { Parameter, ParametersType, ToolInfo } from '../types/tool_types';
import { parsedDoc } from '../chatboxcomponents/ChatBox';
import { CollectionViewType } from '../../../../documents/DocumentTypes';
@@ -431,7 +431,10 @@ const createDocToolInfo: ToolInfo<CreateDocToolParamsType> = {
description: `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."
+ For example, create multiple individual documents, including ${Object.keys(documentTypesInfo)
+ .map(t => '"' + t + '"')
+ .join(',')}
+ If the "doc_type" parameter is missing, set it to an empty string ("").
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.
@@ -443,7 +446,7 @@ const createDocToolInfo: ToolInfo<CreateDocToolParamsType> = {
Ensure web documents use URLs from the search tool if relevant. Each document in a dashboard should be unique and well-differentiated in type and content,
without repetition of similar types in any single collection.
When creating a dashboard, ensure that it consists of a broad range of document types.
- Include a variety of documents, such as text, web, deck, comparison, image, simulation, and equation documents,
+ Include a variety of documents, such as text, web, deck, comparison, image, and equation documents,
each with distinct titles and colors, following the user’s preferences.
Do not overuse collections or nest all document types within a single collection; instead, represent document types individually. Use this example for reference:
${finalJsonString} .
@@ -469,6 +472,9 @@ export class CreateDocTool extends BaseTool<
this._addLinkedDoc = addLinkedDoc;
}
+ override inputValidator(inputParam: ParametersType<readonly Parameter[]>) {
+ return !!inputParam.data;
+ }
// Executes the tool logic for creating documents
async execute(
args: ParametersType<
@@ -481,8 +487,8 @@ export class CreateDocTool extends BaseTool<
>
): Promise<Observation[]> {
try {
- const parsedDocs = args instanceof Array ? args : [args]; // JSON.parse((args as any).data) as parsedDoc[];
- parsedDocs.forEach(doc => this._addLinkedDoc({ ...doc, _layout_fitWidth: false, _layout_autoHeight: true }));
+ const parsedDocs = args instanceof Array ? args : Object.keys(args).length === 1 && 'data' in args ? JSON.parse(args.data as string) : [args];
+ parsedDocs.forEach((pdoc: parsedDoc) => this._addLinkedDoc({ ...pdoc, _layout_fitWidth: false, _layout_autoHeight: true }));
return [{ type: 'text', text: 'Created document.' }];
} catch (error) {
return [{ type: 'text', text: 'Error creating text document, ' + error }];