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.tsx35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index f13116fdd..a9cf849cc 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -35,7 +35,7 @@ import { PDFBox } from '../../PDFBox';
import { ScriptingBox } from '../../ScriptingBox';
import { VideoBox } from '../../VideoBox';
import { Agent } from '../agentsystem/Agent';
-import { supportedDocumentTypes } from '../tools/CreateDocumentTool';
+import { supportedDocTypes } from '../tools/CreateDocumentTool';
import { ASSISTANT_ROLE, AssistantMessage, CHUNK_TYPE, Citation, ProcessingInfo, SimplifiedChunk, TEXT_TYPE } from '../types/types';
import { Vectorstore } from '../vectorstore/Vectorstore';
import './ChatBox.scss';
@@ -443,18 +443,18 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
const ndoc = (() => {
switch (doc.doc_type) {
default:
- case supportedDocumentTypes.text: return Docs.Create.TextDocument(data as string, options);
- case supportedDocumentTypes.comparison: return this.createComparison(data as parsedDoc[], options);
- case supportedDocumentTypes.flashcard: return this.createFlashcard(data as parsedDoc[], options);
- case supportedDocumentTypes.deck: return this.createDeck(data as parsedDoc[], options);
- case supportedDocumentTypes.image: return Docs.Create.ImageDocument(data as string, options);
- case supportedDocumentTypes.equation: return Docs.Create.EquationDocument(data as string, options);
- case supportedDocumentTypes.notetaking: return Docs.Create.NoteTakingDocument([], options);
- case supportedDocumentTypes.web: return Docs.Create.WebDocument(data as string, { ...options, data_useCors: true });
- case supportedDocumentTypes.dataviz: return Docs.Create.DataVizDocument('/users/rz/Downloads/addresses.csv', options);
- case supportedDocumentTypes.pdf: return Docs.Create.PdfDocument(data as string, options);
- case supportedDocumentTypes.video: return Docs.Create.VideoDocument(data as string, options);
- case supportedDocumentTypes.mermaid: return Docs.Create.DiagramDocument(undefined, { text: data as unknown as RichTextField, ...options}); // text: can take a string or RichTextField but it's typed for RichTextField.
+ case supportedDocTypes.text: return Docs.Create.TextDocument(data as string, options);
+ case supportedDocTypes.comparison: return this.createComparison(JSON.parse(data as string) as parsedDoc[], options);
+ case supportedDocTypes.flashcard: return this.createFlashcard(JSON.parse(data as string) as parsedDoc[], options);
+ case supportedDocTypes.deck: return this.createDeck(JSON.parse(data as string) as parsedDoc[], options);
+ case supportedDocTypes.image: return Docs.Create.ImageDocument(data as string, options);
+ case supportedDocTypes.equation: return Docs.Create.EquationDocument(data as string, options);
+ case supportedDocTypes.notetaking: return Docs.Create.NoteTakingDocument([], options);
+ case supportedDocTypes.web: return Docs.Create.WebDocument(data as string, { ...options, data_useCors: true });
+ case supportedDocTypes.dataviz: return Docs.Create.DataVizDocument('/users/rz/Downloads/addresses.csv', options);
+ case supportedDocTypes.pdf: return Docs.Create.PdfDocument(data as string, options);
+ case supportedDocTypes.video: return Docs.Create.VideoDocument(data as string, options);
+ case supportedDocTypes.diagram: return Docs.Create.DiagramDocument(undefined, { text: data as unknown as RichTextField, ...options}); // text: can take a string or RichTextField but it's typed for RichTextField.
// case supportedDocumentTypes.dataviz:
// {
@@ -466,7 +466,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// this.addCSVForAnalysis(doc, id);
// return doc;
// }
- case supportedDocumentTypes.script: {
+ case supportedDocTypes.script: {
const result = !(data as string).trim() ? ({ compiled: false, errors: [] } as CompileError) : CompileScript(data as string, {});
const script_field = result.compiled ? new ScriptField(result, undefined, data as string) : undefined;
const sdoc = Docs.Create.ScriptingDocument(script_field, options);
@@ -477,12 +477,13 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
});
return sdoc;
}
- case supportedDocumentTypes.collection: {
- const arr = this.createCollectionWithChildren(data as parsedDoc[], true).filter(d=>d).map(d => d!);
- const collOpts = { ...options, _layout_fitWidth: true, _width:300, _height: 300, _freeform_backgroundGrid: true };
+ case supportedDocTypes.collection: {
+ const arr = this.createCollectionWithChildren(JSON.parse(data as string) as parsedDoc[], true).filter(d=>d).map(d => d!);
+ const collOpts = { _width:300, _height: 300, _layout_fitWidth: true, _freeform_backgroundGrid: true, ...options, };
return (() => {
switch (options.type_collection) {
case CollectionViewType.Tree: return Docs.Create.TreeDocument(arr, collOpts);
+ case CollectionViewType.Stacking: return Docs.Create.StackingDocument(arr, collOpts);
case CollectionViewType.Masonry: return Docs.Create.MasonryDocument(arr, collOpts);
case CollectionViewType.Card: return Docs.Create.CardDeckDocument(arr, collOpts);
case CollectionViewType.Carousel: return Docs.Create.CarouselDocument(arr, collOpts);