generateFunctionmain.tsx7 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23function extractCode(str: string): string {
4const regex = /```[a-z]+\n([\s\S]*?)\n```/;
5const match = str.match(regex);
11}
1213export async function generateFunction(
14functionName: string,
15parameters: string,
16): Promise<string> {
17if (!functionName) {
18return "Please provide a function name";
19}
2021const openai = new OpenAI();
22const prompt =
23`Generate a TypeScript function named "${functionName}" with the following parameters: ${parameters}. ONLY RETURN VALID JAVASCRIPT DO NOT INCLUDE ANY CONTEXT.`;
24const completion = await openai.chat.completions.create({
25messages: [
27role: "system",
28content:
29"You are a helpful assistant that generates JAVASCRIPT functions. Be fuzzy with typing since you do not know what the types of the function inputs will be, but assum the number of arguments is reasonable (e.g. addTwoNumbers will take two numbers).",
30},
31{ role: "user", content: prompt },
ciceroAISiteDesignmain.tsx5 matches
218`;
219220function AnimatedHeadline() {
221const [animationStarted, setAnimationStarted] = useState(false);
222const contentRef = useRef(null);
421`;
422423function FeatureCarousel() {
424const features = [
425{ icon: "âš¡", title: "Speed", description: "Draft in minutes, not hours" },
445}
446447function App() {
448const [isNavOpen, setIsNavOpen] = React.useState(false);
449505}
506507function client() {
508const root = document.getElementById("root");
509if (root) {
527}
528529export default async function server(request: Request): Promise<Response> {
530return new Response(`
531<!DOCTYPE html>
laudableCrimsonCoyotemain.tsx7 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function LoadingSpinner() {
6return (
7<div className="loading-spinner">
12}
1314function cleanText(text: string) {
15return text
16.replace(/\*+/g, '')
19}
2021function App() {
22const [storyParts, setStoryParts] = useState({
23title: null,
133}
134135function client() {
136createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142let timeoutHandle: number;
143const timeoutPromise = new Promise<never>((_, reject) => {
152}
153154export default async function server(request: Request): Promise<Response> {
155if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156const formData = await request.formData();
versatileAquamarineBoarmain.tsx4 matches
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
45function TransactionParser() {
6const [inputLog, setInputLog] = useState("");
7const [transactions, setTransactions] = useState([]);
264};
265266function App() {
267return <TransactionParser />;
268}
269270function client() {
271createRoot(document.getElementById("root")).render(<App />);
272}
273if (typeof document !== "undefined") { client(); }
274275export default async function server(request: Request): Promise<Response> {
276return new Response(
277`
Storyweavermain.tsx7 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function LoadingSpinner() {
6return (
7<div className="loading-spinner">
12}
1314function cleanText(text: string) {
15return text
16.replace(/\*+/g, '')
19}
2021function App() {
22const [storyParts, setStoryParts] = useState({
23title: null,
133}
134135function client() {
136createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142let timeoutHandle: number;
143const timeoutPromise = new Promise<never>((_, reject) => {
152}
153154export default async function server(request: Request): Promise<Response> {
155if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156const formData = await request.formData();
8};
910function App() {
11const [isPending, startTransition] = useTransition();
12const [likes, setLikes] = useState(0);
43}
4445export default async function server(request: Request): Promise<Response> {
46const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
47const KEY = "app";
readySilverMandrillmain.tsx11 matches
24);
2526function Hero({
27prompt,
28setPrompt,
4546<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47Turn your ideas into fully functional apps in{" "}
48<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49less than a second
116}
117118function App() {
119const previewRef = React.useRef<HTMLDivElement>(null);
120const [prompt, setPrompt] = useState("");
170});
171172function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173setLoading(true);
174setTimeout(() => handleSubmit(promptItem.prompt), 0);
175}
176177async function handleSubmit(e: React.FormEvent | string) {
178if (typeof e !== "string") {
179e.preventDefault();
226}
227228function handleVersionChange(direction: "back" | "forward") {
229const { currentVersionIndex, versions } = versionHistory;
230if (direction === "back" && currentVersionIndex > 0) {
974);
975976function client() {
977const path = window.location.pathname;
978const root = createRoot(document.getElementById("root")!);
1010}
10111012function extractCodeFromFence(text: string): string {
1013const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014return htmlMatch ? htmlMatch[1].trim() : text;
1015}
10161017async function generateCode(prompt: string, currentCode: string) {
1018const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019if (starterPrompt) {
1060}
10611062export default async function cerebras_coder(req: Request): Promise<Response> {
1063// Dynamic import for SQLite to avoid client-side import
1064const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163<meta property="og:site_name" content="Cerebras Coder">
1164<meta property="og:url" content="https://cerebrascoder.com"/>
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">
parseTransactionsmain.tsx4 matches
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
45function TransactionParser() {
6const [inputLog, setInputLog] = useState("");
7const [transactions, setTransactions] = useState([]);
264};
265266function App() {
267return <TransactionParser />;
268}
269270function client() {
271createRoot(document.getElementById("root")).render(<App />);
272}
273if (typeof document !== "undefined") { client(); }
274275export default async function server(request: Request): Promise<Response> {
276return new Response(
277`
cerebras_codermain.tsx11 matches
24);
2526function Hero({
27prompt,
28setPrompt,
4546<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47Turn your ideas into fully functional apps in{" "}
48<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49less than a second
116}
117118function App() {
119const previewRef = React.useRef<HTMLDivElement>(null);
120const [prompt, setPrompt] = useState("");
170});
171172function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173setLoading(true);
174setTimeout(() => handleSubmit(promptItem.prompt), 0);
175}
176177async function handleSubmit(e: React.FormEvent | string) {
178if (typeof e !== "string") {
179e.preventDefault();
226}
227228function handleVersionChange(direction: "back" | "forward") {
229const { currentVersionIndex, versions } = versionHistory;
230if (direction === "back" && currentVersionIndex > 0) {
974);
975976function client() {
977const path = window.location.pathname;
978const root = createRoot(document.getElementById("root")!);
1010}
10111012function extractCodeFromFence(text: string): string {
1013const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014return htmlMatch ? htmlMatch[1].trim() : text;
1015}
10161017async function generateCode(prompt: string, currentCode: string) {
1018const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019if (starterPrompt) {
1060}
10611062export default async function cerebras_coder(req: Request): Promise<Response> {
1063// Dynamic import for SQLite to avoid client-side import
1064const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163<meta property="og:site_name" content="Cerebras Coder">
1164<meta property="og:url" content="https://cerebrascoder.com"/>
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">
interview_practicemain.tsx3 matches
14}
1516function App() {
17const [intervieweeResponse, setIntervieweeResponse] = useState("");
18const [response, setResponse] = useState("");
225}
226227function client() {
228createRoot(document.getElementById("root")).render(<App />);
229}
230if (typeof document !== "undefined") { client(); }
231232export default async function server(request: Request): Promise<Response> {
233if (request.method === "POST" && new URL(request.url).pathname === "/ask") {
234try {