5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>CerebrasCoder</title>
7 <link rel="preconnect" href="https://fonts.googleapis.com" />
8 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9 <link
10 href="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"
11 rel="stylesheet"
12 />
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">
24
25
16 };
17 } else {
18 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19 const completion = await client.chat.completions.create({
20 messages: [
12 },
13 {
14 "prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15 "title": "Weather App",
16 "code":
8
91. Sign up for [Cerebras](https://cloud.cerebras.ai/)
102. Get a Cerebras API Key
113. Save it in your project env variable called `CEREBRAS_API_KEY`
211 } catch (error) {
212 Toastify({
213 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
214 position: "center",
215 duration: 3000,
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>CerebrasCoder</title>
7 <link rel="preconnect" href="https://fonts.googleapis.com" />
8 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9 <link
10 href="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"
11 rel="stylesheet"
12 />
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">
24
25
16 };
17 } else {
18 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19 const completion = await client.chat.completions.create({
20 messages: [
11## Setup
12
131. **Get your Readwise API token:**
14 - Go to https://readwise.io/access_token
15 - Copy your access token
23### HTTP Version (Recommended)
24
25The `readwise-http.ts` file provides a web interface and API endpoints:
26
27- **Dashboard:** Visit the root URL to see a simple web interface
28- **Sync API:** `POST /sync` - Triggers a sync of your shortlist
29- **Links API:** `GET /links?limit=50` - Retrieves saved links from database
30
31### Standalone Version
70- ✅ **SQLite compatibility:** Properly handles Val Town's SQLite format
71
72## API Examples
73
74### Sync shortlist
91## Environment Variables Required
92
93- `READWISE_TOKEN` - Your Readwise API access token
94
95## Recent Updates
28}
29
30interface ReadwiseApiResponse {
31 results: ReadwiseDocument[];
32 nextPageCursor: string | null;
60}
61
62// Fetch documents from Readwise API
63async function fetchReadwiseShortlist(): Promise<ReadwiseDocument[]> {
64 const token = Deno.env.get('READWISE_TOKEN');
78 }
79
80 console.log('Making Readwise API request with params:', queryParams.toString());
81
82 const response = await fetch(`https://readwise.io/api/v3/list/?${queryParams.toString()}`, {
83 method: 'GET',
84 headers: {
88
89 if (!response.ok) {
90 throw new Error(`Readwise API error: ${response.status} ${response.statusText}`);
91 }
92
93 const responseJson: ReadwiseApiResponse = await response.json();
94 fullData.push(...responseJson.results);
95 nextPageCursor = responseJson.nextPageCursor;
28}
29
30interface ReadwiseApiResponse {
31 results: ReadwiseDocument[];
32 nextPageCursor: string | null;
60}
61
62// Fetch documents from Readwise API
63async function fetchReadwiseShortlist(): Promise<ReadwiseDocument[]> {
64 const token = Deno.env.get('READWISE_TOKEN');
78 }
79
80 console.log('Making Readwise API request with params:', queryParams.toString());
81
82 const response = await fetch(`https://readwise.io/api/v3/list/?${queryParams.toString()}`, {
83 method: 'GET',
84 headers: {
88
89 if (!response.ok) {
90 throw new Error(`Readwise API error: ${response.status} ${response.statusText}`);
91 }
92
93 const responseJson: ReadwiseApiResponse = await response.json();
94 fullData.push(...responseJson.results);
95 nextPageCursor = responseJson.nextPageCursor;