From 480ef8584a9f13a7f56d36a3e8b0044b07a03512 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Thu, 29 Feb 2024 13:02:08 -0800 Subject: [PATCH] lightly improved prompts for suggest fix --- netlify/functions/suggest-fix.ts | 16 ++++++++++++++-- netlify/utils.ts | 2 +- src/lib/api-calls.ts | 7 +++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/netlify/functions/suggest-fix.ts b/netlify/functions/suggest-fix.ts index 01e68daa..f1583210 100644 --- a/netlify/functions/suggest-fix.ts +++ b/netlify/functions/suggest-fix.ts @@ -4,11 +4,18 @@ type promptInput = { inputColors: string[]; background: string; error: string; + context: string; }; const prompt = (pal: promptInput) => ` -You are a color expert. You take in a color palette and an error it has and fix it. Present your fixes as a single JSON object that describes the color palette. It should have a type like {"background: string; colors: string[]}. Do not offer any other response. YOU MUST GIVE A VALID JSON OBJECT. If you do not, you will be banned. +You are a color expert. You take in a color palette and an error it has and fix it. Your fixes should be clever but respect the original vibe of the palette. Present your fixes as a single JSON object that describes the color palette. It should have a type like {"background: string; colors: string[]}. +Addition criteria: +- As much as possible, do not provide fixes by simply removing a color from the palette. +- DO NOT JUST RETURN THE SAME COLORS. That is not a fix. You must change at least one color. + +Do not offer any other response. YOU MUST GIVE A VALID JSON OBJECT. If you do not, you will be banned. Palette: ${JSON.stringify(pal.inputColors)} +Context: ${JSON.stringify(pal.context)} Background Color: ${JSON.stringify(pal.background)} Error: ${JSON.stringify(pal.error)} @@ -30,5 +37,10 @@ export const handler = genericHandler(prompt, (x) => { if (typeof error !== "string") { throw new Error("No error"); } - return { inputColors, background, error }; + const context = input.context; + if (typeof context !== "string") { + throw new Error("No context"); + } + + return { inputColors, background, error, context }; }); diff --git a/netlify/utils.ts b/netlify/utils.ts index a5cc9f24..c71c302d 100644 --- a/netlify/utils.ts +++ b/netlify/utils.ts @@ -24,7 +24,7 @@ const engines = { messages: [{ role: "user", content: prompt }], model: "gpt-3.5-turbo", n: 1, - temperature: 0.1, + temperature: 0.7, // model: "gpt-4", // model: "gpt-4-turbo-preview", }), diff --git a/src/lib/api-calls.ts b/src/lib/api-calls.ts index af3a2ff0..743cdb86 100644 --- a/src/lib/api-calls.ts +++ b/src/lib/api-calls.ts @@ -114,8 +114,11 @@ export function suggestContextualAdjustments( } export function suggestFix(currentPal: Palette, msg: string, engine: Engine) { - const error = `${summarizePal(currentPal)}\n\n${msg}`; - const body = JSON.stringify({ ...palToString(currentPal), error }); + const body = JSON.stringify({ + ...palToString(currentPal), + error: msg, + context: summarizePal(currentPal), + }); return engineToScaffold[engine](`suggest-fix`, body, true); }