Skip to content

Commit

Permalink
sketch out most of a browse pal system (#40)
Browse files Browse the repository at this point in the history
* sketch out most of a browse pal system

* clean up
  • Loading branch information
mcnuttandrew authored Feb 20, 2024
1 parent c42e550 commit a8bcb6b
Show file tree
Hide file tree
Showing 14 changed files with 1,639 additions and 969 deletions.
24 changes: 24 additions & 0 deletions netlify/functions/suggest-name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { genericHandler } from "../utils";

type promptInput = { inputColors: string[]; background: string };
const prompt = (pal: promptInput) => `
You are a color expert. You expertly name color palettes. You take in a list of colors presented as hex code and return a name for the palette.
Present your names a list of JSON strings. They should have a type like string[]. Only respond with one array consisting of 4 name suggestions. Do not offer any other response.
Palette: ${JSON.stringify(pal.inputColors)}
Background Color: ${pal.background}
Your response: `;
export const handler = genericHandler<promptInput>(prompt, (x) => {
const input = JSON.parse(x);
const inputColors = input.colors;
if (
!Array.isArray(inputColors) ||
!inputColors.every((x) => typeof x === "string")
) {
throw new Error("Not an array");
}
const background = input.background;
if (typeof background !== "string") {
throw new Error("No background");
}
return { inputColors, background };
});
Loading

0 comments on commit a8bcb6b

Please sign in to comment.