diff options
author | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-11-13 01:43:37 -0500 |
---|---|---|
committer | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-11-13 01:43:37 -0500 |
commit | 84cfc17b6b743a498f0f3b8680d262c3695e00fa (patch) | |
tree | 49ad973412e2061cc4509496d9e4c030516958bf /src | |
parent | be60b14248de71d44e1a3195afab2c4d74c10363 (diff) |
4 hours later...dashboard i think working
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx | 24 | ||||
-rw-r--r-- | src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts | 122 |
2 files changed, 128 insertions, 18 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index f6b284bdb..594736fbc 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -472,19 +472,37 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { doc = DocCast(Docs.Create.ImageDocument(data, options)); break; case 'equation': - doc = DocCast(Docs.Create.EquationDocument('', options)); + // make more advanced + doc = DocCast(Docs.Create.EquationDocument(data, options)); break; case 'noteboard': + // COME BACK doc = DocCast(Docs.Create.NoteTakingDocument([], options)); break; case 'simulation': + // make more advanced doc = DocCast(Docs.Create.SimulationDocument(options)); break; case 'collection': { + // COME BACK const arr = await this.createCollectionWithChildren(data); options._layout_fitWidth = true; options._freeform_backgroundGrid = true; - doc = DocCast(Docs.Create.FreeformDocument(arr, options)); + if (options.type_collection == 'tree') { + doc = DocCast(Docs.Create.TreeDocument(arr, options)); + } else if (options.type_collection == 'masonry') { + doc = DocCast(Docs.Create.MasonryDocument(arr, options)); + } else if (options.type_collection == 'card') { + doc = DocCast(Docs.Create.CardDeckDocument(arr, options)); + } else if (options.type_collection == 'carousel') { + doc = DocCast(Docs.Create.CarouselDocument(arr, options)); + } else if (options.type_collection == '3d-carousel') { + doc = DocCast(Docs.Create.Carousel3DDocument(arr, options)); + } else if (options.type_collection == 'multicolumn') { + doc = DocCast(Docs.Create.CarouselDocument(arr, options)); + } else { + doc = DocCast(Docs.Create.FreeformDocument(arr, options)); + } break; } case 'web': @@ -494,9 +512,11 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { doc = this.createComparison(data, options); break; case 'diagram': + // come back doc = Docs.Create.DiagramDocument(options); break; case 'audio': + // come back doc = Docs.Create.AudioDocument(data, options); break; case 'map': diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts index 810f763af..d35dd0e1d 100644 --- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts +++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts @@ -6,6 +6,30 @@ import { DocumentOptions } from '../../../../documents/Documents'; const example = [ { + doc_type: 'equation', + title: 'quadratic', + data: 'x^2 + y^2 = 3', + width: 300, + height: 300, + }, + { + doc_type: 'collection', + title: 'Advanced Biology', + data: [ + { + doc_type: 'text', + title: 'Cell Structure', + data: 'Cells are the basic building blocks of all living organisms.', + width: 300, + height: 300, + }, + ], + backgroundColor: '#00ff00', + width: 600, + height: 600, + type_collection: 'freeform', + }, + { doc_type: 'image', title: 'experiment', data: 'https://plus.unsplash.com/premium_photo-1694819488591-a43907d1c5cc?q=80&w=2628&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', @@ -75,6 +99,13 @@ const example = [ height: 300, }, { + doc_type: 'simulation', + title: 'Physics simulation', + data: '', + width: 300, + height: 300, + }, + { doc_type: 'comparison', title: 'WWI vs. WWII', data: [ @@ -101,13 +132,6 @@ const example = [ title: 'Science Collection', data: [ { - doc_type: 'web', - title: 'Brown University Wikipedia', - data: 'https://en.wikipedia.org/wiki/Brown_University', - width: 300, - height: 300, - }, - { doc_type: 'flashcard', title: 'Photosynthesis', data: [ @@ -131,6 +155,13 @@ const example = [ height: 300, }, { + doc_type: 'web', + title: 'Brown University Wikipedia', + data: 'https://en.wikipedia.org/wiki/Brown_University', + width: 300, + height: 300, + }, + { doc_type: 'text', title: 'Water Cycle', data: 'The continuous movement of water on, above, and below the Earth’s surface.', @@ -152,10 +183,12 @@ const example = [ backgroundColor: '#00ff00', width: 600, height: 600, + type_collection: 'freeform', }, ], width: 600, height: 600, + type_collection: 'freeform', }, ]; @@ -173,10 +206,11 @@ const docInstructions = { deck: 'A decks data is an array of flashcards.', image: 'A URL to an image for data. Example: "https://example.com/image.jpg"', web: 'A URL to a webpage. Example: https://en.wikipedia.org/wiki/Brown_University', - equation: 'Create a equation document.', + equation: 'Create an equation document, not a text document. Data is math equation.', noteboard: 'Create a noteboard document', - comparison: 'Create a comparison document', + comparison: 'Create a comparison document - in type_collection specify the type of collection: masonry, freeform, tree, carousel.', simulation: 'Create a simulation document', + audio: 'A url to an audio recording. Example: ', } as const; const createDocToolParams = [ @@ -222,6 +256,12 @@ const createDocToolParams = [ description: 'The height of the document in pixels.', required: true, }, + { + name: 'type_collection', + type: 'string', + description: 'Either freeform, card, carousel, 3d-carousel, multicolumn, multirow, linear, map, notetaking, schema, stacking, grid, tree, or masonry.', + required: false, + }, ] as const; const createListDocToolParams = [ @@ -246,14 +286,55 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> { constructor(addLinkedDoc: (doc_type: string, data: string, options: DocumentOptions, id: string) => void) { super( 'createDoc', - 'Creates one or more documents that best fit users request with input following the example below. Or creates a dashboard of many documents/collections.', + 'Creates one or more documents that best fit the user’s request. If the user requests a "dashboard," first call search tool and then generate a variety of document types individually, each with different content and color schemes. For example, create multiple individual documents like "text," "deck," "web," "image," "equation," and "comparison." ' + + 'Do not nest all documents within a single collection unless explicitly requested by the user. Instead, create a set of independent documents with diverse document types. Each type should appear separately unless specified otherwise.', createListDocToolParams, - 'Modify the data parameter and include title (and optionally color) for the document. Web doc data type must be url from search tool.', - 'Creates one or more documents represented by an array of strings with the provided content based on the instructions ' + - docInstructions + - 'Use if the user wants to create something that aligns with a document type in dash like a flashcard, flashcard deck/stack, or textbox or text document of some sort. Can use after the search tool to save information.' + - 'When user asks for dashboard, create many documents/collections with different colors and texts while listening to their preferences, after using search tool to create a dashboard.' + 'Use the "data" parameter for document content and include title, color, and document dimensions. Ensure web documents use URLs from the search tool if relevant. Each document in a dashboard should be unique and well-differentiated in type and content, without repetition of similar types in any single collection.', + 'When creating a dashboard, ensure that it consists of a broad range of document types. Include a variety of documents, such as text, web, deck, comparison, image, simulation, and equation documents, each with distinct titles and colors, following the user’s preferences. ' + + 'Do not overuse collections or nest all document types within a single collection; instead, represent document types individually. Use this example for reference: ' + + finalJsonString + + '. Create dashboard after search tool.' ); + + // super( + // 'createDoc', + // 'Creates one or more documents that best fit users request with input following the example below. Or creates a dashboard of many documents/collections with this as an example: ' + finalJsonString, + // createListDocToolParams, + // 'Modify the data parameter and include title (and optionally color) for the document. Web doc data type must be url from search tool.', + // 'Creates one or more documents represented by an array of strings with the provided content based on the instructions ' + + // docInstructions + + // 'Use if the user wants to create something that aligns with a document type in dash like a flashcard, flashcard deck/stack, or textbox or text document of some sort. Can use after the search tool to save information.' + + // 'When user asks for dashboard, create many documents/collections with different colors and texts while listening to their preferences, after using search tool to create a dashboard.' + // ); + // this._addLinkedDoc = addLinkedDoc; + + // super( + // 'createDoc', + // 'Creates one or more documents based on the user’s request. If the user asks for a "dashboard," generate multiple documents of different types, such as "text," "flashcard," "image," "web," "comparison," and "collection," and include no more than three web documents unless specified otherwise. For a single document request (like "a text document"), create only the requested document type, without extra templates. Follow the examples below to understand the structure of various document types and their required properties.', + // createListDocToolParams, + // 'Use the "data" parameter to specify document content and include the title (and optionally colors) for each document. For web documents, use a URL from a search tool if applicable.' + + // 'For dashboards, create a diverse array of documents including text, flashcard decks, images, comparisons, and collections, with a mix of colors and unique titles, adhering to the user’s preferences. Example structures are provided for both dashboards and individual document types.' + + // 'Examples:' + + // finalJsonString, + // '' + // ); + + // super( + // 'createDoc', + // 'Creates one or more documents that best fit users request with input following the example below. Or creates a dashboard for the user; there must be different kinds of documents. If the user asks for "a" document, only make one since it is singular - not an additional template one or more documents.', + // createListDocToolParams, + // 'Modify the data parameter and include title (and optionally color) for the document. ' + + // 'Web doc data type must be url from search tool. ' + + // 'Creates one or more documents represented by an array of strings with the provided content based on the instructions ' + + // docInstructions + + // //'. If user asks for dashboard, create many documents/collections, including text, web, image, flashcard, deck, comparison, and collection, after calling the search tool following this example but only have three websites max: ' + + // //'Use if the user wants to create something that aligns with a document type in dash like a flashcard, flashcard deck/stack, or textbox or text document of some sort. Can use after the search tool to save information. If use after the search tool, do not use than more than 3 websites unless specified if dashboard; have text documents, flashcards, and more documents.' + + // // 'When user asks for dashboard, create many documents/collections of different types, such as text, web, flashcard, with different colors and texts while listening to their preferences, after using search tool to create a dashboard. Documents, such as text and web, should not all be in a collection unless specified. Do not have too many websites, and all websites do not need to be in one collection. An example of a dashboard is ' + + // // finalJsonString + // '. If user asks for dashboard, first use search tool. Then create text, web, flashcard, collections, and comparison documents. There absolutely must be different kinds of documents.' + + // 'Do not only have web documents for dashboard; have other kinds of documents. Follow this example: ' + + // finalJsonString + // ); this._addLinkedDoc = addLinkedDoc; } @@ -266,7 +347,16 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> { this._addLinkedDoc( doc['doc_type'], doc['data'], - { title: doc['title'], backgroundColor: doc['backgroundColor'], text_fontColor: doc['font_color'], _width: doc['width'], _height: doc['height'], _layout_fitWidth: false, _layout_autoHeight: true }, + { + title: doc['title'], + backgroundColor: doc['backgroundColor'], + text_fontColor: doc['font_color'], + _width: doc['width'], + _height: doc['height'], + type_collection: doc['type_collection'], + _layout_fitWidth: false, + _layout_autoHeight: true, + }, uuidv4() ); }); |