Skip to content

Commit f6e6a5e

Browse files
committed
morning update before work
1 parent 7bcadfd commit f6e6a5e

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

src/engine/prompts/libraries.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export const CDN = 'https://cdn.skypack.dev/pin/'
99

1010
// note: the version are not randoly chose, those are the versions *suggested* by GPT-3
1111
export const libraries: Record<string, ModulePath> = {
12+
/*
1213
lodash: {
1314
minimal: `Lodash (for data structure utilities)`,
1415
basic: `window._; // Lodash (for data structure utilities)`,
1516
prompt: `import _ from "${CDN}lodash.js";`,
1617
prod: `import _ from "${CDN}[email protected]/mode=imports,min/optimized/lodash.js";`,
1718
},
19+
*/
1820
/*
1921
canvasUtils: {
2022
prompt: `import { canvasUtils } from "${CDN}canvas-utils";`,

src/engine/prompts/script.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,12 @@ import { Instructions } from './types'
88
*/
99
export const genericScript =
1010
(id: string) => (instructions: Instructions, html: string) =>
11-
`Exercice: ${instructions.summary}:
11+
`${instructions.summary}
1212
${instructions.script.map((instruction) => `- ${instruction}`).join('\n')}
13-
14-
Note: Here are some optional libraries that may or may not be used:
15-
${Object.values(libraries)
16-
.filter(({ basic }) => basic)
17-
.map(({ basic }) => `- ${basic}`)
18-
.join('\n')}
19-
Attention: not all applications need all libraries. Games typically need Three.js, or pure canvas, maybe some Tone.js,
20-
but normal apps usually only need lodash and jQuery.
21-
2213
Code formatting rules:
2314
- we use 1 space for indentation
24-
- all variables are compressed to max 3 characters
25-
- this is the final project, not a demo or example
26-
- there are no lines starting with "//", code comments are replaced by line returns
15+
- code is compressed, all JS variables have maximum 3 characters
16+
- this is not a tutorial or a demo, but the final project
2717
\`\`\`html
2818
${
2919
// to save space, we only give essential info to the model

src/engine/prompts/tasks.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Instructions, TaskCategory, Tasks } from './types'
66
export const tasksPrompt = (query: string) =>
77
`You are a senior frontend engineer who needs to develop a web application using only HTML and Javascript.
88
You are not going to code it yourself, instead you will write a valid spec of the app, in the form of JSON instructions.
9-
You do not need to use Three.js, lights, cameras.. if there is no mention of 3D or WebGL. For instance if the brief is a bout a 2D game, you can write the app logic using a 2D <canvas>.
109
1110
Here are some examples, but don't copy them verbatim! instead you need to adapt to the application brief!
1211
@@ -18,7 +17,8 @@ Spec: {
1817
"text content": "Text should be straight to the point, it contains labels, buttons and links to execute various of the application",
1918
"content": "There is a table with editable cells, one line per type of ingredient: bread, sausage, mustard, picked onion, fried onion etc. Columns are: ingredient icon (emoji), name, price, number in stock, and number to order. We also see the total price of items to order",
2019
"interactivity": "There is an input text where we can enter the number of expected customers, and JS code to automatically adjust the number of items to order and the total price",
21-
"images": "no image neeeded"
20+
"js modules": "jQuery, oLdash",
21+
"images": "no image neeeded",
2222
}
2323
2424
Brief: A startup website called Aisy about a new cool SaaS product for creators to create AI movies.
@@ -28,21 +28,23 @@ Spec: {
2828
"art direction": "The design is fresh and sleek, with a sans serif font abd original colors on the theme of AI and movies (purple, black, grey, red)",
2929
"text content": "Page contains marketing content to explain why people should use Aisy to generate movies. Text is concise and to the point, with punch lines for titles. It should make us wish we purchased the product.",
3030
"interactivity": "no javascript needed",
31+
"js modules": "no library available",
3132
"images": "The hero section image shows a woman using a computer in a coffeeshop. The page features multiple screenshots of the application, and also captures of examples movies generated with the tool (documentary, action movie..)"
3233
}
3334
34-
Brief: A WebGL simulator to roll a dice. It has a simple design, with a dark background and yellow-orange interface. You can roll the dice by manually dragging it with the mouse.
35+
Brief: A simulator to roll a dice. It has a simple design, with a dark background and yellow-orange interface. You can roll the dice by manually dragging it with the mouse.
3536
Spec: {
36-
"summary": "WebGL app to roll dices using the mouse",
37+
"summary": "js app to roll dices using the mouse",
3738
"layout": "A simple dice-rolling application page, with a huge title and a large HTML canvas content",
3839
"art direction": "The design should evoke tabletop games or casino, with a green background. Dices might be white, grey, either square or cubes. Emojis are used for buttons.",
3940
"text content": "There should be some instructions about how to roll the dices, explanations on which buttons to click, and some tips",
4041
"interactivity": "The app should have JS code to roll the dice whenever we click, drag and release on the HTML canvas",
42+
"js modules": "jQuery, Tone.js",
43+
"images": "no image needed",
4144
"mouse events": "When clicking on a dice, it should move it, and releasing the mouse should play a small animation to roll the dice",
4245
"keyboard events": "no keyboard events needed",
4346
"sounds": "We may generate a sound using tone.js to simulate the sound of a dice being dropped",
4447
"application logic": "A dice is a random number generator so we should see number inside it or next to in (in the html page), to see which random number was chosen upon rolling",
45-
"images": "no image needed",
4648
"animations": "when the mouse button is released, it should spin for a few seconds before slowing down",
4749
"constraints": "The dice should not be able to get out of the canvas edges"
4850
}
@@ -52,9 +54,10 @@ Spec: {
5254
"layout": "An encyclopedia-like layout, similar to scientific articles or Wikipedia. Images (if any) should be including within the body.",
5355
"art direction": "The design should be sober and elegant, without any emoji, using a serif font to make it looks like a book or printed article. Background should be white, foreground colors should be in shades of grey.",
5456
"text content": "The article should be written in a very rich and scientific tone, with a lot of details about the origins of the word asteroid, the history of their discovery, a scientific analysis of common asteroid composition, the impact on human society, the economics of asteroids, the risks associated with asteroids, and so on.",
55-
"images": "the article should includes at least 5 or 6 pictures to illustration the diversity in asteroids compositions and shapes",
5657
"references": "The article should includes scientific or book references at the end, like for a scientific article",
57-
"interactivity": "No javascript needed"
58+
"interactivity": "No javascript needed",
59+
"js modules": "jQuery, Three.js",
60+
"images": "the article should includes at least 5 or 6 pictures to illustration the diversity in asteroids compositions and shapes"
5861
}
5962
6063
Real work is starting now. Remember, you MUST respect the application brief carefully!

src/pages/content.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function Content() {
121121
prompt,
122122
tasks,
123123
html: document.getElementById('html-tag')?.innerHTML || '',
124-
script,
124+
script: document.getElementById('script-tag')?.innerHTML || '',
125125
text,
126126
data,
127127
...extra,

src/providers/openai/index.ts

-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ ${output}`.trim()
154154
window.appData = {};
155155
var app = window.appData;
156156
${output}`.trim()
157-
158-
console.log('raw script:', script)
159-
160157
// for some reason GPT-3 sometimes generates JS code with ‘ instead of '
161158
script = script.replace('‘', "'")
162159

0 commit comments

Comments
 (0)