aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
-rw-r--r--src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx50
1 files changed, 15 insertions, 35 deletions
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<FieldViewProps>() {
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<FieldViewProps>() {
}
};
+ //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<FieldViewProps>() {
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<FieldViewProps>() {
} 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);
@@ -987,16 +980,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
/**
- * 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.
*/
@computed get linkedCSVs(): { filename: string; id: string; text: string }[] {
@@ -1022,7 +1005,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// 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<FieldViewProps>() {
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.