From 6081078bf7fa1ddfbe43dad7a8c140c400a19c36 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Thu, 9 May 2024 10:29:51 -0400 Subject: [PATCH] Improve prompt starting message --- pages/api/bin/openai.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pages/api/bin/openai.js b/pages/api/bin/openai.js index 009b5921..0e419dd4 100644 --- a/pages/api/bin/openai.js +++ b/pages/api/bin/openai.js @@ -1,5 +1,17 @@ import OpenAI from 'openai'; +const sample = (arr) => arr[Math.floor(Math.random() * arr.length)] + +const messageStarters = [ + "you could build a", + "what if you built a", + "i'd use these parts to build a", + "how about a", + "you could make a", + "as a raccoon, i'd build a", + "i live in the trash and i'd build a", +] + const generateProjectIdea = async (parts) => { let prompt = `I'm running a hardware program around the raspberry pi pico w where high schoolers will build a simple project using the following parts. Please propose a simple project in 1-2 sentences to use as a prompt for the high schoolers to build with: @@ -10,7 +22,8 @@ const generateProjectIdea = async (parts) => { }) prompt += ` - The project should only involve household items. The project should only use sensors provided, and use those sensors for their intended use. For example, an accelerometer cannot be used to measure humidity or tilt.` + The project should only involve household items. The project should only use sensors provided, and use those sensors for their intended use. For example, an accelerometer cannot be used to measure humidity or tilt. Reply in all lowercase. Your response should start with "${sample(messageStarters)}"` + // expects OPENAI_API_KEY const openai = new OpenAI();