aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts')
-rw-r--r--src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts22
1 files changed, 21 insertions, 1 deletions
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<string, AgentDocument>;
private chatBox: ChatBox;
+ private parentView : DocumentView
private chatBoxDocument: Doc | null = null;
private fieldMetadata: Record<string, any> = {}; // bcz: CHANGE any to a proper type!
@observable private simplifiedChunks: ObservableMap<string, SimplifiedChunk>;
@@ -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<string,string>();
+
+ public async getDocDescription(id: string): Promise<string> {
+ 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