cerebras_codermain.tsx11 matches
26const PoweredByInfo = "";
2728function Hero({
29prompt,
30setPrompt,
4748<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49Turn your ideas into fully functional apps in{" "}
50<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51less than a second!
121}
122123function App() {
124const previewRef = React.useRef<HTMLDivElement>(null);
125const [prompt, setPrompt] = useState("");
175});
176177function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178setLoading(true);
179setTimeout(() => handleSubmit(promptItem.prompt), 0);
180}
181182async function handleSubmit(e: React.FormEvent | string) {
183if (typeof e !== "string") {
184e.preventDefault();
231}
232233function handleVersionChange(direction: "back" | "forward") {
234const { currentVersionIndex, versions } = versionHistory;
235if (direction === "back" && currentVersionIndex > 0) {
920);
921922function client() {
923const path = window.location.pathname;
924const root = createRoot(document.getElementById("root")!);
956}
957958function extractCodeFromFence(text: string): string {
959const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960return htmlMatch ? htmlMatch[1].trim() : text;
961}
962963async function generateCode(prompt: string, currentCode: string) {
964const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965if (starterPrompt) {
1006}
10071008export default async function cerebras_coder(req: Request): Promise<Response> {
1009// Dynamic import for SQLite to avoid client-side import
1010const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109<meta property="og:site_name" content="Cerebras Coder">
1110<meta property="og:url" content="https://cerebrascoder.com"/>
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">
1export async function getLatestYouTubeVideoFromChannel(channelId: string): Promise<
2{
3title: string;
rm_ios_testmain.tsx8 matches
215* Generates the main HTML shell, injecting the CSS and the client script.
216*/
217function generateHTML(importMetaUrl: string) {
218return `
219<!DOCTYPE html>
236237/**
238* Server function that handles HTTP routes, DB setup, and returns HTML.
239*/
240export default async function server(request: Request): Promise<Response> {
241const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
242const KEY = "rm_ios_test";
341* React component that shows an individual app icon & title.
342*/
343function AppCard({ app, onEdit }: { app: App; onEdit: (app: App) => void }) {
344// Click or "Enter" => open via iOS Shortcut
345const handleClick = () => {
378* Overlay to add or edit an app.
379*/
380function AppOverlay({
381app,
382onSave,
512* Overlay for changing settings (e.g., grouping by category).
513*/
514function SettingsOverlay({
515groupByCategory,
516onChangeGroupByCategory,
558* Main React component that displays the header, categories, apps, & state.
559*/
560function App() {
561const [selectedCategory, setSelectedCategory] = useState("All");
562const [apps, setApps] = useState<App[]>([]);
779* Client entry-point to render the React App.
780*/
781function client() {
782createRoot(document.getElementById("root")!).render(<App />);
783}
emailValHandlerNomain.tsx14 matches
60import { pdfText } from "jsr:@pdf/pdftext";
6162// 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");
102103// Extract attachments (if any)
104async function extractAttachments(email) {
105if (!email.attachments || email.attachments.length === 0) {
106return [];
119120// Extract links from email text
121function extractLinks(text) {
122const urlRegex = /(https?:\/\/[^\s]+)/g;
123return text.match(urlRegex) || [];
125126// Extract website markdown content
127async function extractWebsiteMarkdown(links, apiKey) {
128const markdownResults = [];
129const requestsPerMinute = 5;
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", {
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.
304305// Process all attachments (PDFs and Images)
306async function processAttachments(attachments, apiKey, transformedPrompt) {
307const pdfTexts = [];
308const imageAnalysis = [];
324}
325326async function extractPdfText(attachments) {
327const pdfTexts = [];
328358359// Generate the final prompt with all context
360function generateFinalPrompt(transformedPrompt, pdfTexts, imageAnalysis, websiteMarkdown, email) {
361let contextDump = [];
362382}
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
434}
435436// Helper function to send a response back via email
437async function sendResponseByEmail(toEmail, responseContent) {
438const subject = "AI Response to Your Email";
439const text = `${responseContent}`;
tolerantOlivePonymain.tsx2 matches
23const service = new InferableService({
4description: "My functions",
5token: "sk-inf-val-29f8be75-ab85-49ac-8f68-7ed55f18c6bf",
6});
78service.registerFunction({
9name: "date",
10description: "Get the current date",
kanbanTodoListmain.tsx16 matches
8import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
910function TaskBoard() {
11const [taskLists, setTaskLists] = useState({
12todo: [],
44}, []);
4546function loadUserPreferences() {
47const savedDarkMode = localStorage.getItem("app-theme") === "true";
48setIsDarkMode(savedDarkMode);
59}
6061function updateAppStyle(font, size) {
62document.body.style.setProperty("--app-font", font);
63document.body.style.setProperty("--app-font-size", `${size}px`);
64}
6566function saveUserPreferences() {
67localStorage.setItem("app-font", chosenFont);
68localStorage.setItem("app-font-size", fontSize.toString());
72}
7374async function fetchTasks() {
75try {
76const response = await fetch("/get-tasks");
82}
8384async function addNewTask() {
85if (!newTaskText.trim()) return;
86102}
103104async function handleTaskMove(result) {
105const { destination, source, draggableId } = result;
106if (!destination) return;
123}
124125async function removeTask(taskId, column) {
126try {
127const response = await fetch("/delete-task", {
137}
138139async function moveTaskForward(task, currentColumn) {
140const currentIndex = listProgression.indexOf(currentColumn);
141const nextColumn = listProgression[currentIndex + 1];
158}
159160function toggleDarkMode() {
161const newDarkMode = !isDarkMode;
162setIsDarkMode(newDarkMode);
165}
166167function openEditModal(task) {
168setTaskBeingEdited(task);
169setEditedTaskText(task.title);
171}
172173async function saveEditedTask() {
174if (!editedTaskText.trim() || !taskBeingEdited) return;
175try {
191}
192193function handleTaskInteraction(e, task, column) {
194if (e.button === 1) {
195e.preventDefault();
432}
433434function client() {
435createRoot(document.getElementById("root")).render(<TaskBoard />);
436}
439}
440441export default async function server(request: Request): Promise<Response> {
442const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
443const KEY = "kanbanTodoList";
517}
518519async function getAllTasks(sqlite, KEY, SCHEMA_VERSION) {
520const todo = await sqlite.execute(
521`SELECT * FROM ${KEY}_tasks_${SCHEMA_VERSION} WHERE column = 'todo'`,
cerebras_codermain.tsx5 matches
6import { STARTER_PROMPTS } from "https://esm.town/v/stevekrouse/cerebras_coder_prompts";
78function extractCodeFromFence(content: string): string {
9const codeMatch = content.match(/```html\n([\s\S]*?)```/);
10return codeMatch ? codeMatch[1].trim() : content.trim();
11}
1213async function generateCode(prompt: string, currentCode: string) {
14const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
15if (starterPrompt) {
56}
5758function App() {
59const [prompt, setPrompt] = useState('');
60const [generatedCode, setGeneratedCode] = useState('');
255}
256257function client() {
258// Add Tailwind CSS for styling
259const tailwindScript = document.createElement('script');
265if (typeof document !== "undefined") { client(); }
266267export default async function server(request: Request): Promise<Response> {
268if (request.method === 'POST' && new URL(request.url).pathname === '/generate') {
269try {
townieIllustratorPromptmain.tsx4 matches
3First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface.
45Core Functionality
67- Accept an app name as input (e.g., "Zoom", "Slack", "Discord")
8- Generate a single val that renders a minimal, branded mockup of the app's main interface
9- Allow the user to export a png screenshot with transparent background with rounded corners (8px radius)
10- Move the `html2canvas` import inside the `client()` function.
11- Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side.
12- Use dynamic import for `html2canvas` inside the `exportAsPNG` function.
13- Make sure html2canvas is only loaded and used on the client-side
14
townieIllustratorPromptREADME.md4 matches
6First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface.
78Core Functionality
910- Accept an app name as input (e.g., "Zoom", "Slack", "Discord")
11- Generate a single val that renders a minimal, branded mockup of the app's main interface
12- Allow the user to export a png screenshot with transparent background with rounded corners (8px radius)
13- Move the `html2canvas` import inside the `client()` function.
14- Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side.
15- Use dynamic import for `html2canvas` inside the `exportAsPNG` function.
16- Make sure html2canvas is only loaded and used on the client-side
17
preciseScarletHerringmain.tsx3 matches
3import React, { useState } from "https://esm.sh/react@18.2.0";
45function App() {
6const [messages, setMessages] = useState([]);
7const [input, setInput] = useState("");
71}
7273function client() {
74createRoot(document.getElementById("root")).render(<App />);
75}
79}
8081export default async function server(request: Request): Promise<Response> {
82if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
83const { messages } = await request.json();