diff --git a/app/api/ask/route.ts b/app/api/ask/route.ts
index 74041b2dc4bcdb53574abacc010ddca884beb110..6a871c52c7748eef3a01b9392d2100fbb6370fb1 100644
--- a/app/api/ask/route.ts
+++ b/app/api/ask/route.ts
@@ -18,6 +18,7 @@ import {
UPDATE_PAGE_END,
PROMPT_FOR_PROJECT_NAME,
} from "@/lib/prompts";
+import { calculateMaxTokens, estimateInputTokens, getProviderSpecificConfig } from "@/lib/max-tokens";
import MY_TOKEN_KEY from "@/lib/get-cookie-name";
import { Page } from "@/types";
import { createRepo, RepoDesignation, uploadFiles } from "@huggingface/hub";
@@ -25,6 +26,7 @@ import { isAuthenticated } from "@/lib/auth";
import { getBestProvider } from "@/lib/best-provider";
import { rewritePrompt } from "@/lib/rewrite-prompt";
import { COLORS } from "@/lib/utils";
+import { templates } from "@/lib/templates";
const ipAddresses = new Map();
@@ -122,6 +124,21 @@ export async function POST(request: NextRequest) {
// let completeResponse = "";
try {
const client = new InferenceClient(token);
+
+ // Calculate dynamic max_tokens based on provider and input size
+ const systemPrompt = INITIAL_SYSTEM_PROMPT + (enhancedSettings.isActive ? `
+Here are some examples of designs that you can inspire from:
+${templates.map((template) => `- ${template}`).join("\n")}
+IMPORTANT: Use the templates as inspiration, but do not copy them exactly.
+Try to create a unique design, based on the templates, but not exactly like them, mostly depending on the user's prompt. These are just examples, do not copy them exactly.
+` : "");
+
+ const userPrompt = `${rewrittenPrompt}${redesignMarkdown ? `\n\nHere is my current design as a markdown:\n\n${redesignMarkdown}\n\nNow, please create a new design based on this markdown. Use the images in the markdown.` : ""} : ""}`;
+
+ const estimatedInputTokens = estimateInputTokens(systemPrompt, userPrompt);
+ const dynamicMaxTokens = calculateMaxTokens(selectedProvider, estimatedInputTokens, true);
+ const providerConfig = getProviderSpecificConfig(selectedProvider, dynamicMaxTokens);
+
const chatCompletion = client.chatCompletionStream(
{
model: selectedModel.value,
@@ -129,14 +146,14 @@ export async function POST(request: NextRequest) {
messages: [
{
role: "system",
- content: INITIAL_SYSTEM_PROMPT,
+ content: systemPrompt,
},
{
role: "user",
- content: `${rewrittenPrompt}${redesignMarkdown ? `\n\nHere is my current design as a markdown:\n\n${redesignMarkdown}\n\nNow, please create a new design based on this markdown. Use the images in the markdown.` : ""} : ""}`
+ content: userPrompt
},
],
- max_tokens: 65_536,
+ ...providerConfig,
},
billTo ? { billTo } : {}
);
@@ -297,6 +314,21 @@ export async function PUT(request: NextRequest) {
const selectedProvider = await getBestProvider(selectedModel.value, provider)
try {
+ // Calculate dynamic max_tokens for PUT request
+ const systemPrompt = FOLLOW_UP_SYSTEM_PROMPT + (isNew ? PROMPT_FOR_PROJECT_NAME : "");
+ const userContext = previousPrompts
+ ? `Also here are the previous prompts:\n\n${previousPrompts.map((p: string) => `- ${p}`).join("\n")}`
+ : "You are modifying the HTML file based on the user's request.";
+ const assistantContext = `${
+ selectedElementHtml
+ ? `\n\nYou have to update ONLY the following element, NOTHING ELSE: \n\n\`\`\`html\n${selectedElementHtml}\n\`\`\` Could be in multiple pages, if so, update all the pages.`
+ : ""
+ }. Current pages: ${pages?.map((p: Page) => `- ${p.path} \n${p.html}`).join("\n")}. ${files?.length > 0 ? `Current images: ${files?.map((f: string) => `- ${f}`).join("\n")}.` : ""}`;
+
+ const estimatedInputTokens = estimateInputTokens(systemPrompt, prompt, userContext + assistantContext);
+ const dynamicMaxTokens = calculateMaxTokens(selectedProvider, estimatedInputTokens, false);
+ const providerConfig = getProviderSpecificConfig(selectedProvider, dynamicMaxTokens);
+
const response = await client.chatCompletion(
{
model: selectedModel.value,
@@ -304,33 +336,22 @@ export async function PUT(request: NextRequest) {
messages: [
{
role: "system",
- content: FOLLOW_UP_SYSTEM_PROMPT + (isNew ? PROMPT_FOR_PROJECT_NAME : ""),
+ content: systemPrompt,
},
{
role: "user",
- content: previousPrompts
- ? `Also here are the previous prompts:\n\n${previousPrompts.map((p: string) => `- ${p}`).join("\n")}`
- : "You are modifying the HTML file based on the user's request.",
+ content: userContext,
},
{
role: "assistant",
-
- content: `${
- selectedElementHtml
- ? `\n\nYou have to update ONLY the following element, NOTHING ELSE: \n\n\`\`\`html\n${selectedElementHtml}\n\`\`\` Could be in multiple pages, if so, update all the pages.`
- : ""
- }. Current pages: ${pages?.map((p: Page) => `- ${p.path} \n${p.html}`).join("\n")}. ${files?.length > 0 ? `Current images: ${files?.map((f: string) => `- ${f}`).join("\n")}.` : ""}`,
+ content: assistantContext,
},
{
role: "user",
content: prompt,
},
],
- ...(selectedProvider.provider !== "sambanova"
- ? {
- max_tokens: 65_536,
- }
- : {}),
+ ...providerConfig,
},
billTo ? { billTo } : {}
);
diff --git a/assets/deepseek.svg b/assets/deepseek.svg
new file mode 100644
index 0000000000000000000000000000000000000000..dc224e43a4d68070ca6eed494476c8ddd900bf80
--- /dev/null
+++ b/assets/deepseek.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/kimi.svg b/assets/kimi.svg
new file mode 100644
index 0000000000000000000000000000000000000000..4355c522a2dece99e187d9e5c898a66313f4a374
--- /dev/null
+++ b/assets/kimi.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/qwen.svg b/assets/qwen.svg
new file mode 100644
index 0000000000000000000000000000000000000000..a4bb382a6359b82c581fd3e7fb7169fe8fba1657
--- /dev/null
+++ b/assets/qwen.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/components/editor/ask-ai/fake-ask.tsx b/components/editor/ask-ai/fake-ask.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..a5ba64265964d6e8d37c1ddd7d451ebb4d77f47c
--- /dev/null
+++ b/components/editor/ask-ai/fake-ask.tsx
@@ -0,0 +1,75 @@
+import { useState } from "react";
+import { useLocalStorage } from "react-use";
+import { ArrowUp } from "lucide-react";
+import { useRouter } from "next/navigation";
+
+import { Button } from "@/components/ui/button";
+import { useLoginModal } from "@/components/contexts/login-context";
+import { PromptBuilder } from "./prompt-builder";
+import { EnhancedSettings } from "@/types";
+import { Settings } from "./settings";
+
+export const FakeAskAi = () => {
+ const router = useRouter();
+ const [prompt, setPrompt] = useState("");
+ const [openProvider, setOpenProvider] = useState(false);
+ const [enhancedSettings, setEnhancedSettings, removeEnhancedSettings] =
+ useLocalStorage
Want to learn how to build templates like this one? Visit www.pixelrocket.store
+
+
+ Our commitment to green energy is paving the way for a cleaner, healthier planet. Join us on a journey towards a future where clean, renewable energy sources transform the way we power our lives.
See our solutions +EVs use electricity as a power source, which can be generated from renewable energy sources. Our solutions help reducing greenhouse gas emissions in the transportation sector.
Read more +Solar panels convert sunlight into electricity. Photovoltaic (PV) cells on these panels capture the energy from the sun and convert it into electrical power.
Read more +Wind turbines harness the kinetic energy of the wind to generate electricity. Wind farms with multiple turbines are commonly used to produce large amounts of clean energy.
Read more +This technology uses the energy from flowing water, such as rivers and dams, to turn turbines and generate electricity. It's one of the oldest forms of renewable energy.
Read more +





Here you will find the answers to the frequently asked questions.
+For assistance, please visit our Contact Us page or call our customer support hotline at (671) 555-0110 . Our dedicated team is ready to help you on your journey to a greener, more sustainable future.
+


Visit www.pixelrocket.store and learn how to become a frontend web developer
+
+ Stay in the loop with our Green Horizon newsletter, where we deliver bite-sized insights into the latest green energy solutions.
+Want to learn how to build websites like this one? Visit Pixel Rocket
+
Global Bank is a strategic branding agency focused on brand creation, rebrands, and brand
+
+
+
+
+
+
+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum i
+
+
+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum i
+
+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum i
+
+ It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum i
+
+ Global Bank is a strategic branding agency focused on brand creation, rebrands, and brand
+@lesliealexnader
+Finances are very important to me. I regularly plan my expensesand save for the future.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@kristinawatson
+Finances are very important to me. I regularly plan my expensesand save for the future.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@marvinmckinney
+Finances are a part of life that needs constant attention. I try to regularly analyze my expenses
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@robmason
+Prioritizing finances is a constant for me. I regularly budget and save, emphasizing the importance of planning for the future.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@kathrynmurphy
+Finances are one of the most important things in life. I have to be careful not to spend too much and have enough money for everything
+I'm not very knowledgeable about finances, but I try to stay on top of my expenses and take advice from experts."
+I don't like thinking about finances, but I know I have to take care of them. I try to take care of my savings and control my expenses.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@brooklynsimmons
+Finances are a matter of responsibility and discipline for me. I try to monitor my expenses and savings on an ongoing basis to avoid financial problem
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@lucasfloe
+I firmly believe that investing in education and acquiring new skills is pivotal for a secure financial future. It's a strategic move that aligns with my commitment to financial stability.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@devonlane
+Finances are a part of life that needs constant attention. I try to regularly analyze my expenses
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@arlenemccoy
+Finances are a part of life that needs constant attention. I try to regularly analyze my expenses
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@bessiecooper
+I'm interested in new technologies in the field of finance, such as blockchain or robo-advisors. I believe these new tools can help manage money more efficiently.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@mikerochs
+Financial management can be a source of stress. Balancing budgets and making prudent decisions requires careful consideration, but it's a challenge I navigate diligently.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@jeromebell
+I'm convinced that investing in education and acquiring new skills is a key factor in building a stable financial future.
+Managing finances can be stressful.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@ronaldrichards
+I'm convinced that investing in education and acquiring new skills is a key factor in building a stable financial future.
+Managing finances can be stressful.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+@kevinroland
+Responsibility and discipline drive my approach to finances. Regularly monitoring expenses and savings is a routine for me, ensuring a proactive stance to prevent potential financial issues.
+Managing finances can be stressful.
+5:48 PM
+Sep 15, 2023
+232 like
+81 com.
+



+
+ Global Bank is a strategic branding agency focused on brand creation, rebrands, and brand
+© 2023 Global Bank
+Want to learn how to build templates like this one? Visit www.pixelrocket.store
+
+ Our commitment to green energy is paving the way for a cleaner, healthier planet. Join us on a journey towards a future where clean, renewable energy sources transform the way we power our lives.
+ +

Our commitment to green energy is paving the way for a cleaner, healthier planet.
+Solar panels convert sunlight into electricity. Photovoltaic (PV) cells on these panels capture the energy from the sun and convert it into electrical power.
Learn more +Solar panels convert sunlight into electricity. Photovoltaic (PV) cells on these panels capture the energy from the sun and convert it into electrical power.
Learn more +Solar panels convert sunlight into electricity. Photovoltaic (PV) cells on these panels capture the energy from the sun and convert it into electrical power.
Learn more +Solar panels convert sunlight into electricity. Photovoltaic (PV) cells on these panels capture the energy from the sun and convert it into electrical power.
Learn more +
We are committed to a sustainable future
+Our commitment to sustainability shines through as we proudly announce the generation of 5,000 megawatt-hours of renewable energy, contributing to a greener and more environmentally friendly future.
+With gratitude, we celebrate the trust of over 10,000 satisfied customers. Your confidence fuels our dedication to providing exceptional service and forging lasting partnerships.
+Embracing efficiency, we are delighted to report an average energy savings of 15%. This milestone reflects our ongoing efforts to optimize resources and promote a more sustainable energy landscape.
+Our team boasts top green energy experts, driving innovation in sustainability.
+
+
+
+
+
+
+
+
+
+ Stay in the loop with our Green Horizon newsletter, where we deliver bite-sized insights into the latest green energy solutions.
+Tailwind Template created by Pixel Rocket
+
+
+ + Lorem ipsum dolor sit amet consectetur, adipisicing + elit. Beatae, vero. +
+ + Learn more + + +
+ + Lorem, ipsum dolor sit amet consectetur adipisicing + elit. Eum dolorum unde voluptatibus fuga soluta + consequuntur! +
+ + Learn more + + +
+ + Lorem ipsum dolor sit amet consectetur adipisicing + elit. Aut dolorem, optio totam perspiciatis, + perferendis assumenda nulla eaque autem ad magnam + quisquam voluptates dolor nostrum quae odit numquam + voluptas in atque. +
+ + Learn more + + +
+ + Lorem ipsum dolor sit amet consectetur adipisicing + elit. Culpa, tempora. +
+ + Learn more + + +
+ + Lorem ipsum dolor, sit amet consectetur adipisicing + elit. Velit, voluptates. +
+ + Learn more + + +
+ + Lorem ipsum dolor, sit amet consectetur adipisicing + elit. Velit, voluptates. +
+ + Learn more + + +
+ Lamie
++ Product manager, Apple +
+
+ Joy
++ Head of AI, Apple +
+
+ Ben
++ Senior manager, Google +
+
+ Laura
++ UI & UX, Apple +
+
+ + Lorem ipsum dolor sit amet consectetur adipisicing elit. + Ab, explicabo! +
+ + Learn more + + + + +
+ + Lorem ipsum dolor sit amet consectetur adipisicing elit. + Ab, explicabo! +
+ + Learn more + + + + +
+ + Lorem ipsum dolor sit amet consectetur adipisicing elit. + Ab, explicabo! +
+ + Learn more + + + ++ Themeptation helping enterprises to create great Templates + websites perfectly. +
+
+
+ + Themeptation helping enterprises to create great Templates + websites perfectly. +
++ Free and Premium themes, UI Kit's, templates and landing + pages built with Tailwind CSS, HTML & Next.js. +
++ Free and Premium themes, UI Kit's, templates and landing + pages built with Tailwind CSS, HTML & Next.js. +
++ Free and Premium themes, UI Kit's, templates and landing + pages built with Tailwind CSS, HTML & Next.js. +
++ Free and Premium themes, UI Kit's, templates and landing + pages built with Tailwind CSS, HTML & Next.js. +
++ $0 + /month +
++ The essentials to provide your best work for clients. +
+ + + What's included? + ++ $19 + /month +
++ A plan that scales with your rapidly growing business. +
+ + What's included? +