Update server.js
Browse files
server.js
CHANGED
|
@@ -36,13 +36,13 @@ app.post("/api/ask-ai", async (req, res) => {
|
|
| 36 |
res.setHeader("Cache-Control", "no-cache");
|
| 37 |
res.setHeader("Connection", "keep-alive");
|
| 38 |
|
| 39 |
-
const systemPrompt = ONLY USE HTML, CSS AND JAVASCRIPT. No explanations, ONLY CODE. If you want to use ICON make sure to import the library first. Try to create the best UI possible using TailwindCSS. If not possible, use custom CSS (remember to import <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script> in the head). ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE;
|
| 40 |
|
| 41 |
try {
|
| 42 |
-
const response = await fetch(${ApiUrl}/chat/completions, {
|
| 43 |
method: "POST",
|
| 44 |
headers: {
|
| 45 |
-
Authorization: Bearer ${ApiKey},
|
| 46 |
"Content-Type": "application/json",
|
| 47 |
},
|
| 48 |
body: JSON.stringify({
|
|
@@ -51,7 +51,7 @@ app.post("/api/ask-ai", async (req, res) => {
|
|
| 51 |
messages: [
|
| 52 |
{ role: "system", content: systemPrompt },
|
| 53 |
...(previousPrompt ? [{ role: "user", content: previousPrompt }] : []),
|
| 54 |
-
...(html ? [{ role: "assistant", content: The current code is: ${html} }] : []),
|
| 55 |
{ role: "user", content: prompt },
|
| 56 |
],
|
| 57 |
}),
|
|
@@ -107,5 +107,5 @@ app.get("*", (_req, res) => {
|
|
| 107 |
});
|
| 108 |
|
| 109 |
app.listen(PORT, () => {
|
| 110 |
-
console.log(✅ Server running on port ${PORT});
|
| 111 |
-
});
|
|
|
|
| 36 |
res.setHeader("Cache-Control", "no-cache");
|
| 37 |
res.setHeader("Connection", "keep-alive");
|
| 38 |
|
| 39 |
+
const systemPrompt = `ONLY USE HTML, CSS AND JAVASCRIPT. No explanations, ONLY CODE. If you want to use ICON make sure to import the library first. Try to create the best UI possible using TailwindCSS. If not possible, use custom CSS (remember to import <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script> in the head). ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE`;
|
| 40 |
|
| 41 |
try {
|
| 42 |
+
const response = await fetch(`${ApiUrl}/chat/completions`, {
|
| 43 |
method: "POST",
|
| 44 |
headers: {
|
| 45 |
+
Authorization: `Bearer ${ApiKey}`,
|
| 46 |
"Content-Type": "application/json",
|
| 47 |
},
|
| 48 |
body: JSON.stringify({
|
|
|
|
| 51 |
messages: [
|
| 52 |
{ role: "system", content: systemPrompt },
|
| 53 |
...(previousPrompt ? [{ role: "user", content: previousPrompt }] : []),
|
| 54 |
+
...(html ? [{ role: "assistant", content: `The current code is: ${html}` }] : []),
|
| 55 |
{ role: "user", content: prompt },
|
| 56 |
],
|
| 57 |
}),
|
|
|
|
| 107 |
});
|
| 108 |
|
| 109 |
app.listen(PORT, () => {
|
| 110 |
+
console.log(`✅ Server running on port ${PORT}`);
|
| 111 |
+
});
|