Skip to content

Commit

Permalink
lightly improved prompts for suggest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Feb 29, 2024
1 parent 0cdaf4e commit 480ef85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
16 changes: 14 additions & 2 deletions netlify/functions/suggest-fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -30,5 +37,10 @@ export const handler = genericHandler<promptInput>(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 };
});
2 changes: 1 addition & 1 deletion netlify/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}),
Expand Down
7 changes: 5 additions & 2 deletions src/lib/api-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]<SimplePal>(`suggest-fix`, body, true);
}

Expand Down

0 comments on commit 480ef85

Please sign in to comment.