cerebras_coderindex.html3 matches
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
10href="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"
11rel="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
cerebras_coderindex1 match
211} catch (error) {
212Toastify({
213text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
214position: "center",
215duration: 3000,
cerebras_codergenerate-code1 match
16};
17} else {
18const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19const completion = await client.chat.completions.create({
20messages: [
31try {
32const response = await fetch(
33`https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,weathercode&timezone=auto`
34);
35const data = await response.json();
OpenTelemetryCollectorindex.ts7 matches
6import { createFiberplane } from "./deps/fiberplane.ts";
7import { Hono, HTTPException } from "./deps/hono.ts";
8import { getOpenAPISpec } from "./openapi.ts";
910// Migrate database on startup to make sure the proper table exists to store spans
2526/**
27* Mount the Fiberplane api playground
28* Visit /fp to view the UI
29*/
31"/fp/*",
32createFiberplane({
33openapi: { content: JSON.stringify(getOpenAPISpec()) },
34}),
35);
49* Export a function that wraps the incoming request,
50* then injects the Deno env vars into the Hono app befoe
51* executing the api entrypoint (`app.fetch`)
52*/
53export default async function(req: Request): Promise<Response> {
54const env = Deno.env.toObject();
55// NOTE - Adding the entire env object will also expose the following values to your api handlers:
56//
57// * `valtown`
58// * `VAL_TOWN_API_KEY`
59// * `VALTOWN_API_URL`
60//
61// If you don't want those values, remove them from the env object
32<h1>Fiberplane OpenTelemetry Trace Collector on ValTown</h1>
33<p>
34Visit <a href="/fp">/fp</a> to view the Fiberplane API explorer.
35</p>
36</body>
OpenTelemetryCollectoropenapi.ts3 matches
1/**
2* A manually generated OpenAPI spec, to be able to use the Fiberplane library
3* with a better experience
4*/
5export function getOpenAPISpec() {
6return {
7openapi: "3.0.0",
8info: {
9title: "Fiberplane OpenTelemetry Collector",
blob_adminmain.tsx25 matches
73const menuRef = useRef(null);
74const isPublic = blob.key.startsWith("__public/");
75const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
7677useEffect(() => {
237setLoading(true);
238try {
239const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240const data = await response.json();
241setBlobs(data);
264setBlobContentLoading(true);
265try {
266const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267const content = await response.text();
268setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
278const handleSave = async () => {
279try {
280await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281method: "PUT",
282body: editContent,
290const handleDelete = async (key) => {
291try {
292await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293setBlobs(blobs.filter(b => b.key !== key));
294if (selectedBlob && selectedBlob.key === key) {
307const key = `${searchPrefix}${file.name}`;
308formData.append("key", encodeKey(key));
309await fetch("/api/blob", { method: "POST", body: formData });
310const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311setBlobs([newBlob, ...blobs]);
329try {
330const fullKey = `${searchPrefix}${key}`;
331await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332method: "PUT",
333body: "",
344const handleDownload = async (key) => {
345try {
346const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347const blob = await response.blob();
348const url = window.URL.createObjectURL(blob);
363if (newKey && newKey !== oldKey) {
364try {
365const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366const content = await response.blob();
367await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368method: "PUT",
369body: content,
370});
371await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373if (selectedBlob && selectedBlob.key === oldKey) {
383const newKey = `__public/${key}`;
384try {
385const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386const content = await response.blob();
387await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388method: "PUT",
389body: content,
390});
391await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393if (selectedBlob && selectedBlob.key === key) {
402const newKey = key.slice(9); // Remove "__public/" prefix
403try {
404const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405const content = await response.blob();
406await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407method: "PUT",
408body: content,
409});
410await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412if (selectedBlob && selectedBlob.key === key) {
557onClick={() =>
558copyToClipboard(
559`${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
560)}
561className="text-blue-400 hover:text-blue-300 text-sm"
580>
581<img
582src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
583alt="Blob content"
584className="max-w-full h-auto"
660661// Public route without authentication
662app.get("/api/public/:id", async (c) => {
663const key = `__public/${c.req.param("id")}`;
664const { blob } = await import("https://esm.town/v/std/blob");
778};
779780app.get("/api/blobs", checkAuth, async (c) => {
781const prefix = c.req.query("prefix") || "";
782const limit = parseInt(c.req.query("limit") || "20", 10);
787});
788789app.get("/api/blob", checkAuth, async (c) => {
790const key = c.req.query("key");
791if (!key) return c.text("Missing key parameter", 400);
795});
796797app.put("/api/blob", checkAuth, async (c) => {
798const key = c.req.query("key");
799if (!key) return c.text("Missing key parameter", 400);
804});
805806app.delete("/api/blob", checkAuth, async (c) => {
807const key = c.req.query("key");
808if (!key) return c.text("Missing key parameter", 400);
812});
813814app.post("/api/blob", checkAuth, async (c) => {
815const { file, key } = await c.req.parseBody();
816if (!file || !key) return c.text("Missing file or key", 400);
redditAlertREADME.md10 matches
72. Send notifications to your preferred platform (Discord, Slack, email, etc.)
89Reddit does not have an API that allows users to scrape data, so we are doing this with the Google Search API, [Serp](https://serpapi.com/).
1011---
2930---
31### 3. Get a SerpApi Key
32This template requires a [SerpApi](https://serpapi.com/) key to search Reddit posts via Google search results.
33341. **Get a SerpApi key**:
35- Sign up at [SerpApi](https://serpapi.com/) to create an account.
36- Generate an API key from your account dashboard.
37382. **Add the SerpApi key to your environment variables**:
39- Go to your [Val Town environment variables](https://www.val.town/settings/environment-variables).
40- Add a new key:
41- Key: `SERP_API_KEY`
42- Value: Your SERP API key.
4344Without this key, the val will not function correctly.
7576### NOTE: Usage Limits
77- **SerpApi:** Free SerpApi accounts have monthly call limits.
redditAlertmain.tsx9 matches
1import { searchWithSerpApi } from "https://esm.town/v/charmaine/searchWithSerpApi";
2import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
34// Customize your search parameters
5const KEYWORDS = "\"node\" OR \"node.js\"";
6const DISCORD_API_KEY = Deno.env.get("mentionsDiscord");
7const SERP_API_KEY = Deno.env.get("SERP_API_KEY");
89// Set isProd = false for testing and = true for production
1314export async function redditAlert({ lastRunAt }: Interval) {
15if (!SERP_API_KEY || !DISCORD_API_KEY) {
16console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
17return;
18}
1920// Determine the time frame for the search
21// Details on as_qdr: https://serpapi.com/advanced-google-query-parameters#api-parameters-advanced-search-query-parameters-as-qdr
22const timeFrame = isProd
23? lastRunAt
2728try {
29const response = await searchWithSerpApi({
30query: KEYWORDS,
31site: "reddit.com",
32apiKey: SERP_API_KEY,
33as_qdr: timeFrame,
34});
62if (isProd) {
63await discordWebhook({
64url: DISCORD_API_KEY,
65content,
66});