From f0807c6f6c31ac9ae2e6fb581f19a760f8e5687e Mon Sep 17 00:00:00 2001 From: sharkiecodes Date: Wed, 2 Jul 2025 20:33:37 -0400 Subject: Implementing replacement of GPTPopup --- .../nodes/chatbot/utils/AgentDocumentManager.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts') diff --git a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts index dcb708450..857cc859d 100644 --- a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts +++ b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts @@ -27,6 +27,7 @@ interface AgentDocument { export class AgentDocumentManager { @observable private documentsById: ObservableMap; private chatBox: ChatBox; + private parentView : DocumentView private chatBoxDocument: Doc | null = null; private fieldMetadata: Record = {}; // bcz: CHANGE any to a proper type! @observable private simplifiedChunks: ObservableMap; @@ -35,8 +36,9 @@ export class AgentDocumentManager { * Creates a new DocumentManager * @param templateDocument The document that serves as a template for new documents */ - constructor(chatBox: ChatBox) { + constructor(chatBox: ChatBox, parentView : DocumentView) { makeObservable(this); + this.parentView = parentView; const agentDoc = DocCast(chatBox.Document.agentDocument) ?? new Doc(); const chunk_simpl = DocCast(agentDoc.chunk_simpl) ?? new Doc(); @@ -164,6 +166,10 @@ export class AgentDocumentManager { } } + public get parentViewDocument(): DocumentView { + return this.parentView; + } + /** * Process a document by ensuring it has an ID and adding it to the appropriate collections * @param doc The document to process @@ -1011,6 +1017,20 @@ export class AgentDocumentManager { const docInfo = this.documentsById.get(docId); return docInfo?.dataDoc; } + + // 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)!; + } + + /** * Adds simplified chunks to a document for citation handling * @param doc The document to add simplified chunks to -- cgit v1.2.3-70-g09d2