diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
-rw-r--r-- | src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index 542d8ea58..6d5290c95 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -550,6 +550,53 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { @action createDocInDash = async (doc_type: string, data: string, options: DocumentOptions, id: string) => { const doc = await this.whichDoc(doc_type, data, options, id); + createDocInDash = async (doc_type: string, data: string | undefined, options: DocumentOptions, id: string) => { + let doc; + + switch (doc_type.toLowerCase()) { + case 'text': + doc = Docs.Create.TextDocument(data || '', options); + break; + case 'image': + doc = Docs.Create.ImageDocument(data || '', options); + break; + case 'pdf': + doc = Docs.Create.PdfDocument(data || '', options); + break; + case 'video': + doc = Docs.Create.VideoDocument(data || '', options); + break; + case 'audio': + doc = Docs.Create.AudioDocument(data || '', options); + break; + case 'web': + doc = Docs.Create.WebDocument(data || '', options); + break; + case 'equation': + doc = Docs.Create.EquationDocument(data || '', options); + break; + case 'functionplot': + case 'function_plot': + doc = Docs.Create.FunctionPlotDocument([], options); + break; + case 'dataviz': + case 'data_viz': { + const { fileUrl, id } = await Networking.PostToServer('/createCSV', { + filename: (options.title as string).replace(/\s+/g, '') + '.csv', + data: data, + }); + doc = Docs.Create.DataVizDocument(fileUrl, { ...options, text: RTFCast(data) }); + this.addCSVForAnalysis(doc, id); + break; + } + case 'chat': + doc = Docs.Create.ChatDocument(options); + break; + // Add more cases for other document types + default: + console.error('Unknown or unsupported document type:', doc_type); + return; + } const linkDoc = Docs.Create.LinkDocument(this.Document, doc); LinkManager.Instance.addLink(linkDoc); doc && this._props.addDocument?.(doc); @@ -942,9 +989,10 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { <MessageComponentBox key={this.history.length} message={this.current_message} onFollowUpClick={this.handleFollowUpClick} onCitationClick={this.handleCitationClick} updateMessageCitations={this.updateMessageCitations} /> )} </div> + <form onSubmit={this.askGPT} className="chat-input"> - <input type="text" name="messageInput" autoComplete="off" placeholder="Type your message here..." value={this.inputValue} onChange={e => (this.inputValue = e.target.value)} /> - <button className="submit-button" type="submit" disabled={this.isLoading}> + <input type="text" name="messageInput" autoComplete="off" placeholder="Type your message here..." value={this.inputValue} onChange={e => (this.inputValue = e.target.value)} disabled={this.isLoading} /> + <button className="submit-button" type="submit" disabled={this.isLoading || !this.inputValue.trim()}> {this.isLoading ? ( <div className="spinner"></div> ) : ( |