-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sketch out most of a browse pal system
- Loading branch information
1 parent
c42e550
commit 09d76fc
Showing
14 changed files
with
1,678 additions
and
969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
}); |
Oops, something went wrong.