Spaces:
Running
Running
test_v
#252
by
vishu2124
- opened
- app/api/ask-ai/route.ts +2 -11
- components/editor/ask-ai/index.tsx +2 -8
- components/editor/deploy-button/index.tsx +1 -1
- components/editor/save-button/index.tsx +2 -2
- lib/prompts.ts +1 -1
- lib/providers.ts +1 -18
- public/providers/groq.svg +0 -4
app/api/ask-ai/route.ts
CHANGED
@@ -223,8 +223,7 @@ export async function PUT(request: NextRequest) {
|
|
223 |
const userToken = request.cookies.get(MY_TOKEN_KEY())?.value;
|
224 |
|
225 |
const body = await request.json();
|
226 |
-
const { prompt, html, previousPrompt, provider, selectedElementHtml
|
227 |
-
body;
|
228 |
|
229 |
if (!prompt || !html) {
|
230 |
return NextResponse.json(
|
@@ -233,15 +232,7 @@ export async function PUT(request: NextRequest) {
|
|
233 |
);
|
234 |
}
|
235 |
|
236 |
-
const selectedModel = MODELS
|
237 |
-
(m) => m.value === model || m.label === model
|
238 |
-
);
|
239 |
-
if (!selectedModel) {
|
240 |
-
return NextResponse.json(
|
241 |
-
{ ok: false, error: "Invalid model selected" },
|
242 |
-
{ status: 400 }
|
243 |
-
);
|
244 |
-
}
|
245 |
|
246 |
let token = userToken;
|
247 |
let billTo: string | null = null;
|
|
|
223 |
const userToken = request.cookies.get(MY_TOKEN_KEY())?.value;
|
224 |
|
225 |
const body = await request.json();
|
226 |
+
const { prompt, html, previousPrompt, provider, selectedElementHtml } = body;
|
|
|
227 |
|
228 |
if (!prompt || !html) {
|
229 |
return NextResponse.json(
|
|
|
232 |
);
|
233 |
}
|
234 |
|
235 |
+
const selectedModel = MODELS[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
let token = userToken;
|
238 |
let billTo: string | null = null;
|
components/editor/ask-ai/index.tsx
CHANGED
@@ -67,10 +67,6 @@ export function AskAI({
|
|
67 |
const [controller, setController] = useState<AbortController | null>(null);
|
68 |
const [isFollowUp, setIsFollowUp] = useState(true);
|
69 |
|
70 |
-
const selectedModel = useMemo(() => {
|
71 |
-
return MODELS.find((m: { value: string }) => m.value === model);
|
72 |
-
}, [model]);
|
73 |
-
|
74 |
const callAi = async (redesignMarkdown?: string) => {
|
75 |
if (isAiWorking) return;
|
76 |
if (!redesignMarkdown && !prompt.trim()) return;
|
@@ -182,9 +178,7 @@ export function AskAI({
|
|
182 |
setPrompt("");
|
183 |
setisAiWorking(false);
|
184 |
setHasAsked(true);
|
185 |
-
|
186 |
-
setModel(MODELS[0].value);
|
187 |
-
}
|
188 |
if (audio.current) audio.current.play();
|
189 |
|
190 |
// Now we have the complete HTML including </html>, so set it to be sure
|
@@ -450,7 +444,7 @@ export function AskAI({
|
|
450 |
id="diff-patch-checkbox"
|
451 |
checked={isFollowUp}
|
452 |
onCheckedChange={(e) => {
|
453 |
-
if (e === true && !isSameHtml
|
454 |
setModel(MODELS[0].value);
|
455 |
}
|
456 |
setIsFollowUp(e === true);
|
|
|
67 |
const [controller, setController] = useState<AbortController | null>(null);
|
68 |
const [isFollowUp, setIsFollowUp] = useState(true);
|
69 |
|
|
|
|
|
|
|
|
|
70 |
const callAi = async (redesignMarkdown?: string) => {
|
71 |
if (isAiWorking) return;
|
72 |
if (!redesignMarkdown && !prompt.trim()) return;
|
|
|
178 |
setPrompt("");
|
179 |
setisAiWorking(false);
|
180 |
setHasAsked(true);
|
181 |
+
setModel(MODELS[0].value);
|
|
|
|
|
182 |
if (audio.current) audio.current.play();
|
183 |
|
184 |
// Now we have the complete HTML including </html>, so set it to be sure
|
|
|
444 |
id="diff-patch-checkbox"
|
445 |
checked={isFollowUp}
|
446 |
onCheckedChange={(e) => {
|
447 |
+
if (e === true && !isSameHtml) {
|
448 |
setModel(MODELS[0].value);
|
449 |
}
|
450 |
setIsFollowUp(e === true);
|
components/editor/deploy-button/index.tsx
CHANGED
@@ -71,7 +71,7 @@ export function DeployButton({
|
|
71 |
<div>
|
72 |
<Button variant="default" className="max-lg:hidden !px-4">
|
73 |
<MdSave className="size-4" />
|
74 |
-
|
75 |
</Button>
|
76 |
<Button variant="default" size="sm" className="lg:hidden">
|
77 |
Deploy
|
|
|
71 |
<div>
|
72 |
<Button variant="default" className="max-lg:hidden !px-4">
|
73 |
<MdSave className="size-4" />
|
74 |
+
Save your Project
|
75 |
</Button>
|
76 |
<Button variant="default" size="sm" className="lg:hidden">
|
77 |
Deploy
|
components/editor/save-button/index.tsx
CHANGED
@@ -59,7 +59,7 @@ export function SaveButton({
|
|
59 |
onClick={updateSpace}
|
60 |
>
|
61 |
<MdSave className="size-4" />
|
62 |
-
|
63 |
{loading && <Loading className="ml-2 size-4 animate-spin" />}
|
64 |
</Button>
|
65 |
<Button
|
@@ -68,7 +68,7 @@ export function SaveButton({
|
|
68 |
className="lg:hidden relative"
|
69 |
onClick={updateSpace}
|
70 |
>
|
71 |
-
|
72 |
</Button>
|
73 |
</>
|
74 |
);
|
|
|
59 |
onClick={updateSpace}
|
60 |
>
|
61 |
<MdSave className="size-4" />
|
62 |
+
Save your Project{" "}
|
63 |
{loading && <Loading className="ml-2 size-4 animate-spin" />}
|
64 |
</Button>
|
65 |
<Button
|
|
|
68 |
className="lg:hidden relative"
|
69 |
onClick={updateSpace}
|
70 |
>
|
71 |
+
Save {loading && <Loading className="ml-2 size-4 animate-spin" />}
|
72 |
</Button>
|
73 |
</>
|
74 |
);
|
lib/prompts.ts
CHANGED
@@ -2,7 +2,7 @@ export const SEARCH_START = "<<<<<<< SEARCH";
|
|
2 |
export const DIVIDER = "=======";
|
3 |
export const REPLACE_END = ">>>>>>> REPLACE";
|
4 |
export const MAX_REQUESTS_PER_IP = 2;
|
5 |
-
export const INITIAL_SYSTEM_PROMPT = `ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. MAKE IT RESPONSIVE USING TAILWINDCSS. Use as much as you can TailwindCSS for the CSS, if you can't do something with TailwindCSS, then use custom CSS (make sure to import <script src="https://cdn.tailwindcss.com"></script> in the head). Also, try to ellaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE
|
6 |
export const FOLLOW_UP_SYSTEM_PROMPT = `You are an expert web developer modifying an existing HTML file.
|
7 |
The user wants to apply changes based on their request.
|
8 |
You MUST output ONLY the changes required using the following SEARCH/REPLACE block format. Do NOT output the entire file.
|
|
|
2 |
export const DIVIDER = "=======";
|
3 |
export const REPLACE_END = ">>>>>>> REPLACE";
|
4 |
export const MAX_REQUESTS_PER_IP = 2;
|
5 |
+
export const INITIAL_SYSTEM_PROMPT = `ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. MAKE IT RESPONSIVE USING TAILWINDCSS. Use as much as you can TailwindCSS for the CSS, if you can't do something with TailwindCSS, then use custom CSS (make sure to import <script src="https://cdn.tailwindcss.com"></script> in the head). Also, try to ellaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE`;
|
6 |
export const FOLLOW_UP_SYSTEM_PROMPT = `You are an expert web developer modifying an existing HTML file.
|
7 |
The user wants to apply changes based on their request.
|
8 |
You MUST output ONLY the changes required using the following SEARCH/REPLACE block format. Do NOT output the entire file.
|
lib/providers.ts
CHANGED
@@ -29,11 +29,6 @@ export const PROVIDERS = {
|
|
29 |
max_tokens: 128_000,
|
30 |
id: "together",
|
31 |
},
|
32 |
-
groq: {
|
33 |
-
name: "Groq",
|
34 |
-
max_tokens: 16_384,
|
35 |
-
id: "groq",
|
36 |
-
},
|
37 |
};
|
38 |
|
39 |
export const MODELS = [
|
@@ -55,19 +50,7 @@ export const MODELS = [
|
|
55 |
"sambanova",
|
56 |
],
|
57 |
autoProvider: "novita",
|
58 |
-
isThinker: true,
|
59 |
-
},
|
60 |
-
{
|
61 |
-
value: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
|
62 |
-
label: "Qwen3 Coder 480B A35B Instruct",
|
63 |
-
providers: ["novita", "hyperbolic"],
|
64 |
-
autoProvider: "novita",
|
65 |
isNew: true,
|
66 |
-
|
67 |
-
{
|
68 |
-
value: "moonshotai/Kimi-K2-Instruct",
|
69 |
-
label: "Kimi K2 Instruct",
|
70 |
-
providers: ["together", "novita", "groq"],
|
71 |
-
autoProvider: "groq",
|
72 |
},
|
73 |
];
|
|
|
29 |
max_tokens: 128_000,
|
30 |
id: "together",
|
31 |
},
|
|
|
|
|
|
|
|
|
|
|
32 |
};
|
33 |
|
34 |
export const MODELS = [
|
|
|
50 |
"sambanova",
|
51 |
],
|
52 |
autoProvider: "novita",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
isNew: true,
|
54 |
+
isThinker: true,
|
|
|
|
|
|
|
|
|
|
|
55 |
},
|
56 |
];
|
public/providers/groq.svg
DELETED