InstantQueryApp1 match
2import getSystemPrompt from "./getSystemPrompt";
34export default async function(req: Request): Promise<Response> {
5if (!Deno.env.get("INSTANT_APP_ID") || !Deno.env.get("INSTANT_ADMIN_TOKEN")) {
6throw new Error("Missing INSTANT_APP_ID or INSTANT_ADMIN_TOKEN");
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">
InstantQuerygetSystemPrompt1 match
1function getSystemPrompt(schema: string) {
2return `You have access to an instantdb database. When people ask for info you will provide it for
3them by creating an instantdb query for the server to query the database. Return the query param json string only -- the json object that query is assigned to.
9const thisURL = parseProject(import.meta.url).links.self.project;
1011function StatusRow({ rows }) {
12return (
13<div className="w-full flex flex-col space-y-2">
31}
3233function StatusSection({ url, rows }) {
34const sectionRows = rows.filter(row => row[0] === url);
35const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
4849export default async function(req: Request): Promise<Response> {
50const { rows } = await sqlite.execute(
51"select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
statussparklineSVG1 match
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2export function SparklineSVG({ strokeWidth = 2, data = [], fill = "none", stroke = "black" }) {
3const padding = 2;
4const xMargin = 25;
4const thisURL = parseProject(import.meta.url).links.self.latest;
56export async function notify(message: string) {
7await email({ subject: message, text: `Email sent from ${thisURL}` });
8}
7);
89export async function uptimeCheck(url: string) {
10let reason: string, status: number, end: number;
11let ok = true;
status_migratedmain.tsx3 matches
5import { renderToString } from "npm:react-dom/server";
67function StatusRow({ rows }) {
8return (
9<div className="w-full flex flex-col space-y-2">
28}
2930function StatusSection({ url, rows }) {
31const sectionRows = rows.filter(row => row[0] === url);
32const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
4546export default async function(req: Request): Promise<Response> {
47const { rows } = await sqlite.execute(
48"select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
InstantQuerygetInstantSchema1 match
1async function getInstantSchema(instantAppId: string, instantAdminToken: string) {
2const response = await fetch("https://api.instantdb.com/admin/schema", {
3method: "GET",
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function translateToEnglishWithOpenAI(text: string) {
4const openai = new OpenAI();
5const completion = await openai.chat.completions.create({