From 8f5fa4fe9f4b36a347d6a4b5252a803d64765d38 Mon Sep 17 00:00:00 2001 From: Mark Goltsman Date: Sun, 20 Oct 2024 12:27:34 -0400 Subject: [PATCH] Added mindmap page --- .env | 1 + .gitignore | 1 + src/api/openAI/openAI-API.ts | 28 +++++++++++++++++ src/app/mindmap/page.tsx | 58 ++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .env create mode 100644 src/api/openAI/openAI-API.ts create mode 100644 src/app/mindmap/page.tsx diff --git a/.env b/.env new file mode 100644 index 0000000..40198d2 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +OPENAI_API_KEY="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" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9fd9904..1bb7ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.pnp .pnp.js .yarn/install-state.gz +.env # testing /coverage diff --git a/src/api/openAI/openAI-API.ts b/src/api/openAI/openAI-API.ts new file mode 100644 index 0000000..4ddc94b --- /dev/null +++ b/src/api/openAI/openAI-API.ts @@ -0,0 +1,28 @@ +import { OpenAI } from "openai"; +import dotenv from "dotenv"; + +dotenv.config(); + +console.log(process.env); + +const openAIClient = new OpenAI({ + apiKey: "OPENAI_API_KEY", +}); + +const systemPrompt = + "You will be given a list of links. Each link contains JSON file. In each JSON file there a 'url' field that contains a class/course material from university. Your task is to return a one short sentence question about any of these materials."; + +export default async function getSubtask(files: string[]) { + const chatCompletion = await openAIClient.chat.completions.create({ + model: "gpt-4o-mini", + messages: [ + { role: "system", content: systemPrompt }, + { + role: "user", + content: `${files.toString()}`, + }, + ], + }); + + return chatCompletion.choices[0].message.content; +} diff --git a/src/app/mindmap/page.tsx b/src/app/mindmap/page.tsx new file mode 100644 index 0000000..dcaf230 --- /dev/null +++ b/src/app/mindmap/page.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import './App.css'; // Make sure to add styles here + +// Example of notes array (similar to the content in the image) +const notes = [ + "The average attention span is 8.25 s", + "E = mc^2", + "We are a team of dreamers!", + "Our names are Kaz, Tymur, Daniil, and Mark!", + "LET'S GO TECH", + "In my free time, I do poster design for my dorm room" +]; + +// Utility function to generate random sizes and positions +const getRandomStyles = () => { + const randomWidth = Math.floor(Math.random() * (200 - 100 + 1)) + 100; // Width between 100 and 200px + const randomHeight = Math.floor(Math.random() * (150 - 80 + 1)) + 80; // Height between 80 and 150px + const randomX = Math.floor(Math.random() * 40); // Left margin (to simulate shifting) + const randomY = Math.floor(Math.random() * 20); // Top margin (for shifting vertically) + const randomBackground = getRandomColor(); // Assign a random background color + + return { + width: `${randomWidth}px`, + height: `${randomHeight}px`, + marginLeft: `${randomX}px`, + marginTop: `${randomY}px`, + backgroundColor: randomBackground, + borderRadius: '20px', + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + fontSize: '1.1rem', + padding: '10px', + color: '#fff', // White text color + fontWeight: 'bold' + }; +}; + +// Helper function to generate a random color from a predefined list +const getRandomColor = () => { + const colors = ['#F7DC6F', '#E74C3C', '#48C9B0', '#85C1E9', '#F1948A', '#5DADE2']; + return colors[Math.floor(Math.random() * colors.length)]; +}; + +export default function Landing() { + return ( +
+

Your personal mind space

+
+ {notes.map((note, index) => ( +
+ {note} +
+ ))} +
+
+ ); +} \ No newline at end of file