aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools
diff options
context:
space:
mode:
authoralyssaf16 <alyssa_feinberg@brown.edu>2024-10-30 22:17:57 -0400
committeralyssaf16 <alyssa_feinberg@brown.edu>2024-10-30 22:17:57 -0400
commitcd54cba6269dbc4e10b457fe7eddd5114a9d301e (patch)
tree91c0406991193b6f8667db09f4eec4e9afcb689b /src/client/views/nodes/chatbot/tools
parentf37c99bb332bba274dc93b7509696c6d61c3dd21 (diff)
version 5 working
Diffstat (limited to 'src/client/views/nodes/chatbot/tools')
-rw-r--r--src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts91
1 files changed, 27 insertions, 64 deletions
diff --git a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
index a1924ed82..0b83ff24f 100644
--- a/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
+++ b/src/client/views/nodes/chatbot/tools/CreateDocumentTool.ts
@@ -3,18 +3,19 @@ import { BaseTool } from './BaseTool';
import { Observation } from '../types/types';
import { ParametersType } from '../types/tool_types';
import { DocumentOptions } from '../../../../documents/Documents';
-const jsonData = [
+
+const example = [
{
doc_type: 'collection',
title: 'Science Collection',
- data: JSON.stringify([
+ data: [
{
doc_type: 'flashcard',
title: 'Photosynthesis',
- data: JSON.stringify({ 'What is photosynthesis?': 'The process by which plants make food.' }),
+ data: { 'What is photosynthesis?': 'The process by which plants make food.' },
+ backgroundColor: '#00ff00',
width: 300,
height: 300,
- backgroundColor: '#0000FF',
},
{
doc_type: 'text',
@@ -26,11 +27,12 @@ const jsonData = [
{
doc_type: 'collection',
title: 'Advanced Biology',
- data: JSON.stringify([
+ data: [
{
doc_type: 'flashcard',
title: 'Respiration',
- data: JSON.stringify({ 'What is respiration?': 'Conversion of oxygen and glucose to energy.' }),
+ data: { 'What is respiration?': 'Conversion of oxygen and glucose to energy.' },
+ backgroundColor: '#00ff00',
width: 300,
height: 300,
},
@@ -41,67 +43,23 @@ const jsonData = [
width: 300,
height: 300,
},
- ]),
- width: 600,
- height: 600,
- },
- ]),
- width: 600,
- height: 600,
- },
- {
- doc_type: 'collection',
- title: 'Math Collection',
- data: JSON.stringify([
- {
- doc_type: 'flashcard',
- title: 'Pythagorean Theorem',
- data: JSON.stringify({ 'What is the Pythagorean theorem?': 'In a right triangle, a² + b² = c².' }),
- width: 300,
- height: 300,
- backgroundColor: '#FFA500',
- },
- {
- doc_type: 'text',
- title: 'Calculus Introduction',
- data: 'Calculus is the mathematical study of continuous change.',
- width: 300,
- height: 300,
- },
- {
- doc_type: 'collection',
- title: 'Algebra Concepts',
- data: JSON.stringify([
- {
- doc_type: 'flashcard',
- title: 'Quadratic Formula',
- data: JSON.stringify({ 'What is the quadratic formula?': 'x = (-b ± √(b² - 4ac)) / 2a' }),
- width: 300,
- height: 300,
- },
- {
- doc_type: 'text',
- title: 'Linear Equations',
- data: 'A linear equation is an equation between two variables that gives a straight line when plotted.',
- width: 300,
- height: 300,
- },
- ]),
+ ],
width: 600,
height: 600,
},
- ]),
+ ],
width: 600,
height: 600,
},
];
-// Stringify the entire object if needed for your API
-const finalJsonString = JSON.stringify(jsonData);
+// Stringify the entire structure for transmission if needed
+const finalJsonString = JSON.stringify(example);
const docInstructions = {
collection: {
- description: 'A recursive collection of documents. Each document can be a "text", "flashcard", "image", "web", or another "collection".',
+ description:
+ 'A recursive collection of documents as a stringified array. Each document can be a "text", "flashcard", "image", "web", "image", "comparison", "equation", "noteboard", "simulation", "diagram", "map", "screengrab", "webcam", "button", or another "collection".',
example: finalJsonString,
// example: [
// {
@@ -156,6 +114,10 @@ const docInstructions = {
flashcardDeck: 'A collection of flashcards under a common theme.',
image: 'A URL to an image. Example: "https://example.com/image.jpg"',
web: 'A URL to a webpage. Example: "https://example.com"',
+ equation: 'Create a equation document.',
+ noteboard: 'Create a noteboard document',
+ comparison: 'Create a comparison document',
+ simulation: 'Create a simulation document',
} as const;
const createDocToolParams = [
@@ -211,8 +173,9 @@ const createListDocToolParams = [
'Array of documents in stringified JSON format. Each item in the array should be an individual stringified JSON object. Each document can be of type "text", "flashcard", "image", "web", or "collection" (for nested documents). ' +
'Use this structure for nesting collections within collections. Each document should follow the structure in ' +
createDocToolParams +
- '. Example: ' + finalJsonString,
- //Example: ["{"doc_type":"collection","title":"Science Topics","data":"[\\"{\\\\"doc_type\\\\":\\\\"text\\\\",\\\\"title\\\\":\\\\"Photosynthesis\\\\",\\\\"background_color\\\\":\\\\"#0000FF\\\\",\\\\"data\\\\":\\\\"Photosynthesis is the process by which plants make food.\\\\",\\\\"width\\\\":300,\\\\"height\\\\":300}\\",\\"{\\\\"doc_type\\\\":\\\\"collection\\\\",\\\\"title\\\\":\\\\"Advanced Biology\\\\",\\\\"data\\\\":\\\\"[\\\\"{\\\\"doc_type\\\\":\\\\"flashcard\\\\",\\\\"title\\\\":\\\\"Respiration\\\\",\\\\"data\\\\":{\\\\"What is respiration?\\\\":\\\\"Conversion of oxygen and glucose to energy.\\\\"},\\\\"width\\\\":300,\\\\"height\\\\":300}\\",\\\\"{\\\\"doc_type\\\\":\\\\"text\\\\",\\\\"title\\\\":\\\\"Cell Structure\\\\",\\\\"data\\\\":\\\\"Cells are the basic building blocks of all living organisms.\\\\",\\\\"width\\\\":300,\\\\"height\\\\":300}\\"]\\\\",\\\\"width\\\\":600,\\\\"height\\\\":600}\\"]","width":600,"height":600}"]',
+ '. Example: ' +
+ finalJsonString,
+ //["{"doc_type":"collection","title":"Science Topics","data":"[\\"{\\\\"doc_type\\\\":\\\\"text\\\\",\\\\"title\\\\":\\\\"Photosynthesis\\\\",\\\\"background_color\\\\":\\\\""#0000FF"\\\\",\\\\"data\\\\":\\\\"Photosynthesis is the process by which plants make food.\\\\",\\\\"width\\\\":300,\\\\"height\\\\":300}\\",\\"{\\\\"doc_type\\\\":\\\\"collection\\\\",\\\\"title\\\\":\\\\"Advanced Biology\\\\",\\\\"data\\\\":\\\\"[\\\\"{\\\\"doc_type\\\\":\\\\"flashcard\\\\",\\\\"title\\\\":\\\\"Respiration\\\\",\\\\"data\\\\":{\\\\"What is respiration?\\\\":\\\\"Conversion of oxygen and glucose to energy.\\\\"},\\\\"width\\\\":300,\\\\"height\\\\":300}\\",\\\\"{\\\\"doc_type\\\\":\\\\"text\\\\",\\\\"title\\\\":\\\\"Cell Structure\\\\",\\\\"data\\\\":\\\\"Cells are the basic building blocks of all living organisms.\\\\",\\\\"width\\\\":300,\\\\"height\\\\":300}\\"]\\\\",\\\\"width\\\\":600,\\\\"height\\\\":600}\\"]","width":600,"height":600}"]',
//["{"doc_type":"collection","title":"Science Topics","data":["{\\"doc_type\\":\\"text\\",\\"title\\":\\"Photosynthesis\\",\\"data\\":\\"Photosynthesis is the process by which plants make food.\\",\\"width\\":300,\\"height\\":300}","{\\"doc_type\\":\\"collection\\",\\"title\\":\\"Advanced Biology\\",\\"data\\":["{\\"doc_type\\":\\"flashcard\\",\\"title\\":\\"Respiration\\",\\"data\\":{\\"What is respiration?\\":\\"Conversion of oxygen and glucose to energy.\\"},\\"width\\":300,\\"height\\":300}","{\\"doc_type\\":\\"text\\",\\"title\\":\\"Cell Structure\\",\\"data\\":\\"Cells are the basic building blocks of all living organisms.\\",\\"width\\":300,\\"height\\":300}"],\\"width\\":600,\\"height\\":600}"],"width":600,"height":600}"]',
required: true,
@@ -244,14 +207,14 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {
*/
try {
- // console.log('EXE' + args.docs);
+ console.log('EXE' + args.docs);
const parsedDoc = JSON.parse(args.docs);
console.log('parsed' + parsedDoc);
- parsedDoc.forEach((firstDoc: string) => {
+ parsedDoc.forEach(doc => {
// console.log('THIS DOC' + firstDoc);
- console.log(typeof firstDoc);
- const doc = JSON.parse(firstDoc);
- console.log('NEW DOC' + doc);
+ // console.log(typeof firstDoc);
+ // const doc = JSON.parse(firstDoc);
+ // console.log('NEW DOC' + doc);
// console.log('TYPE' + doc['doc_type']);
// console.log('WIDTH' + doc['width']);
// console.log('HEIGHT' + doc['height']);
@@ -259,7 +222,7 @@ export class CreateDocTool extends BaseTool<CreateListDocToolParamsType> {
this._addLinkedDoc(
doc['doc_type'],
doc['data'],
- { title: doc['title'], backgroundColor: doc['background_color'], 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'], _layout_fitWidth: false, _layout_autoHeight: true },
uuidv4()
);
});