forked from SawyerHood/draw-a-ui
-
Notifications
You must be signed in to change notification settings - Fork 523
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
Showing
6 changed files
with
44 additions
and
13 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 |
---|---|---|
|
@@ -34,3 +34,4 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
.idea |
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 |
---|---|---|
|
@@ -13,23 +13,43 @@ Use JavaScript modules and unkpkg to import any necessary dependencies. | |
Respond ONLY with the contents of the html file.` | ||
|
||
const threeJsSystemPrompt = `You are an expert web developer who specializes in three.js. | ||
A user will provide you with a low-fidelity wireframe of an application. | ||
You will return a single html file that uses HTML, three.js, and JavaScript to create a high fidelity website. | ||
Include any extra CSS and JavaScript in the html file. | ||
The user will provide you with notes in blue or red text, arrows, or drawings. | ||
The user may also include images of other websites as style references. Transfer the styles as best as you can, matching colors. | ||
Prefer to use standard materials instead of basic and avoid custom shaders. | ||
Unless otherwise specified, set up orbit controls and a directional light attached to the camera. | ||
Use an import map e.g. <script type="importmap">{"imports": {"three": "https://unpkg.com/[email protected]/build/three.module.js","OrbitControls": "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js"}}</script> | ||
They may also provide you with the html of a previous design that they want you to iterate from. | ||
Carry out any changes they request from you. | ||
In the wireframe, the previous design's html will appear as a white rectangle. | ||
Use creative license to make the application more fleshed out. | ||
Use JavaScript modules and unkpkg to import any necessary dependencies. | ||
Respond ONLY with the contents of the html file.` | ||
|
||
export async function getHtmlFromOpenAI({ | ||
image, | ||
html, | ||
apiKey, | ||
mode, | ||
}: { | ||
image: string | ||
html: string | ||
apiKey: string | ||
image: string; | ||
html: string; | ||
apiKey: string; | ||
mode: 'tailwind' | 'threejs', | ||
}) { | ||
let threeJsText = 'Turn this into a single html file using three.js.' | ||
let tailwindText = 'Turn this into a single html file using tailwind.' | ||
const body: GPT4VCompletionRequest = { | ||
model: 'gpt-4-vision-preview', | ||
max_tokens: 4096, | ||
temperature: 0, | ||
messages: [ | ||
{ | ||
role: 'system', | ||
content: systemPrompt, | ||
content: mode === 'tailwind' ? systemPrompt : threeJsSystemPrompt, | ||
}, | ||
{ | ||
role: 'user', | ||
|
@@ -43,7 +63,7 @@ export async function getHtmlFromOpenAI({ | |
}, | ||
{ | ||
type: 'text', | ||
text: 'Turn this into a single html file using tailwind.', | ||
text: mode === 'tailwind' ? tailwindText : threeJsText, | ||
}, | ||
{ | ||
type: 'text', | ||
|
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