exuberantLimeReindeermain.tsx5 matches
217} catch (error) {
218Toastify({
219text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
220position: "center",
221duration: 3000,
970};
971} else {
972const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
973const completion = await client.chat.completions.create({
974messages: [
1095<meta name="viewport" content="width=device-width, initial-scale=1.0">
1096<title>CerebrasCoder</title>
1097<link rel="preconnect" href="https://fonts.googleapis.com" />
1098<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1099<link
1100href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1101rel="stylesheet"
1102/>
1111<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."">
1112<meta property="og:type" content="website">
1113<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1114
1115
cerebras_coderREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
cerebras_codermain.tsx5 matches
217} catch (error) {
218Toastify({
219text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
220position: "center",
221duration: 3000,
970};
971} else {
972const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
973const completion = await client.chat.completions.create({
974messages: [
1095<meta name="viewport" content="width=device-width, initial-scale=1.0">
1096<title>CerebrasCoder</title>
1097<link rel="preconnect" href="https://fonts.googleapis.com" />
1098<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1099<link
1100href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1101rel="stylesheet"
1102/>
1111<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."">
1112<meta property="og:type" content="website">
1113<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1114
1115
rm_ios_testmain.tsx15 matches
255`);
256257// GET /api/apps => return all apps
258if (request.method === "GET" && request.url.endsWith("/api/apps")) {
259const result = await sqlite.execute(`SELECT * FROM ${KEY}_apps`);
260return new Response(JSON.stringify({ apps: result.rows }), {
262});
263}
264// POST /api/apps => create new app
265else if (request.method === "POST" && request.url.endsWith("/api/apps")) {
266const app = await request.json();
267const id = crypto.randomUUID();
274});
275}
276// PUT /api/apps => update existing app
277else if (request.method === "PUT" && request.url.endsWith("/api/apps")) {
278const app = await request.json();
279await sqlite.execute(
285});
286}
287// DELETE /api/apps/:id => delete an app
288else if (request.method === "DELETE" && /\/api\/apps\/[^/]+$/.test(request.url)) {
289const segments = request.url.split("/");
290const id = segments[segments.length - 1];
294});
295}
296// POST /api/apps/import => bulk import (skip duplicates by name)
297else if (request.method === "POST" && request.url.endsWith("/api/apps/import")) {
298const { apps } = await request.json();
299const existing = await sqlite.execute(`SELECT name FROM ${KEY}_apps`);
575// Get all apps, build categories
576const loadApps = async () => {
577const response = await fetch("/api/apps");
578const data = await response.json();
579setApps(data.apps);
603const handleSave = async (updatedApp: App) => {
604const method = updatedApp.id ? "PUT" : "POST";
605await fetch("/api/apps", {
606method,
607headers: { "Content-Type": "application/json" },
614const handleDelete = async (id: string) => {
615if (!window.confirm("Are you sure you want to delete this app?")) return;
616const resp = await fetch(`/api/apps/${id}`, { method: "DELETE" });
617if (resp.ok) {
618await loadApps();
631// Export
632const handleExportApps = async () => {
633const response = await fetch("/api/apps");
634const data = await response.json();
635const jsonStr = JSON.stringify(data.apps, null, 2);
652const text = await file.text();
653const importedApps = JSON.parse(text);
654await fetch("/api/apps/import", {
655method: "POST",
656headers: { "Content-Type": "application/json" },
emailValHandlerNomain.tsx22 matches
20212. Set up the required environment variable:
22- OPENAI_API_KEY: Your OpenAI API key
2324Optional environment variable:
25- MD_API_KEY: Your API key for the markdown extraction service (if available)
2627You can set these using Val Town's environment variables: https://docs.val.town/reference/environment-variables/
4748- PDFs: Text content will be extracted and analyzed
49- Images: Will be analyzed using GPT-4 Vision API
50- Websites: Content will be extracted and converted to markdown for analysis if the markdown extraction service is available
51- Other file types are not currently supported and will be ignored
62// Main controller function
63export default async function emailValHandler(receivedEmail) {
64const openaiUrl = "https://api.openai.com/v1/chat/completions";
65const openaiKey = Deno.env.get("OPENAI_API_KEY");
66const mdApiKey = Deno.env.get("MD_API_KEY");
67const model = "o1-2024-12-17";
6882// Step 3: Process different types of content
83const { pdfTexts, imageAnalysis } = await processAttachments(attachments, openaiKey, transformedPrompt);
84const websiteMarkdown = await extractWebsiteMarkdown(links, mdApiKey);
8586// Step 4: Create final prompt with all context
125126// Extract website markdown content
127async function extractWebsiteMarkdown(links, apiKey) {
128const markdownResults = [];
129const requestsPerMinute = 5;
145};
146147// Only add headers if API key is available
148if (apiKey) {
149fetchOptions.headers = {
150"Authorization": `Bearer ${apiKey}`,
151"Content-Type": "application/json",
152};
170171// Process image attachments with GPT-4V
172async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
173try {
174const response = await fetch("https://api.openai.com/v1/chat/completions", {
175method: "POST",
176headers: {
177"Content-Type": "application/json",
178"Authorization": `Bearer ${apiKey}`,
179},
180body: JSON.stringify({
214215// Transform the original prompt using the prompt transformer
216async function transformPrompt(emailText, openaiUrl, apiKey, model) {
217const promptTransformerText =
218`You are an AI assistant tasked with transforming user queries into structured research or information requests. Your goal is to take a simple query and expand it into a comprehensive research objective with specific formatting requirements.
288headers: {
289"Content-Type": "application/json",
290Authorization: `Bearer ${apiKey}`,
291},
292});
294const data = await response.json();
295if (data.error) {
296throw new Error(`OpenAI API Error: ${data.error.message}`);
297}
298return data.choices[0]?.message?.content || emailText;
304305// Process all attachments (PDFs and Images)
306async function processAttachments(attachments, apiKey, transformedPrompt) {
307const pdfTexts = [];
308const imageAnalysis = [];
313pdfTexts.push(...pdfText);
314} else if (attachment.type.startsWith("image/")) {
315const analysis = await analyzeImage(attachment, apiKey, transformedPrompt);
316imageAnalysis.push({
317filename: attachment.filename,
383384// Helper function to send a request to OpenAI
385async function sendRequestToOpenAI(prompt, transformedPrompt, openaiUrl, apiKey, model) {
386try {
387// Debug logging for the prompt and transformed prompt
418headers: {
419"Content-Type": "application/json",
420Authorization: `Bearer ${apiKey}`,
421},
422});
425const data = await response.json();
426if (data.error) {
427throw new Error(`OpenAI API Error: ${data.error.message}`);
428}
429return data.choices[0]?.message?.content || "No response from OpenAI.";
emailValHandlerNoREADME.md3 matches
19202. Set up the required environment variables:
21- OPENAI_API_KEY: Your OpenAI API key
22- MD_API_KEY: Your API key for the markdown extraction service
2324You can set these using Val Town's environment variables: https://docs.val.town/reference/environment-variables/
4445- PDFs: Text content will be extracted and analyzed
46- Images: Will be analyzed using GPT-4 Vision API
47- Websites: Content will be extracted and converted to markdown for analysis
48- Other file types are not currently supported and will be ignored
kanbanTodoListmain.tsx2 matches
499<title>Task Board</title>
500<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
501<link rel="preconnect" href="https://fonts.googleapis.com">
502<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
503<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Text:ital@0;1&family=Dancing+Script:wght@400..700&family=Jersey+10&family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Playwrite+AU+SA:wght@100..400&family=Playwrite+IE+Guides&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Rubik+Vinyl&display=swap" rel="stylesheet">
504<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" />
505<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet" />
cerebras_codermain.tsx1 match
20};
21} else {
22const client = new Cerebras({ apiKey: "csk-mn4mrjnj8dx6pe26dfme6v8djjvd65jhedtt464fcxtcfkry" });
23const completion = await client.chat.completions.create({
24messages: [
cerebras_coderREADME.md2 matches
671. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
preciseScarletHerringmain.tsx5 matches
88// Keep these comments so we remember not to change this
89const client = new OpenAI({
90apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91baseURL: "https://api.cerebras.ai/v1",
92});
93101return Response.json({ message: generatedMessage });
102} catch (error) {
103console.error("Error calling Cerebras API:", error);
104105if (error.status === 429) {
106return Response.json({ error: "Cerebras API rate limit reached. Please try again later." }, { status: 429 });
107} else {
108return Response.json({ error: `API Error: ${error.message}` }, { status: 500 });
109}
110}