From e141307dbd9b951f76c908610e7b89e296ad92b8 Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Sun, 11 May 2025 17:18:18 -0400 Subject: chanegd everything to be more consistent - made both web related tools use doc manager and chunk Ids --- .../nodes/chatbot/chatboxcomponents/ChatBox.tsx | 50 +++++++--------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'src/client/views/nodes/chatbot/chatboxcomponents') diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index 6349e554e..867e78860 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -121,16 +121,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { this.vectorstore = new Vectorstore(this.vectorstore_id, this.docManager); // Create an agent with the vectorstore - this.agent = new Agent( - this.vectorstore, - this.retrieveSummaries.bind(this), - this.retrieveFormattedHistory.bind(this), - this.retrieveCSVData.bind(this), - this.retrieveDocIds.bind(this), - this.createImageInDash.bind(this), - this.createCSVInDash.bind(this), - this.docManager - ); + this.agent = new Agent(this.vectorstore, this.retrieveFormattedHistory.bind(this), this.retrieveCSVData.bind(this), this.createImageInDash.bind(this), this.createCSVInDash.bind(this), this.docManager); // Add event listeners this.addScrollListener(); @@ -228,6 +219,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { } }; + //TODO: Update for new chunk_simpl on agentDocument /** * Adds a CSV file for analysis by sending it to OpenAI and generating a summary. * @param newLinkedDoc The linked document representing the CSV file. @@ -650,18 +642,15 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { citation: JSON.stringify(citation, null, 2), }); - // First try to find the document using the document manager's chunk ID lookup - const doc: Doc | undefined = this.docManager.getDocByChunkId(chunkId); - if (!doc) { - console.warn(`Document not found for citation with chunk_id: ${chunkId}`); - return; - } - // Get the simplified chunk using the document manager - const foundChunk = this.docManager.getSimplifiedChunkById(doc, chunkId); + const { foundChunk, doc } = this.docManager.getSimplifiedChunkById(chunkId); if (!foundChunk) { - console.warn(`Chunk not found in document for chunk ID: ${chunkId}`); - DocumentManager.Instance.showDocument(doc, { willZoomCentered: true }, () => {}); + if (doc) { + console.warn(`Chunk not found in document, ${doc.id}, for chunk ID: ${chunkId}`); + DocumentManager.Instance.showDocument(doc, { willZoomCentered: true }, () => {}); + } else { + console.warn(`Chunk not found for chunk ID: ${chunkId}`); + } return; } @@ -678,6 +667,10 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { } else if (foundChunk.chunkType === CHUNK_TYPE.TABLE || foundChunk.chunkType === CHUNK_TYPE.IMAGE) { this.handleOtherChunkTypes(foundChunk, citation, doc); } else { + if (doc.type === 'web') { + DocumentManager.Instance.showDocument(doc, { openLocation: OpenWhere.addRight }, () => {}); + return; + } // Show the chunk text in citation popup let chunkText = citation.direct_text || 'Text content not available'; this.showCitationPopup(chunkText); @@ -986,16 +979,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { return Array.from(this.docManager.listDocs); } - /** - * Getter that retrieves summaries of all linked documents. - */ - @computed - get summaries(): string { - // Use the document manager to get all summaries - console.log(this.docManager.listDocs); - return JSON.stringify(this.docManager.listDocs); - } - /** * Getter that retrieves all linked CSV files for analysis. */ @@ -1022,7 +1005,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { // Other helper methods for retrieving document data and processing retrieveSummaries = (): string => { - return this.docManager.getAllDocumentSummaries(); + console.log(this.docManager.listDocs); + return JSON.stringify(this.docManager.listDocs); }; retrieveCSVData = () => { @@ -1033,10 +1017,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { return this.formattedHistory; }; - retrieveDocIds = (): string[] => { - return Array.from(this.docManager.docIds); - }; - /** * Handles follow-up questions when the user clicks on them. * Automatically sets the input value to the clicked follow-up question. -- cgit v1.2.3-70-g09d2