23);
24
25function Hero({
26 prompt,
27 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);
19 <meta property="og:site_name" content="Cerebras Coder">
20 <meta property="og:url" content="https://cerebrascoder.com"/>
21 <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."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {
5## Files
6
7- `readwise-bot.ts` - Standalone function version (can be used as cron)
8- `readwise-http.ts` - HTTP endpoint version with web dashboard ⭐ **Recommended**
9- `README.md` - This documentation
32
33The `readwise-bot.ts` can be:
34- Run manually by calling the function
35- Set up as a cron job for automatic syncing
36
34
35// Initialize database table
36async function initializeDatabase() {
37 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${LINKS_TABLE} (
38 id TEXT PRIMARY KEY,
61
62// Fetch documents from Readwise API
63async function fetchReadwiseShortlist(): Promise<ReadwiseDocument[]> {
64 const token = Deno.env.get('READWISE_TOKEN');
65 if (!token) {
106
107// Save documents to database
108async function saveDocumentsToDatabase(documents: ReadwiseDocument[]) {
109 let savedCount = 0;
110 let updatedCount = 0;
183}
184
185// Main bot function
186export default async function() {
187 try {
188 console.log('Starting Readwise shortlist sync...');
34
35// Initialize database table
36async function initializeDatabase() {
37 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${LINKS_TABLE} (
38 id TEXT PRIMARY KEY,
61
62// Fetch documents from Readwise API
63async function fetchReadwiseShortlist(): Promise<ReadwiseDocument[]> {
64 const token = Deno.env.get('READWISE_TOKEN');
65 if (!token) {
106
107// Save documents to database
108async function saveDocumentsToDatabase(documents: ReadwiseDocument[]) {
109 let savedCount = 0;
110 let updatedCount = 0;
184
185// Get saved links from database
186async function getSavedLinks(limit = 50) {
187 const results = await sqlite.execute(`
188 SELECT id, url, title, author, source, site_name, word_count,
229
230// HTTP handler
231export default async function(req: Request) {
232 const url = new URL(req.url);
233 const path = url.pathname;
318
319 <script>
320 async function syncReadwise() {
321 const resultDiv = document.getElementById('result');
322 resultDiv.innerHTML = '<p>Syncing...</p>';
350 }
351
352 async function loadLinks() {
353 const linksDiv = document.getElementById('links');
354 linksDiv.innerHTML = '<p>Loading...</p>';
16}
17
18export default function VoiceRecorder({ onVoiceNoteCreated }: VoiceRecorderProps) {
19 const [recordingState, setRecordingState] = useState<RecordingState>({
20 isRecording: false,
7}
8
9export default function VoicePlayer({ voiceNoteId }: VoicePlayerProps) {
10 const [voiceNote, setVoiceNote] = useState<VoiceNote | null>(null);
11 const [loading, setLoading] = useState(true);
150 apiKey: Deno.env.get("GROQ_API_KEY") || "",
151});
152// Background transcription function
153async function transcribeAudio(voiceNoteId: string, audioBuffer: ArrayBuffer) {
154 try {
155 // Convert ArrayBuffer to File for OpenAI
9}
10
11export default function ShareModal({ onSave, onCancel, isUploading }: ShareModalProps) {
12 const [expirationType, setExpirationType] = useState<'none' | 'date' | 'listens'>('none');
13 const [expirationDate, setExpirationDate] = useState('');
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.