aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-16 19:02:56 -0400
committerbobzel <zzzman@gmail.com>2025-03-16 19:02:56 -0400
commitdf708c90d8356934d2e3d9123129c761d328c1fe (patch)
tree98b0588710ac8ca00c303960da0851614aacf597 /src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts
parent7d9fae09e8906e5636f6ea695ad560797b08d023 (diff)
parentf4042257be7359734a0dd35cedbf03fe4aa14cf1 (diff)
Merge branch 'DocCreatorMenu-work' of https://github.com/brown-dash/Dash-Web into DocCreatorMenu-work
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts')
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts
new file mode 100644
index 000000000..16dc938bb
--- /dev/null
+++ b/src/client/views/nodes/chatbot/tools/CreateTextDocumentTool.ts
@@ -0,0 +1,57 @@
+import { parsedDoc } from '../chatboxcomponents/ChatBox';
+import { ParametersType, ToolInfo } from '../types/tool_types';
+import { Observation } from '../types/types';
+import { BaseTool } from './BaseTool';
+const createTextDocToolParams = [
+ {
+ name: 'text_content',
+ type: 'string',
+ description: 'The text content that the document will display',
+ required: true,
+ },
+ {
+ name: 'title',
+ type: 'string',
+ description: 'The title of the document',
+ required: true,
+ },
+ // {
+ // name: 'background_color',
+ // type: 'string',
+ // description: 'The background color of the document as a hex string',
+ // required: false,
+ // },
+ // {
+ // name: 'font_color',
+ // type: 'string',
+ // description: 'The font color of the document as a hex string',
+ // required: false,
+ // },
+] as const;
+
+type CreateTextDocToolParamsType = typeof createTextDocToolParams;
+
+const createTextDocToolInfo: ToolInfo<CreateTextDocToolParamsType> = {
+ name: 'createTextDoc',
+ description: 'Creates a text document with the provided content and title. Use if the user wants to create a textbox or text document of some sort. Can use after a search or other tool to save information.',
+ citationRules: 'No citation needed.',
+ parameterRules: createTextDocToolParams,
+};
+
+export class CreateTextDocTool extends BaseTool<CreateTextDocToolParamsType> {
+ private _addLinkedDoc: (doc: parsedDoc) => void;
+
+ constructor(addLinkedDoc: (doc: parsedDoc) => void) {
+ super(createTextDocToolInfo);
+ this._addLinkedDoc = addLinkedDoc;
+ }
+
+ async execute(args: ParametersType<CreateTextDocToolParamsType>): Promise<Observation[]> {
+ try {
+ this._addLinkedDoc({ doc_type: 'text', data: args.text_content, title: args.title });
+ return [{ type: 'text', text: 'Created text document.' }];
+ } catch (error) {
+ return [{ type: 'text', text: 'Error creating text document, ' + error }];
+ }
+ }
+}