83
84export default async function gatherPatreonPosts(interval: Interval) {
85 let apiUrl =
86 `https://www.patreon.com/api/posts?fields[campaign]=name%2Curl%2Cpatron_count&fields[post]=change_visibility_at%2Ccomment_count%2Ccommenter_count%2Ccontent%2Ccreated_at%2Ccurrent_user_can_comment%2Ccurrent_user_can_delete%2Ccurrent_user_can_report%2Ccurrent_user_can_view%2Ccurrent_user_comment_disallowed_reason%2Ccurrent_user_has_liked%2Cembed%2Cimage%2Cinsights_last_updated_at%2Cis_paid%2Cis_preview_blurred%2Chas_custom_thumbnail%2Clike_count%2Cpublished_at%2Cpatreon_url%2Cpost_type%2Cpledge_url%2Cpreview_asset_type%2Cthumbnail%2Cthumbnail_url%2Cteaser_text%2Ccontent_teaser_text%2Ctitle%2Cupgrade_url%2Curl%2Cwas_posted_by_campaign_owner%2Chas_ti_violation%2Cmoderation_status%2Cpost_level_suspension_removal_date%2Cpls_one_liners_by_category%2Cvideo%2Cvideo_preview%2Cview_count%2Ccontent_unlock_options%2Cis_new_to_current_user%2Cwatch_state&fields[post_tag]=tag_type%2Cvalue&fields[user]=image_url%2Cfull_name%2Curl&filter[campaign_id]=76490&filter[contains_exclusive_posts]=true&sort=published_at&json-api-use-default-includes=false&json-api-version=1.0`;
87
88 await createPostsTable();
93
94 while (true) {
95 const response = await fetch(apiUrl);
96 const posts = await response.json();
97 await upsertJsonPosts(posts);
98 retrievedPosts += posts.data.length;
99 console.log("got", retrievedPosts, "out of", posts.meta.pagination.total);
100 apiUrl = posts.links?.next;
101 if (!apiUrl) {
102 break;
103 }
32 document.getElementById('faculty-count')!.textContent = window.__INITIAL_DATA__.faculties.length.toString();
33 } else {
34 // Fallback: fetch data from API
35 fetchFaculties();
36 }
40 try {
41 setIsLoading(true);
42 const response = await fetch('/api/faculties');
43 const data = await response.json();
44 setFaculties(data);
61
62 try {
63 const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
64 const data = await response.json();
65 setSearchResults(data.results);
213
214 try {
215 const response = await fetch('/api/directions', {
216 method: 'POST',
217 headers: { 'Content-Type': 'application/json' },
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: [
21 const loadExercises = async () => {
22 try {
23 const response = await fetch('/api/workouts/exercises');
24 const result = await response.json();
25
34 const loadInitialMessages = async () => {
35 try {
36 const response = await fetch('/api/chat/messages');
37 const result = await response.json();
38
49 const connectToStream = () => {
50 try {
51 const eventSource = new EventSource('/api/chat/stream');
52 eventSourceRef.current = eventSource;
53
93
94 try {
95 const response = await fetch('/api/chat/messages', {
96 method: 'POST',
97 headers: { 'Content-Type': 'application/json' },
39 const handleLogout = async () => {
40 try {
41 await fetch('/api/auth/logout', {
42 method: 'POST',
43 credentials: 'include'
174 >
175 <img
176 src={`https://ui-avatars.com/api/?name=${encodeURIComponent(user.firstName + ' ' + user.lastName)}&background=6366f1&color=fff&size=32`}
177 alt={user.firstName}
178 className="h-8 w-8 rounded-full"