Chris Tate 5 сар өмнө
parent
commit
241a8107aa

+ 5 - 1
apps/web/app/api/generate/route.ts

@@ -42,13 +42,17 @@ EXAMPLE - Contact Form:
 
 Generate JSONL patches for the user's request:`;
 
+const MAX_PROMPT_LENGTH = 140;
+
 export async function POST(req: Request) {
   const { prompt } = await req.json();
 
+  const sanitizedPrompt = String(prompt || '').slice(0, MAX_PROMPT_LENGTH);
+
   const result = streamText({
     model: gateway('openai/gpt-4o-mini'),
     system: SYSTEM_PROMPT,
-    prompt,
+    prompt: sanitizedPrompt,
     temperature: 0.7,
   });
 

+ 1 - 0
apps/web/components/demo.tsx

@@ -346,6 +346,7 @@ export function Demo() {
                 placeholder="Describe what you want to build..."
                 className="flex-1 bg-transparent outline-none placeholder:text-muted-foreground/50"
                 disabled={isLoading}
+                maxLength={140}
                 autoFocus
               />
             </form>