aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts2
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts25
2 files changed, 8 insertions, 19 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
index 25e471ce8..13fdac7f5 100644
--- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
@@ -54,7 +54,7 @@ export class Agent {
history: () => string,
csvData: () => { filename: string; id: string; text: string }[],
addLinkedUrlDoc: (url: string, id: string) => void,
- addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void,
+ addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id?: string) => void,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
createCSVInDash: (url: string, title: string, id: string, data: string) => void
) {
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
index b919b242c..07b515fea 100644
--- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
+++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
@@ -1,8 +1,8 @@
-import { v4 as uuidv4 } from 'uuid';
import { BaseTool } from './BaseTool';
import { Observation } from '../types/types';
import { ParametersType } from '../types/tool_types';
import { DocumentOptions } from '../../../../documents/Documents';
+import { OmitKeys } from '../../../../../ClientUtils';
export enum supportedDocumentTypes {
flashcard = 'flashcard',
@@ -360,9 +360,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, id: string) => void;
+ private _addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions) => void;
- constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions, id: string) => void) {
+ constructor(addLinkedDoc: (doc_type: supportedDocumentTypes, data: unknown, options: DocumentOptions) => void) {
super(
'createDoc',
`Creates one or more documents that best fit the user’s request.
@@ -395,24 +395,13 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {
async execute(args: ParametersType<CreateListDocToolParamsType>): Promise<Observation[]> {
try {
const parsedDoc = JSON.parse(args.docs) as ({ doc_type: supportedDocumentTypes; data: unknown } & DocumentOptions)[];
- parsedDoc.forEach(doc =>
+ parsedDoc.forEach(
+ doc =>
this._addLinkedDoc(
doc.doc_type,
doc.data,
- {
- 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,
- },
- uuidv4()
- )
+ {...OmitKeys(doc, ["data", "doc_type"]).omit, _layout_fitWidth: false, _layout_autoHeight: true}
+ ) // prettier-ignore
);
return [{ type: 'text', text: 'Created document.' }];
} catch (error) {