From 832593c3189008aa9af49e3350228a50f0503c59 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 30 Dec 2024 16:50:05 +0000 Subject: [PATCH 1/2] Added a few new goodies, and another attempt to fix the sound button (which worked this time!) --- lib/flavor.js | 84 +++++++++++++++++----------------- src/app/api/ideagen/route.js | 42 ++++++++--------- src/components/sound-button.js | 1 + 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/lib/flavor.js b/lib/flavor.js index e4a77ad1..f5a24eb0 100644 --- a/lib/flavor.js +++ b/lib/flavor.js @@ -1,60 +1,62 @@ export const sample = (arr, seed = '') => { - const random = seed === '' ? Math.random() : pseudoRandom(seed) - return arr[Math.floor(random * arr.length)] + const random = seed === '' ? Math.random() : pseudoRandom(seed) + return arr[Math.floor(random * arr.length)] } export const loadingSpinners = ['compass.svg', 'skull.svg'] const loadingMsg = [''] const pseudoRandom = (seed) => { - return Math.sin(seed * 10000) / 2 + 0.5 + return Math.sin(seed * 10000) / 2 + 0.5 } export const zeroMessage = [ - 'Arrr, ye be flat broke!', - "Ye're as poor as a landlubber!", - "Ye've got no doubloons!", - "Can't buy nothin' with nothin'!", + 'Arrr, ye be flat broke!', + "Ye're as poor as a landlubber!", + "Ye've got no doubloons!", + "Can't buy nothin' with nothin'!", ] export const purchaseWords = [ - // Don't uniquify this! Some are rarer than others - 'Acquire', - 'Acquire', - 'Buye', - 'Buye', - 'Obtain', - 'Obtain', - 'Procure', - 'Procure', - 'Steal', - 'Plunder', - 'Plunder', - 'Plunder', - 'BitTorrent', + // Don't uniquify this! Some are rarer than others + 'Acquire', + 'Acquire', + 'Buye', + 'Buye', + 'Obtain', + 'Obtain', + 'Procure', + 'Procure', + 'Steal', + 'Summon', + 'Plunder', + 'Plunder', + 'Plunder', + 'BitTorrent', ] export const cantAffordWords = [ - 'too expensive...', - // "can't afford this...", - "can't afford...", - 'unaffordable...', - 'out of reach...', - 'need doubloons...', - 'too pricey...', - // "when you're richer...", + 'too expensive...', + // "can't afford this...", + "can't afford...", + 'unaffordable...', + 'out of reach...', + 'need doubloons...', + 'too pricey...', + 'not quite yet...', + // "when you're richer...", ] export const shopBanner = [ - 'buy something or get out!', - 'spend your doubloons here!', - 'get that booty!', - 'NO REFUNDS', - 'feeling overburdened by money?', - 'plundered from the best dead adventurers in the land', - 'we accept doubloons and PiratePay™', - 'YARR', - '🏴‍☠️', - "you wouldn't download a ship...", - "These prices are walkin' the plank!", -] + 'buy something or get out!', + 'spend your doubloons here!', + 'get that booty!', + 'NO REFUNDS', + 'feeling overburdened by money?', + 'plundered from the best dead adventurers in the land', + 'we accept doubloons and PiratePay™', + 'YARR', + '🏴‍☠️', + "you wouldn't download a ship...", + "These prices are walkin' the plank!", +] \ No newline at end of file diff --git a/src/app/api/ideagen/route.js b/src/app/api/ideagen/route.js index 8f9aedce..e64844a6 100644 --- a/src/app/api/ideagen/route.js +++ b/src/app/api/ideagen/route.js @@ -65,25 +65,23 @@ import { openai } from '@ai-sdk/openai' // This method must be named GET export async function POST(request) { - const response = await streamText({ - model: openai('gpt-4o'), - messages: [ - { - role: 'system', - content: - 'You are an embedded model that takes a project idea and outputs an action plan of how one could go about building it to a creative developer, preferably in about 4 bullet points. Your explaination should not include dumb stuff like "testing" but should describe the subsystems and how they will fit together. Do not preface your answer. There is no option to converse - your first answer will be displayed on the website. Do not wafffle. Use plaintext only. No markdown. Keep it extremely concise and technical. Remember to number the bullet points!', - }, - { - role: 'user', - content: (await request.json()).msg, - }, - ], - stream: true, - }) - // Respond with the stream - return response.toTextStreamResponse({ - headers: { - 'Content-Type': 'text/event-stream', - }, - }) -} + const response = await streamText({ + model: openai('gpt-4o'), + messages: [{ + role: 'system', + content: 'You are an embedded model that takes a project idea and outputs an action plan of how one could go about building it to a creative developer, preferably in about 4 bullet points. Your explaination should not include dumb stuff like "testing" but should describe the subsystems and how they will fit together. Do not preface your answer. There is no option to converse - your first answer will be displayed on the website. Do not wafffle. Use plaintext only. No markdown. Keep it extremely concise and technical. Remember to number the bullet points! The project idea may seem nonsensical, but try to make it work.', + }, + { + role: 'user', + content: (await request.json()).msg, + }, + ], + stream: true, + }) + // Respond with the stream + return response.toTextStreamResponse({ + headers: { + 'Content-Type': 'text/event-stream', + }, + }) +} \ No newline at end of file diff --git a/src/components/sound-button.js b/src/components/sound-button.js index abaccced..07c381c7 100644 --- a/src/components/sound-button.js +++ b/src/components/sound-button.js @@ -160,6 +160,7 @@ const SoundButton = () => { {soundState ? theFlags() : ''}
From ae9f5072fe428ada06a93e02b35ce47e4651955e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 31 Dec 2024 18:19:29 +0000 Subject: [PATCH 2/2] Pretty Signed-off-by: Ben --- lib/flavor.js | 86 +++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/flavor.js b/lib/flavor.js index f5a24eb0..d3f4806e 100644 --- a/lib/flavor.js +++ b/lib/flavor.js @@ -1,62 +1,62 @@ export const sample = (arr, seed = '') => { - const random = seed === '' ? Math.random() : pseudoRandom(seed) - return arr[Math.floor(random * arr.length)] + const random = seed === '' ? Math.random() : pseudoRandom(seed) + return arr[Math.floor(random * arr.length)] } export const loadingSpinners = ['compass.svg', 'skull.svg'] const loadingMsg = [''] const pseudoRandom = (seed) => { - return Math.sin(seed * 10000) / 2 + 0.5 + return Math.sin(seed * 10000) / 2 + 0.5 } export const zeroMessage = [ - 'Arrr, ye be flat broke!', - "Ye're as poor as a landlubber!", - "Ye've got no doubloons!", - "Can't buy nothin' with nothin'!", + 'Arrr, ye be flat broke!', + "Ye're as poor as a landlubber!", + "Ye've got no doubloons!", + "Can't buy nothin' with nothin'!", ] export const purchaseWords = [ - // Don't uniquify this! Some are rarer than others - 'Acquire', - 'Acquire', - 'Buye', - 'Buye', - 'Obtain', - 'Obtain', - 'Procure', - 'Procure', - 'Steal', - 'Summon', - 'Plunder', - 'Plunder', - 'Plunder', - 'BitTorrent', + // Don't uniquify this! Some are rarer than others + 'Acquire', + 'Acquire', + 'Buye', + 'Buye', + 'Obtain', + 'Obtain', + 'Procure', + 'Procure', + 'Steal', + 'Summon', + 'Plunder', + 'Plunder', + 'Plunder', + 'BitTorrent', ] export const cantAffordWords = [ - 'too expensive...', - // "can't afford this...", - "can't afford...", - 'unaffordable...', - 'out of reach...', - 'need doubloons...', - 'too pricey...', - 'not quite yet...', - // "when you're richer...", + 'too expensive...', + // "can't afford this...", + "can't afford...", + 'unaffordable...', + 'out of reach...', + 'need doubloons...', + 'too pricey...', + 'not quite yet...', + // "when you're richer...", ] export const shopBanner = [ - 'buy something or get out!', - 'spend your doubloons here!', - 'get that booty!', - 'NO REFUNDS', - 'feeling overburdened by money?', - 'plundered from the best dead adventurers in the land', - 'we accept doubloons and PiratePay™', - 'YARR', - '🏴‍☠️', - "you wouldn't download a ship...", - "These prices are walkin' the plank!", -] \ No newline at end of file + 'buy something or get out!', + 'spend your doubloons here!', + 'get that booty!', + 'NO REFUNDS', + 'feeling overburdened by money?', + 'plundered from the best dead adventurers in the land', + 'we accept doubloons and PiratePay™', + 'YARR', + '🏴‍☠️', + "you wouldn't download a ship...", + "These prices are walkin' the plank!", +]