-
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.
- Loading branch information
1 parent
52677d5
commit 946bda0
Showing
32 changed files
with
2,836 additions
and
1,646 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
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
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,23 @@ | ||
import { genericHandler } from "../utils"; | ||
|
||
type promptInput = { | ||
lintProgram: string; | ||
}; | ||
const prompt = (pal: promptInput) => ` | ||
# Identity and Task | ||
You are a color expert and domain-specific language programmer. You take in a program written in a JSON DSL that checks for color palettes for errors and suggests some meta data for it. Your task is to suggest a name, description, and fail message for the given program. Description and fail message should be specific clear and thoughtful. The name should be short and descriptive. | ||
# Output format | ||
Your response should be a JSON object with the following structure: {"description: string, "failMessage": string, "name": string}. This must be a valid JSON object. | ||
Prompt: ${JSON.stringify(pal.lintProgram)} | ||
Your response: `; | ||
export const handler = genericHandler<promptInput>(prompt, (x) => { | ||
const input = JSON.parse(x); | ||
const lintProgram = input.lintProgram; | ||
if (typeof lintProgram !== "string") { | ||
throw new Error("No lintProgram"); | ||
} | ||
return { lintProgram }; | ||
}); |
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,77 @@ | ||
import { genericHandler } from "../utils"; | ||
|
||
type promptInput = { | ||
lintPrompt: string; | ||
}; | ||
const prompt = (pal: promptInput) => ` | ||
# Identity | ||
You are a color expert and domain-specific language programmer. You take in a lint prompt and suggest a lint using the following programming language. | ||
# Task and output format | ||
Given a lint prompt, suggest a lint using the color check linting language Your response should be a JSON object written in the following JSON DSL. You must be explicit in your response and include all necessary information. If a list of colors is suggest you should guess what those colors are and give explicit values | ||
Expressions | ||
EXPR = Conjunction | Quantifier | Comparison | Boolean | ||
Conjunctions: | ||
AND: {and: [EXPR, EXPR, ...]} | ||
OR: {or: [EXPR, EXPR, EXPR]} | ||
NOT: {not: EXPR} | ||
Quantifiers: | ||
FORALL: {all: {varbs: Variable[], predicate: EXPR, where?: EXPR, in: Variable | Value[]}} | ||
EXISTS: {exist: {varbs: Variable[], predicate: EXPR, where?: EXPR, in: Variable | Value[]}} | ||
Comparisons (value) => expression | ||
similar: {"similar": {left: Value, right: Value, threshold: Number}} | ||
equal: {"==": {left: Value, right: Value}} | ||
not equal: {"!=": {left: Value, right: Value}} | ||
less than: {"<": {left: Value, right: Value}} | ||
greater than: {">": {left: Value, right: Value}} | ||
Value = Variable | Number | Color | Boolean | ||
Variable = string | colors | background | ||
Operations: | ||
*|+|/|-: {left: Number | Variable, right: Number | Variable} | ||
dist: {left: Color | Variable, right: Color | Variable, space: COLOR_SPACE } | ||
deltaE: {left: Color | Variable, right: Color | Variable, algorithm: '2000' | etc } | ||
contrast: {left: Color | Variable, right: Color | Variable, algorithm: | "APCA" | "WCAG21" | "Michelson" | "Weber" | "Lstar" | "DeltaPhi"} | ||
count: {count: Variable | Number[] | Color[]} | ||
sum|min|max|mean|first|last|extent: {sum: Variable | Number[]} | ||
toColor: {toColor: variableName, space: 'lab' | 'hsl' | etc, channel: 'a' | 'b' | 'l' | etc} | ||
cvd_sim: {cvd_sim: variableName, type: 'protanomaly' | 'deuteranomaly' | 'tritanopia' | 'grayscale'} | ||
name: {name: variableName} | ||
map|sort: {map: Variable | Value[], func: Operation} | ||
filter: {filter: Variable | Value[], func: EXPR} | ||
Example prompt: All colors should be color blind friendly for deuteranopia | ||
Example Result: | ||
{"not": {"exist": { | ||
"in": "colors", | ||
"varbs": ["a", "b"], | ||
"predicate": { | ||
"!=": {"left": { "cvd_sim": "a", "type": "deuteranopia" }, "right": { "cvd_sim": "b", "type": "deuteranopia" } | ||
}}}}} | ||
Example prompt: Colors should not be extreme | ||
Example Result: | ||
{"all": { | ||
"in": "colors", | ||
"varb": "a", | ||
"predicate": { | ||
"all": {"in": ["#000000", "#ffffff"], "varb": "b", | ||
"predicate": { "!=": { "left": "a", "right": "b" } }, | ||
}}}} | ||
Prompt: ${JSON.stringify(pal.lintPrompt)} | ||
Your response: `; | ||
export const handler = genericHandler<promptInput>(prompt, (x) => { | ||
const input = JSON.parse(x); | ||
const lintPrompt = input.lintPrompt; | ||
if (typeof lintPrompt !== "string") { | ||
throw new Error("No lintPrompt"); | ||
} | ||
return { lintPrompt }; | ||
}); |
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
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
Oops, something went wrong.