cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
20if (!file) return null;
2122if (file.type.startsWith("image/")) {
23return (
24<img
25src={URL.createObjectURL(file)}
26alt="Uploaded content"
27className="file-preview-image"
28/>
29);
111type="file"
112onChange={handleFileChange}
113accept="image/*,.pdf"
114style={{ display: "none" }}
115multiple
317];
318319let imageFiles = [];
320if (files && files.length > 0) {
321imageFiles = files.filter(file => file.startsWith("data:image"));
322if (imageFiles.length > 0) {
323messages.push({
324role: "user",
325content: [
326{ type: "text", text: prompt },
327...imageFiles.map(file => ({ type: "image_url", image_url: { url: file } })),
328],
329});
341const completion = await openai.chat.completions.create({
342messages: messages,
343model: imageFiles.length > 0 ? "chatgpt-4o-latest" : "gpt-4o",
344max_tokens: 10000,
345});
630}
631632.file-preview-image {
633max-width: 200px;
634max-height: 200px;
GROKPROMPTmain.tsx35 matches
6/**
7* App Component
8* Handles user input (text or image), communicates with the server to generate prompts,
9* and displays the results. Includes dark mode support.
10*/
13const [input, setInput] = useState("");
14const [file, setFile] = useState(null);
15const [imageIntent, setImageIntent] = useState("recreate");
16const [detailedPrompt, setDetailedPrompt] = useState("");
17const [concisePrompt, setConcisePrompt] = useState("");
48formData.append("text", input);
49} else if (file) {
50formData.append("image", file);
51formData.append("imageIntent", imageIntent);
52}
53190<p className="text-lg font-semibold">How to Use:</p>
191<ol className="list-decimal list-inside mt-2 space-y-1 text-sm">
192<li>Choose between text or image input.</li>
193<li>Write your idea or upload an image.</li>
194<li>For image recreation, select "Recreate" (the "Modify" option is under construction).</li>
195<li>Click "Generate Prompts" to create your enhanced prompts.</li>
196<li>Copy and paste the generated prompts into Grok!</li>
220<button
221type="button"
222onClick={() => setInputType("image")}
223className={`flex-1 py-2 px-4 rounded-lg font-semibold text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 transition-colors duration-200
224${
225inputType === "image"
226? "bg-purple-600 text-white"
227: isDarkMode
231`}
232>
233Image
234</button>
235</div>
252<input
253type="file"
254accept="image/*"
255onChange={(e) => setFile(e.target.files?.[0])}
256className={`w-full rounded-lg mt-2 border shadow-sm focus:border-purple-500 focus:ring-purple-500
271<button
272type="button"
273onClick={() => setImageIntent("recreate")}
274className={`flex-1 py-2 px-4 rounded-lg font-semibold text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 transition-colors duration-200
275${
276imageIntent === "recreate"
277? "bg-purple-600 text-white"
278: isDarkMode
282`}
283>
284Recreate Image
285</button>
286<button
287type="button"
288onClick={() => setImageIntent("modify")}
289className={`flex-1 py-2 px-4 rounded-lg font-semibold text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 transition-colors duration-200
290${
291imageIntent === "modify"
292? "bg-purple-600 text-white"
293: isDarkMode
297`}
298>
299Modify Image
300</button>
301</div>
525/**
526* Server-side logic for generating prompts.
527* The server expects a POST request to "/generate-prompts" with either text or image form data.
528* It uses OpenAI API to generate detailed and concise prompts.
529*/
538let analysisMessages: {
539role: string;
540content: string | { type: string; text?: string; image_url?: { url: string } };
541}[] = [];
542550- Detailed Prompt: A comprehensive narrative (max 1024 characters).
551- Concise Prompt: A brief, streamlined version capturing the core essence.
5523. For image inputs, confirm the user's intent (recreate or modify).
5534. Use intelligent strategies for creative and actionable prompts:
554- Include specific details, art styles, mediums, and perspectives.
586content: `Generate prompts based on this input: ${text}`,
587});
588} else if (inputType === "image") {
589const image = formData.get("image") as File;
590const imageIntent = formData.get("imageIntent") as string;
591592if (!image) {
593throw new Error("No image file provided");
594}
595596// Convert image to base64
597const imageBase64 = await new Promise<string>((resolve, reject) => {
598const reader = new FileReader();
599reader.onloadend = () => {
601resolve(reader.result.split(",")[1]); // Remove the data URL prefix
602} else {
603reject(new Error("Failed to read image"));
604}
605};
606reader.onerror = reject;
607reader.readAsDataURL(image);
608});
609613{
614type: "text",
615text: `Generate prompts to ${imageIntent === "recreate" ? "recreate" : "modify"} this image:`,
616},
617{
618type: "image_url",
619image_url: {
620url: `data:image/jpeg;base64,${imageBase64}`,
621},
622},
708- Detailed Prompt: A comprehensive narrative (max 1024 characters).
709- Concise Prompt: A brief, streamlined version capturing the core essence.
7103. For image inputs, confirm the user's intent (recreate or modify).
7114. Use intelligent strategies for creative and actionable prompts:
712- Include specific details, art styles, mediums, and perspectives.
743role: "user",
744content:
745`Original input was an image.\nClarification: ${clarificationAnswer}\nGenerate prompts based on this clarified input.`,
746};
747}
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
cerebras_codermain.tsx1 match
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169