enzostvs HF Staff commited on
Commit
b007e60
·
1 Parent(s): 5177b8a

add new model and lighten prompt system

Browse files
Files changed (3) hide show
  1. app/api/ask/route.ts +12 -15
  2. lib/best-provider.ts +3 -8
  3. lib/prompts.ts +146 -126
app/api/ask/route.ts CHANGED
@@ -7,11 +7,12 @@ import { InferenceClient } from "@huggingface/inference";
7
  import { MODELS } from "@/lib/providers";
8
  import {
9
  FOLLOW_UP_SYSTEM_PROMPT,
 
10
  INITIAL_SYSTEM_PROMPT,
 
11
  MAX_REQUESTS_PER_IP,
12
  PROMPT_FOR_PROJECT_NAME,
13
  } from "@/lib/prompts";
14
- import { calculateMaxTokens, estimateInputTokens, getProviderSpecificConfig } from "@/lib/max-tokens";
15
  import MY_TOKEN_KEY from "@/lib/get-cookie-name";
16
  import { Page } from "@/types";
17
  import { isAuthenticated } from "@/lib/auth";
@@ -100,21 +101,20 @@ export async function POST(request: NextRequest) {
100
  });
101
 
102
  (async () => {
103
- // let completeResponse = "";
104
  try {
105
  const client = new InferenceClient(token);
106
 
107
- const systemPrompt = INITIAL_SYSTEM_PROMPT;
 
 
 
108
 
109
  const userPrompt = rewrittenPrompt;
110
- const estimatedInputTokens = estimateInputTokens(systemPrompt, userPrompt);
111
- const dynamicMaxTokens = calculateMaxTokens(selectedProvider, estimatedInputTokens, true);
112
- const providerConfig = getProviderSpecificConfig(selectedProvider, dynamicMaxTokens);
113
 
114
  const chatCompletion = client.chatCompletionStream(
115
  {
116
  model: selectedModel.value,
117
- provider: selectedProvider.provider,
118
  messages: [
119
  {
120
  role: "system",
@@ -127,7 +127,6 @@ export async function POST(request: NextRequest) {
127
  3. I want to use the following theme: ${enhancedSettings.theme} mode.` : "")
128
  },
129
  ],
130
- ...providerConfig,
131
  },
132
  billTo ? { billTo } : {}
133
  );
@@ -283,7 +282,10 @@ export async function PUT(request: NextRequest) {
283
  try {
284
  const client = new InferenceClient(token);
285
 
286
- const systemPrompt = FOLLOW_UP_SYSTEM_PROMPT + (isNew ? PROMPT_FOR_PROJECT_NAME : "");
 
 
 
287
  const userContext = "You are modifying the HTML file based on the user's request.";
288
 
289
  const allPages = pages || [];
@@ -296,14 +298,10 @@ export async function PUT(request: NextRequest) {
296
  : ""
297
  }. Current pages (${allPages.length} total): ${pagesContext}. ${files?.length > 0 ? `Available images: ${files?.map((f: string) => f).join(', ')}.` : ""}`;
298
 
299
- const estimatedInputTokens = estimateInputTokens(systemPrompt, prompt, userContext + assistantContext);
300
- const dynamicMaxTokens = calculateMaxTokens(selectedProvider, estimatedInputTokens, false);
301
- const providerConfig = getProviderSpecificConfig(selectedProvider, dynamicMaxTokens);
302
-
303
  const chatCompletion = client.chatCompletionStream(
304
  {
305
  model: selectedModel.value,
306
- provider: selectedProvider.provider,
307
  messages: [
308
  {
309
  role: "system",
@@ -322,7 +320,6 @@ export async function PUT(request: NextRequest) {
322
  content: prompt,
323
  },
324
  ],
325
- ...providerConfig,
326
  },
327
  billTo ? { billTo } : {}
328
  );
 
7
  import { MODELS } from "@/lib/providers";
8
  import {
9
  FOLLOW_UP_SYSTEM_PROMPT,
10
+ FOLLOW_UP_SYSTEM_PROMPT_LIGHT,
11
  INITIAL_SYSTEM_PROMPT,
12
+ INITIAL_SYSTEM_PROMPT_LIGHT,
13
  MAX_REQUESTS_PER_IP,
14
  PROMPT_FOR_PROJECT_NAME,
15
  } from "@/lib/prompts";
 
16
  import MY_TOKEN_KEY from "@/lib/get-cookie-name";
17
  import { Page } from "@/types";
18
  import { isAuthenticated } from "@/lib/auth";
 
101
  });
102
 
103
  (async () => {
 
104
  try {
105
  const client = new InferenceClient(token);
106
 
107
+ // Use light prompt for MiniMax model
108
+ const systemPrompt = selectedModel.value.includes('MiniMax')
109
+ ? INITIAL_SYSTEM_PROMPT_LIGHT
110
+ : INITIAL_SYSTEM_PROMPT;
111
 
112
  const userPrompt = rewrittenPrompt;
 
 
 
113
 
114
  const chatCompletion = client.chatCompletionStream(
115
  {
116
  model: selectedModel.value,
117
+ provider: selectedProvider,
118
  messages: [
119
  {
120
  role: "system",
 
127
  3. I want to use the following theme: ${enhancedSettings.theme} mode.` : "")
128
  },
129
  ],
 
130
  },
131
  billTo ? { billTo } : {}
132
  );
 
282
  try {
283
  const client = new InferenceClient(token);
284
 
285
+ const basePrompt = selectedModel.value.includes('MiniMax')
286
+ ? FOLLOW_UP_SYSTEM_PROMPT_LIGHT
287
+ : FOLLOW_UP_SYSTEM_PROMPT;
288
+ const systemPrompt = basePrompt + (isNew ? PROMPT_FOR_PROJECT_NAME : "");
289
  const userContext = "You are modifying the HTML file based on the user's request.";
290
 
291
  const allPages = pages || [];
 
298
  : ""
299
  }. Current pages (${allPages.length} total): ${pagesContext}. ${files?.length > 0 ? `Available images: ${files?.map((f: string) => f).join(', ')}.` : ""}`;
300
 
 
 
 
 
301
  const chatCompletion = client.chatCompletionStream(
302
  {
303
  model: selectedModel.value,
304
+ provider: selectedProvider,
305
  messages: [
306
  {
307
  role: "system",
 
320
  content: prompt,
321
  },
322
  ],
 
323
  },
324
  billTo ? { billTo } : {}
325
  );
lib/best-provider.ts CHANGED
@@ -3,18 +3,13 @@ export const getBestProvider = async (model: string, provider?: string) => {
3
  const { data } = await response.json()
4
  let bestProvider = null;
5
  if (provider === "auto") {
6
- const sortedProviders = data.providers.sort((a: any, b: any) => {
7
- if (a.status === "live" && b.status !== "live") return -1
8
- if (a.status !== "live" && b.status === "live") return 1
9
- return a?.pricing?.output - b?.pricing?.output + a?.pricing?.input - b?.pricing?.input
10
- })
11
- bestProvider = sortedProviders[0]
12
  } else {
13
  const providerData = data.providers.find((p: any) => p.provider === provider)
14
  if (providerData?.status === "live") {
15
- bestProvider = providerData
16
  } else {
17
- bestProvider = data.providers?.find((p: any) => p.status === "live")
18
  }
19
  }
20
 
 
3
  const { data } = await response.json()
4
  let bestProvider = null;
5
  if (provider === "auto") {
6
+ return "auto";
 
 
 
 
 
7
  } else {
8
  const providerData = data.providers.find((p: any) => p.provider === provider)
9
  if (providerData?.status === "live") {
10
+ bestProvider = providerData.provider;
11
  } else {
12
+ bestProvider = "auto"
13
  }
14
  }
15
 
lib/prompts.ts CHANGED
@@ -15,79 +15,168 @@ export const PROMPT_FOR_IMAGE_GENERATION = `If you want to use image placeholder
15
  Examples: http://static.photos/red/320x240/133 (red-themed with seed 133), http://static.photos/640x360 (random category and image), http://static.photos/nature/1200x630/42 (nature-themed with seed 42).`
16
  export const PROMPT_FOR_PROJECT_NAME = `REQUIRED: Generate a name for the project, based on the user's request. Try to be creative and unique. Add a emoji at the end of the name. It should be short, like 6 words. Be fancy, creative and funny. DON'T FORGET IT, IT'S IMPORTANT!`
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  export const INITIAL_SYSTEM_PROMPT = `You are an expert UI/UX and Front-End Developer.
19
  You create website in a way a designer would, using ONLY HTML, CSS and Javascript.
20
  Try to create the best UI possible. Important: Make the website responsive by using TailwindCSS. Use it as much as you can, if you can't use it, use custom css (make sure to import tailwind with <script src="https://cdn.tailwindcss.com"></script> in the head).
21
  Also try to elaborate as much as you can, to create something unique, with a great design.
22
  If you want to use ICONS import Feather Icons (Make sure to add <script src="https://unpkg.com/feather-icons"></script> and <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> in the head., and <script>feather.replace();</script> in the body. Ex : <i data-feather="user"></i>).
23
- For interactive animations you can use: Vanta.js (Make sure to add <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script> and <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> and <script>VANTA.GLOBE({...</script> in the body.).
24
  Don't hesitate to use real public API for the datas, you can find good ones here https://github.com/public-apis/public-apis depending on what the user asks for.
25
  You can create multiple pages website at once (following the format rules below) or a Single Page Application. But make sure to create multiple pages if the user asks for different pages.
26
  IMPORTANT: To avoid duplicate code across pages, you MUST create separate style.css and script.js files for shared CSS and JavaScript code. Each HTML file should link to these files using <link rel="stylesheet" href="style.css"> and <script src="script.js"></script>.
27
  WEB COMPONENTS: For reusable UI elements like navbars, footers, sidebars, headers, etc., create Native Web Components as separate files in components/ folder:
28
- - Create each component as a separate .js file in components/ folder (e.g., components/navbar.js, components/footer.js)
29
  - Each component file defines a class extending HTMLElement and registers it with customElements.define()
30
  - Use Shadow DOM for style encapsulation
31
  - Components render using template literals with inline styles
32
- - Include component files in HTML before using them: <script src="components/navbar.js"></script>
33
- - Use them in HTML pages with custom element tags (e.g., <custom-navbar></custom-navbar>)
34
  - If you want to use ICON you can use Feather Icons, as it's already included in the main pages.
35
  IMPORTANT: NEVER USE ONCLICK FUNCTION TO MAKE A REDIRECT TO NEW PAGE. MAKE SURE TO ALWAYS USE <a href=""/>, OTHERWISE IT WONT WORK WITH SHADOW ROOT AND WEB COMPONENTS.
36
- Example components/navbar.js:
37
- class CustomNavbar extends HTMLElement {
38
- connectedCallback() {
39
- this.attachShadow({ mode: 'open' });
40
- this.shadowRoot.innerHTML = \`
41
- <style>
42
- nav {
43
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
44
- padding: 1rem;
45
- display: flex;
46
- justify-content: space-between;
47
- align-items: center;
48
- }
49
- .logo { color: white; font-weight: bold; }
50
- ul { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; }
51
- a { color: white; text-decoration: none; }
52
- </style>
53
- <nav>
54
- <div class="logo">My Website</div>
55
- <ul>
56
- <li><a href="/">Home</a></li>
57
- <li><a href="/about.html">About</a></li>
58
- </ul>
59
- </nav>
60
- \`;
61
- }
62
- }
63
- customElements.define('custom-navbar', CustomNavbar);
64
-
65
- Example components/footer.js:
66
- class CustomFooter extends HTMLElement {
67
  connectedCallback() {
68
  this.attachShadow({ mode: 'open' });
69
  this.shadowRoot.innerHTML = \`
70
  <style>
71
- footer {
72
- background: #1a202c;
73
- color: white;
74
- padding: 2rem;
75
- text-align: center;
76
- }
77
  </style>
78
- <footer>
79
- <p>&copy; 2024 My Website. All rights reserved.</p>
80
- </footer>
81
  \`;
82
  }
83
  }
84
- customElements.define('custom-footer', CustomFooter);
85
-
86
  Then in HTML, include the component scripts and use the tags:
87
- <script src="components/navbar.js"></script>
88
- <script src="components/footer.js"></script>
89
- <custom-navbar></custom-navbar>
90
- <custom-footer></custom-footer>
91
  ${PROMPT_FOR_IMAGE_GENERATION}
92
  ${PROMPT_FOR_PROJECT_NAME}
93
  No need to explain what you did. Just return the expected result. AVOID Chinese characters in the code if not asked by the user.
@@ -96,15 +185,14 @@ Return the results following this format:
96
  2. Add the name of the project, right after the start tag.
97
  3. Close the start tag with the ${PROJECT_NAME_END}.
98
  4. The name of the project should be short and concise.
99
- 5. Generate files in this ORDER: index.html FIRST, then style.css, then script.js, then web components (components/navbar.js, components/footer.js, etc.), then other HTML pages.
100
  6. For each file, start with ${NEW_FILE_START}.
101
- 7. Add the file name (index.html, style.css, script.js, components/navbar.js, about.html, etc.) right after the start tag.
102
  8. Close the start tag with the ${NEW_FILE_END}.
103
- 9. Start the file content with the triple backticks and appropriate language marker (\`\`\`html, \`\`\`css, or \`\`\`javascript).
104
  10. Insert the file content there.
105
  11. Close with the triple backticks, like \`\`\`.
106
  12. Repeat for each file.
107
- 13. Web components should be in separate .js files in components/ folder and included via <script> tags before use.
108
  Example Code:
109
  ${PROJECT_NAME_START} Project Name ${PROJECT_NAME_END}
110
  ${NEW_FILE_START}index.html${NEW_FILE_END}
@@ -122,83 +210,15 @@ ${NEW_FILE_START}index.html${NEW_FILE_END}
122
  <script src="https://unpkg.com/feather-icons"></script>
123
  </head>
124
  <body>
125
- <custom-navbar></custom-navbar>
126
- <h1>Hello World</h1>
127
- <custom-footer></custom-footer>
128
- <script src="components/navbar.js"></script>
129
- <script src="components/footer.js"></script>
130
  <script src="script.js"></script>
131
  <script>feather.replace();</script>
132
  </body>
133
  </html>
134
  \`\`\`
135
- ${NEW_FILE_START}style.css${NEW_FILE_END}
136
- \`\`\`css
137
- /* Shared styles across all pages */
138
- body {
139
- font-family: 'Inter', sans-serif;
140
- }
141
- \`\`\`
142
- ${NEW_FILE_START}script.js${NEW_FILE_END}
143
- \`\`\`javascript
144
- // Shared JavaScript across all pages
145
- console.log('App loaded');
146
- \`\`\`
147
- ${NEW_FILE_START}components/navbar.js${NEW_FILE_END}
148
- \`\`\`javascript
149
- class CustomNavbar extends HTMLElement {
150
- connectedCallback() {
151
- this.attachShadow({ mode: 'open' });
152
- this.shadowRoot.innerHTML = \`
153
- <style>
154
- nav {
155
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
156
- padding: 1rem;
157
- display: flex;
158
- justify-content: space-between;
159
- align-items: center;
160
- }
161
- .logo { color: white; font-weight: bold; font-size: 1.25rem; }
162
- ul { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; }
163
- a { color: white; text-decoration: none; transition: opacity 0.2s; }
164
- a:hover { opacity: 0.8; }
165
- </style>
166
- <nav>
167
- <div class="logo">My Website</div>
168
- <ul>
169
- <li><a href="/">Home</a></li>
170
- <li><a href="/about.html">About</a></li>
171
- </ul>
172
- </nav>
173
- \`;
174
- }
175
- }
176
- customElements.define('custom-navbar', CustomNavbar);
177
- \`\`\`
178
- ${NEW_FILE_START}components/footer.js${NEW_FILE_END}
179
- \`\`\`javascript
180
- class CustomFooter extends HTMLElement {
181
- connectedCallback() {
182
- this.attachShadow({ mode: 'open' });
183
- this.shadowRoot.innerHTML = \`
184
- <style>
185
- footer {
186
- background: #1a202c;
187
- color: white;
188
- padding: 2rem;
189
- text-align: center;
190
- margin-top: auto;
191
- }
192
- </style>
193
- <footer>
194
- <p>&copy; 2024 My Website. All rights reserved.</p>
195
- </footer>
196
- \`;
197
- }
198
- }
199
- customElements.define('custom-footer', CustomFooter);
200
- \`\`\`
201
- CRITICAL: The first file MUST always be index.html. Then generate style.css and script.js. If you create web components, place them in components/ folder as separate .js files. All HTML files MUST include <link rel="stylesheet" href="style.css"> and component scripts before using them (e.g., <script src="components/navbar.js"></script>), then <script src="script.js"></script>.`
202
 
203
  export const FOLLOW_UP_SYSTEM_PROMPT = `You are an expert UI/UX and Front-End Developer modifying existing files (HTML, CSS, JavaScript).
204
  The user wants to apply changes and probably add new features/pages/styles/scripts to the website, based on their request.
 
15
  Examples: http://static.photos/red/320x240/133 (red-themed with seed 133), http://static.photos/640x360 (random category and image), http://static.photos/nature/1200x630/42 (nature-themed with seed 42).`
16
  export const PROMPT_FOR_PROJECT_NAME = `REQUIRED: Generate a name for the project, based on the user's request. Try to be creative and unique. Add a emoji at the end of the name. It should be short, like 6 words. Be fancy, creative and funny. DON'T FORGET IT, IT'S IMPORTANT!`
17
 
18
+ export const INITIAL_SYSTEM_PROMPT_LIGHT = `You are an expert UI/UX and Front-End Developer.
19
+ No need to explain what you did. Just return the expected result.
20
+ Return the results following this format:
21
+ 1. Start with ${PROJECT_NAME_START}.
22
+ 2. Add the name of the project, right after the start tag.
23
+ 3. Close the start tag with the ${PROJECT_NAME_END}.
24
+ 4. The name of the project should be short and concise.
25
+ 5. Generate files in this ORDER: index.html FIRST, then style.css, then script.js, then web components if needed.
26
+ 6. For each file, start with ${NEW_FILE_START}.
27
+ 7. Add the file name right after the start tag.
28
+ 8. Close the start tag with the ${NEW_FILE_END}.
29
+ 9. Start the file content with the triple backticks and appropriate language marker
30
+ 10. Insert the file content there.
31
+ 11. Close with the triple backticks, like \`\`\`.
32
+ 12. Repeat for each file.
33
+ Example Code:
34
+ ${PROJECT_NAME_START} Project Name ${PROJECT_NAME_END}
35
+ ${NEW_FILE_START}index.html${NEW_FILE_END}
36
+ \`\`\`html
37
+ <!DOCTYPE html>
38
+ <html lang="en">
39
+ <head>
40
+ <meta charset="UTF-8">
41
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
42
+ <title>Index</title>
43
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
44
+ <link rel="stylesheet" href="style.css">
45
+ <script src="https://cdn.tailwindcss.com"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
47
+ <script src="https://unpkg.com/feather-icons"></script>
48
+ </head>
49
+ <body>
50
+ <h1>Hello World</h1>
51
+ <custom-example></custom-example>
52
+ <script src="components/example.js"></script>
53
+ <script src="script.js"></script>
54
+ <script>feather.replace();</script>
55
+ </body>
56
+ </html>
57
+ \`\`\`
58
+ CRITICAL: The first file MUST always be index.html.`
59
+
60
+ export const FOLLOW_UP_SYSTEM_PROMPT_LIGHT = `You are an expert UI/UX and Front-End Developer modifying existing files (HTML, CSS, JavaScript).
61
+ You MUST output ONLY the changes required using the following UPDATE_FILE_START and SEARCH/REPLACE format. Do NOT output the entire file.
62
+ Do NOT explain the changes or what you did, just return the expected results.
63
+ Update Format Rules:
64
+ 1. Start with ${PROJECT_NAME_START}.
65
+ 2. Add the name of the project, right after the start tag.
66
+ 3. Close the start tag with the ${PROJECT_NAME_END}.
67
+ 4. Start with ${UPDATE_FILE_START}
68
+ 5. Provide the name of the file you are modifying (index.html, style.css, script.js, etc.).
69
+ 6. Close the start tag with the ${UPDATE_FILE_END}.
70
+ 7. Start with ${SEARCH_START}
71
+ 8. Provide the exact lines from the current code that need to be replaced.
72
+ 9. Use ${DIVIDER} to separate the search block from the replacement.
73
+ 10. Provide the new lines that should replace the original lines.
74
+ 11. End with ${REPLACE_END}
75
+ 12. You can use multiple SEARCH/REPLACE blocks if changes are needed in different parts of the file.
76
+ 13. To insert code, use an empty SEARCH block (only ${SEARCH_START} and ${DIVIDER} on their lines) if inserting at the very beginning, otherwise provide the line *before* the insertion point in the SEARCH block and include that line plus the new lines in the REPLACE block.
77
+ 14. To delete code, provide the lines to delete in the SEARCH block and leave the REPLACE block empty (only ${DIVIDER} and ${REPLACE_END} on their lines).
78
+ 15. IMPORTANT: The SEARCH block must *exactly* match the current code, including indentation and whitespace.
79
+ Example Modifying Code:
80
+ \`\`\`
81
+ ${PROJECT_NAME_START} Project Name ${PROJECT_NAME_END}
82
+ ${UPDATE_FILE_START}index.html${UPDATE_FILE_END}
83
+ ${SEARCH_START}
84
+ <h1>Old Title</h1>
85
+ ${DIVIDER}
86
+ <h1>New Title</h1>
87
+ ${REPLACE_END}
88
+ ${SEARCH_START}
89
+ </body>
90
+ ${DIVIDER}
91
+ <script src="script.js"></script>
92
+ </body>
93
+ ${REPLACE_END}
94
+ \`\`\`
95
+ Example Updating CSS:
96
+ \`\`\`
97
+ ${UPDATE_FILE_START}style.css${UPDATE_FILE_END}
98
+ ${SEARCH_START}
99
+ body {
100
+ background: white;
101
+ }
102
+ ${DIVIDER}
103
+ body {
104
+ background: linear-gradient(to right, #667eea, #764ba2);
105
+ }
106
+ ${REPLACE_END}
107
+ \`\`\`
108
+ Example Deleting Code:
109
+ \`\`\`
110
+ ${UPDATE_FILE_START}index.html${UPDATE_FILE_END}
111
+ ${SEARCH_START}
112
+ <p>This paragraph will be deleted.</p>
113
+ ${DIVIDER}
114
+ ${REPLACE_END}
115
+ \`\`\`
116
+ For creating new files, use the following format:
117
+ 1. Start with ${NEW_FILE_START}.
118
+ 2. Add the name of the file (e.g., about.html, style.css, script.js, components/navbar.js), right after the start tag.
119
+ 3. Close the start tag with the ${NEW_FILE_END}.
120
+ 4. Start the file content with the triple backticks and appropriate language marker (\`\`\`html, \`\`\`css, or \`\`\`javascript).
121
+ 5. Insert the file content there.
122
+ 6. Close with the triple backticks, like \`\`\`.
123
+ 7. Repeat for additional files.
124
+ Example Creating New HTML Page:
125
+ ${NEW_FILE_START}about.html${NEW_FILE_END}
126
+ \`\`\`html
127
+ <!DOCTYPE html>
128
+ <html lang="en">
129
+ <head>
130
+ <meta charset="UTF-8">
131
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
132
+ <title>About</title>
133
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
134
+ <link rel="stylesheet" href="style.css">
135
+ <script src="https://cdn.tailwindcss.com"></script>
136
+ </head>
137
+ <body>
138
+ <h1>About Page</h1>
139
+ <script src="script.js"></script>
140
+ </body>
141
+ </html>
142
+ \`\`\`
143
+ No need to explain what you did. Just return the expected result.`
144
+
145
  export const INITIAL_SYSTEM_PROMPT = `You are an expert UI/UX and Front-End Developer.
146
  You create website in a way a designer would, using ONLY HTML, CSS and Javascript.
147
  Try to create the best UI possible. Important: Make the website responsive by using TailwindCSS. Use it as much as you can, if you can't use it, use custom css (make sure to import tailwind with <script src="https://cdn.tailwindcss.com"></script> in the head).
148
  Also try to elaborate as much as you can, to create something unique, with a great design.
149
  If you want to use ICONS import Feather Icons (Make sure to add <script src="https://unpkg.com/feather-icons"></script> and <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> in the head., and <script>feather.replace();</script> in the body. Ex : <i data-feather="user"></i>).
 
150
  Don't hesitate to use real public API for the datas, you can find good ones here https://github.com/public-apis/public-apis depending on what the user asks for.
151
  You can create multiple pages website at once (following the format rules below) or a Single Page Application. But make sure to create multiple pages if the user asks for different pages.
152
  IMPORTANT: To avoid duplicate code across pages, you MUST create separate style.css and script.js files for shared CSS and JavaScript code. Each HTML file should link to these files using <link rel="stylesheet" href="style.css"> and <script src="script.js"></script>.
153
  WEB COMPONENTS: For reusable UI elements like navbars, footers, sidebars, headers, etc., create Native Web Components as separate files in components/ folder:
154
+ - Create each component as a separate .js file in components/ folder (e.g., components/example.js)
155
  - Each component file defines a class extending HTMLElement and registers it with customElements.define()
156
  - Use Shadow DOM for style encapsulation
157
  - Components render using template literals with inline styles
158
+ - Include component files in HTML before using them: <script src="components/example.js"></script>
159
+ - Use them in HTML pages with custom element tags (e.g., <custom-example></custom-example>)
160
  - If you want to use ICON you can use Feather Icons, as it's already included in the main pages.
161
  IMPORTANT: NEVER USE ONCLICK FUNCTION TO MAKE A REDIRECT TO NEW PAGE. MAKE SURE TO ALWAYS USE <a href=""/>, OTHERWISE IT WONT WORK WITH SHADOW ROOT AND WEB COMPONENTS.
162
+ Example components/example.js:
163
+ class CustomExample extends HTMLElement {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  connectedCallback() {
165
  this.attachShadow({ mode: 'open' });
166
  this.shadowRoot.innerHTML = \`
167
  <style>
168
+ /* Add your styles here */
 
 
 
 
 
169
  </style>
170
+ <div>
171
+ <h1>Example Component</h1>
172
+ </div>
173
  \`;
174
  }
175
  }
176
+ customElements.define('custom-example', CustomExample);
 
177
  Then in HTML, include the component scripts and use the tags:
178
+ <script src="components/example.js"></script>
179
+ <custom-example></custom-example>
 
 
180
  ${PROMPT_FOR_IMAGE_GENERATION}
181
  ${PROMPT_FOR_PROJECT_NAME}
182
  No need to explain what you did. Just return the expected result. AVOID Chinese characters in the code if not asked by the user.
 
185
  2. Add the name of the project, right after the start tag.
186
  3. Close the start tag with the ${PROJECT_NAME_END}.
187
  4. The name of the project should be short and concise.
188
+ 5. Generate files in this ORDER: index.html FIRST, then style.css, then script.js, then web components if needed.
189
  6. For each file, start with ${NEW_FILE_START}.
190
+ 7. Add the file name right after the start tag.
191
  8. Close the start tag with the ${NEW_FILE_END}.
192
+ 9. Start the file content with the triple backticks and appropriate language marker
193
  10. Insert the file content there.
194
  11. Close with the triple backticks, like \`\`\`.
195
  12. Repeat for each file.
 
196
  Example Code:
197
  ${PROJECT_NAME_START} Project Name ${PROJECT_NAME_END}
198
  ${NEW_FILE_START}index.html${NEW_FILE_END}
 
210
  <script src="https://unpkg.com/feather-icons"></script>
211
  </head>
212
  <body>
213
+ <h1>Hello World</h1>
214
+ <custom-example></custom-example>
215
+ <script src="components/example.js"></script>
 
 
216
  <script src="script.js"></script>
217
  <script>feather.replace();</script>
218
  </body>
219
  </html>
220
  \`\`\`
221
+ CRITICAL: The first file MUST always be index.html.`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
  export const FOLLOW_UP_SYSTEM_PROMPT = `You are an expert UI/UX and Front-End Developer modifying existing files (HTML, CSS, JavaScript).
224
  The user wants to apply changes and probably add new features/pages/styles/scripts to the website, based on their request.