aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/ChatBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/ChatBox/ChatBox.tsx')
-rw-r--r--src/client/views/nodes/ChatBox/ChatBox.tsx80
1 files changed, 1 insertions, 79 deletions
diff --git a/src/client/views/nodes/ChatBox/ChatBox.tsx b/src/client/views/nodes/ChatBox/ChatBox.tsx
index e3a164b3e..49c9b3292 100644
--- a/src/client/views/nodes/ChatBox/ChatBox.tsx
+++ b/src/client/views/nodes/ChatBox/ChatBox.tsx
@@ -4,7 +4,6 @@ import OpenAI, { ClientOptions } from 'openai';
import * as React from 'react';
import { Doc, DocListCast } from '../../../../fields/Doc';
import { CsvCast, DocCast, PDFCast, StrCast } from '../../../../fields/Types';
-import { Networking } from '../../../Network';
import { DocumentType } from '../../../documents/DocumentTypes';
import { Docs } from '../../../documents/Documents';
import { LinkManager } from '../../../util/LinkManager';
@@ -14,19 +13,12 @@ import './ChatBox.scss';
import MessageComponentBox from './MessageComponent';
import { ASSISTANT_ROLE, AssistantMessage, AI_Document, Citation, CHUNK_TYPE, Chunk, getChunkType } from './types';
import { Vectorstore } from './vectorstore/VectorstoreUpload';
-import { CollectionFreeFormDocumentView } from '../CollectionFreeFormDocumentView';
-import { CollectionFreeFormView } from '../../collections/collectionFreeForm';
import { Agent } from './Agent';
import dotenv from 'dotenv';
import { DocData, DocViews } from '../../../../fields/DocSymbols';
-import { DocumentView } from '../DocumentView';
import { AnswerParser } from './AnswerParser';
import { DocumentManager } from '../../../util/DocumentManager';
-import { UUID } from 'bson';
import { v4 as uuidv4 } from 'uuid';
-import { aS } from '@fullcalendar/core/internal-common';
-import { computeRect } from '@fullcalendar/core/internal';
-import { DocUtils } from '../../../documents/DocUtils';
dotenv.config();
@@ -78,14 +70,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
await this.vectorstore.addAIDoc(newLinkedDoc);
};
- // @action
- // uploadNewDocument = async (newDoc: Doc) => {
- // const local_file_path: string = CsvCast(newDoc.data, PDFCast(newDoc.data)).url.pathname;
- // const { document_json } = await Networking.PostToServer('/createDocument', { file_path: local_file_path });
- // this.documents.push(...document_json.map(convertToAIDocument));
- // //newDoc['ai_document'] = document_json;
- // };
-
@action
toggleToolLogs = (index: number) => {
this.expandedScratchpadIndex = this.expandedScratchpadIndex === index ? null : index;
@@ -105,10 +89,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
};
- // getAssistantResponse() {
- // return Docs.Create.MessageDocument(text, {});
- // }
-
@action
askGPT = async (event: React.FormEvent<HTMLFormElement>): Promise<void> => {
event.preventDefault();
@@ -223,42 +203,6 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
return highlight_doc;
};
- // @action
- // uploadLinks = async (linkedDocs: Doc[]) => {
- // if (this.isUploadingDocs) {
- // console.log('Initialization in progress, upload aborted.');
- // return;
- // }
- // const urls: string[] = linkedDocs.map(doc => CsvCast(doc.data, PDFCast(doc.data)).url.pathname);
- // const csvUrls: string[] = urls.filter(url => url.endsWith('.csv'));
- // console.log(this.assistantID, this.threadID, urls);
-
- // await Networking.PostToServer('/uploadPDFs', { file_path: urls[0] });
-
- // // linkedDocs.forEach((doc, i) => {
- // // doc[this.Document[Id] + '_ai_field_id'] = openaiFileIds[i];
- // // console.log('AI Field ID: ' + openaiFileIds[i]);
- // // });
-
- // // if (csvUrls.length > 0) {
- // // for (let i = 0; i < csvUrls.length; i++) {
- // // this.linkedCsvIDs.push(openaiFileIds[urls.indexOf(csvUrls[i])]);
- // // }
- // // console.log('linked csvs:' + this.linkedCsvIDs);
- // // await this.openai.beta.assistants.update(this.assistantID, {
- // // tools: [{ type: 'file_search' }, { type: 'code_interpreter' }],
- // // tool_resources: {
- // // file_search: {
- // // vector_store_ids: [this.vectorStoreID],
- // // },
- // // code_interpreter: {
- // // file_ids: this.linkedCsvIDs,
- // // },
- // // },
- // // });
- // // }
- // };
-
componentDidMount() {
this._props.setContentViewBox?.(this);
if (this.dataDoc.data) {
@@ -307,20 +251,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
});
}
- // case 'splice':
- // if ((change as any).addedCount > 0) {
- // // maybe check here if its already in the urls datadoc array so doesn't add twice
- // console.log((change as any).added as Doc[]);
- // this.addDocsToVectorstore((change as any).added as Doc[]);
- // }
- // // (change as any).removed.forEach((link: any) => remLinkFromDoc(toRealField(link)));
- // break;
- // case 'update': // let oldValue = change.oldValue;
- // default:
-
@computed
get linkedDocs() {
- //return (CollectionFreeFormDocumentView.from(this._props.DocumentView?.())?._props.parent as CollectionFreeFormView)?.childDocs.filter(doc => doc != this.Document) ?? [];
return LinkManager.Instance.getAllRelatedLinks(this.Document)
.map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)))
.map(d => DocCast(d?.annotationOn, d))
@@ -334,6 +266,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
.map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)))
.map(d => DocCast(d?.annotationOn, d))
.filter(d => d)
+ .filter(d => d.summary)
.map((doc, index) => `${index + 1}) ${doc.summary}`)
.join('\n') + '\n'
);
@@ -375,19 +308,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}}>
<div className="messages">
{this.history.map((message, index) => (
- //<DocumentView key={index} Document={message} index={index} onFollowUpClick={this.handleFollowUpClick} onCitationClick={this.handleCitationClick} updateMessageCitations={this.updateMessageCitations} />
<MessageComponentBox key={index} message={message} index={index} onFollowUpClick={this.handleFollowUpClick} onCitationClick={this.handleCitationClick} updateMessageCitations={this.updateMessageCitations} />
))}
- {this.current_message && (
- <MessageComponentBox
- key={this.history.length}
- message={this.current_message}
- index={this.history.length}
- onFollowUpClick={this.handleFollowUpClick}
- onCitationClick={this.handleCitationClick}
- updateMessageCitations={this.updateMessageCitations}
- />
- )}
</div>
</div>
<form onSubmit={this.askGPT} className="chat-form">