aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/GetDocsTool.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/GetDocsTool.ts')
-rw-r--r--src/client/views/nodes/chatbot/tools/GetDocsTool.ts38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/client/views/nodes/chatbot/tools/GetDocsTool.ts b/src/client/views/nodes/chatbot/tools/GetDocsTool.ts
index 903f3f69c..26756522c 100644
--- a/src/client/views/nodes/chatbot/tools/GetDocsTool.ts
+++ b/src/client/views/nodes/chatbot/tools/GetDocsTool.ts
@@ -1,29 +1,47 @@
-import { DocCast } from '../../../../../fields/Types';
+import { Observation } from '../types/types';
+import { ParametersType } from './ToolTypes';
+import { BaseTool } from './BaseTool';
import { DocServer } from '../../../../DocServer';
import { Docs } from '../../../../documents/Documents';
import { DocumentView } from '../../DocumentView';
import { OpenWhere } from '../../OpenWhere';
-import { BaseTool } from './BaseTool';
+import { DocCast } from '../../../../../fields/Types';
-export class GetDocsTool extends BaseTool<{ title: string; document_ids: string[] }> {
+const getDocsToolParams = [
+ {
+ name: 'title',
+ type: 'string',
+ description: 'Title of the collection being created from retrieved documents',
+ required: true,
+ },
+ {
+ name: 'document_ids',
+ type: 'string[]',
+ description: 'List of document IDs to retrieve',
+ required: true,
+ },
+] as const;
+
+type GetDocsToolParamsType = typeof getDocsToolParams;
+
+export class GetDocsTool extends BaseTool<GetDocsToolParamsType> {
private _docView: DocumentView;
+
constructor(docView: DocumentView) {
super(
'retrieveDocs',
'Retrieves the contents of all Documents that the user is interacting with in Dash',
- {},
+ getDocsToolParams,
'No need to provide anything. Just run the tool and it will retrieve the contents of all Documents that the user is interacting with in Dash.',
- 'Returns the the documents in Dash in JSON form. This will include the title of the document, the location in the FreeFormDocument, and the content of the document, any applicable data fields, the layout of the document, etc.'
+ 'Returns the documents in Dash in JSON form.'
);
this._docView = docView;
}
- async execute(args: { title: string; document_ids: string[] }): Promise<unknown> {
- // Note: Using eval() can be dangerous. Consider using a safer alternative.
+ async execute(args: ParametersType<GetDocsToolParamsType>): Promise<Observation[]> {
const docs = args.document_ids.map(doc_id => DocCast(DocServer.GetCachedRefField(doc_id)));
const collection = Docs.Create.FreeformDocument(docs, { title: args.title });
- this._docView._props.addDocTab(collection, OpenWhere.addRight); //in future, create popup prompting user where to add
- return [{ type: 'text', text: 'Collection created in Dash called ' + args.title }];
+ this._docView._props.addDocTab(collection, OpenWhere.addRight);
+ return [{ type: 'text', text: `Collection created in Dash called ${args.title}` }];
}
}
-//export function create_collection(docView: DocumentView, document_ids: string[], title: string): string {}