From 8299e24ccd64987cb898cae74622d5bb06d9e538 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 3 Jul 2025 10:46:08 -0400 Subject: fixed creating docs with ai tool to allow options to be specified. --- .../nodes/chatbot/utils/AgentDocumentManager.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/client/views/nodes/chatbot/utils') diff --git a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts index 857cc859d..088891022 100644 --- a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts +++ b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts @@ -27,7 +27,7 @@ interface AgentDocument { export class AgentDocumentManager { @observable private documentsById: ObservableMap; private chatBox: ChatBox; - private parentView : DocumentView + private parentView: DocumentView; private chatBoxDocument: Doc | null = null; private fieldMetadata: Record = {}; // bcz: CHANGE any to a proper type! @observable private simplifiedChunks: ObservableMap; @@ -36,7 +36,7 @@ export class AgentDocumentManager { * Creates a new DocumentManager * @param templateDocument The document that serves as a template for new documents */ - constructor(chatBox: ChatBox, parentView : DocumentView) { + constructor(chatBox: ChatBox, parentView: DocumentView) { makeObservable(this); this.parentView = parentView; const agentDoc = DocCast(chatBox.Document.agentDocument) ?? new Doc(); @@ -857,6 +857,7 @@ export class AgentDocumentManager { try { // Create simple document with just title and data const simpleDoc: parsedDoc = { + ...(options as parsedDoc), // bcz: hack .. why do we need parsedDoc and not DocumentOptions here? doc_type: docType, title: options?.title ?? `Untitled Document ${this.documentsById.size + 1}`, data: data, @@ -1018,19 +1019,18 @@ export class AgentDocumentManager { return docInfo?.dataDoc; } - // In AgentDocumentManager - private descriptionCache = new Map(); + // In AgentDocumentManager + private descriptionCache = new Map(); public async getDocDescription(id: string): Promise { - if (!this.descriptionCache.has(id)) { - const doc = this.getDocument(id)!; - const desc = await Doc.getDescription(doc); - this.descriptionCache.set(id, desc.replace(/\n/g,' ').trim()); - } - return this.descriptionCache.get(id)!; + if (!this.descriptionCache.has(id)) { + const doc = this.getDocument(id)!; + const desc = await Doc.getDescription(doc); + this.descriptionCache.set(id, desc.replace(/\n/g, ' ').trim()); + } + return this.descriptionCache.get(id)!; } - /** * Adds simplified chunks to a document for citation handling * @param doc The document to add simplified chunks to -- cgit v1.2.3-70-g09d2