3
4const replicate = new Replicate({
5 auth: Deno.env.get("REPLICATE_API_KEY"),
6});
7
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>PrimeCoder</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 PrimeDark69 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
11 },
12 {
13 "prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
14 "title": "Weather App",
15 "code": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>NYC Weather</title>\n <link href=\"https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css\" rel=\"stylesheet\">\n <style>\n .weather-icon {\n font-size: 48px;\n margin-bottom: 16px;\n }\n </style>\n</head>\n<body class=\"h-screen bg-blue-100 flex justify-center items-center p-4\">\n <div class=\"bg-white p-8 rounded-md shadow-md w-full max-w-sm md:p-12 lg:p-16 xl:p-20\">\n <h1 class=\"text-2xl font-bold mb-4 text-center text-blue-500\">NYC Weather</h1>\n <div id=\"weather\" class=\"mb-4 p-4 text-center\">\n <div id=\"temperature\" class=\"text-4xl font-bold mb-4\"></div>\n <div id=\"condition\" class=\"text-xl font-medium mb-4\"></div>\n <div id=\"humidity\" class=\"text-lg font-light mb-2\">Humidity: <span id=\"humidity-value\"></span>%</div>\n <div id=\"wind\" class=\"text-lg font-light mb-2\">Wind: <span id=\"wind-value\"></span> mph</div>\n <i id=\"weather-icon\" class=\"weather-icon text-blue-500\"></i>\n </div>\n </div>\n <p class=\"fixed bottom-0 left-0 right-0 text-center p-4 text-gray-600 md:p-6 lg:p-8 xl:p-10\">\n Built on <a class=\"text-blue-600\" href=\"https://cerebrascoder.com\">Cerebras Coder</a>\n </p>\n\n <script>\n // Sample weather data\n const weatherData = {\n temperature: 75,\n condition: 'Sunny',\n humidity: 60,\n wind: 10,\n icon: 'sun'\n };\n\n document.getElementById('temperature').innerText = `${weatherData.temperature}°F`;\n document.getElementById('condition').innerText = weatherData.condition;\n document.getElementById('humidity-value').innerText = weatherData.humidity;\n document.getElementById('wind-value').innerText = weatherData.wind;\n\n // Map weather icon\n const weatherIcons = {\n 'sun': '☀',\n 'cloud': '☀',\n 'rain': '☃',\n 'snow': '☄'\n };\n\n document.getElementById('weather-icon').innerHTML = weatherIcons[weatherData.icon] || '';\n </script>\n</body>\n</html>",
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`
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: [
1## 🤖 A gateway to Hugging Face's Inference API
2
3You can perform various NLP tasks using different [models](https://huggingface.co/models). The gateway supports multiple tasks, including feature extraction, text classification, token classification, question answering, summarization, translation, text generation, and sentence similarity.
21```bash
22# Example Default Model Request
23 curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World", "How are you?", "Nice to meet you."]}}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction"
24```
25
28**Feature Extraction**
29```bash
30curl -X POST -H "Content-Type: application/json" -d '{"inputs": ["Hello World", "Goodbye World"]}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction&model=BAAI/bge-base-en-v1.5"
31```
32**Feature Extraction**
33```bash
34curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World", "How are you?", "Nice to meet you."]}}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction&model=sentence-transformers/all-MiniLM-L6-v2"
35```
36**Text Classification**
37```bash
38curl -X POST -H "Content-Type: application/json" -d '{"inputs": "I love programming!"}' "https://iamseeley-hfapigateway.web.val.run/?task=text-classification&model=j-hartmann/emotion-english-distilroberta-base"
39```
40**Token Classification**
41```bash
42curl -X POST -H "Content-Type: application/json" -d '{"inputs": "My name is John and I live in New York."}' "https://iamseeley-hfApiGateway.web.val.run/?task=token-classification&model=dbmdz/bert-large-cased-finetuned-conll03-english"
43```
44**Question Answering**
45```bash
46curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"question": "What is the capital of France?", "context": "The capital of France is Paris, a major European city and a global center for art, fashion, gastronomy, and culture."}}' "https://iamseeley-hfapigateway.web.val.run/?task=question-answering&model=deepset/roberta-base-squad2"
47```
48**Summarization**
49```bash
50curl -X POST -H "Content-Type: application/json" -d '{"inputs": "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."}' "https://iamseeley-hfapigateway.web.val.run/?task=summarization&model=sshleifer/distilbart-cnn-12-6"
51```
52**Translation**
53```bash
54curl -X POST -H "Content-Type: application/json" -d '{"inputs": "Hello, how are you?"}' "https://iamseeley-hfapigateway.web.val.run/?task=translation&model=google-t5/t5-small"
55```
56**Text Generation**
57```bash
58curl -X POST -H "Content-Type: application/json" -d '{"inputs": "Once upon a time"}' "https://iamseeley-hfapigateway.web.val.run/?task=text-generation&model=gpt2"
59```
60**Sentence Similarity**
61```bash
62curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World"]}}' "https://iamseeley-hfapigateway.web.val.run/?task=sentence-similarity&model=sentence-transformers/all-MiniLM-L6-v2"
63```
64
1const HUGGING_FACE_API_URL = "https://api-inference.huggingface.co/models";
2const HUGGING_FACE_API_KEY = Deno.env.get("HUGGING_FACE_API_KEY");
3
4const defaultModels = {
60
61 async featureExtraction(input, options) {
62 return this.callHuggingFaceAPI(input, options);
63 }
64
65 async textClassification(input, options) {
66 return this.callHuggingFaceAPI(input, options);
67 }
68
69 async tokenClassification(input, options) {
70 return this.callHuggingFaceAPI(input, options);
71 }
72
73 async questionAnswering(input, options) {
74 return this.callHuggingFaceAPI(input, options);
75 }
76
77 async summarization(input, options) {
78 return this.callHuggingFaceAPI(input, options);
79 }
80
81 async translation(input, options) {
82 return this.callHuggingFaceAPI(input, options);
83 }
84
85 async textGeneration(input, options) {
86 return this.callHuggingFaceAPI(input, options);
87 }
88
89 async sentenceSimilarity(input, options) {
90 return this.callHuggingFaceAPI(input, options);
91 }
92
93 async callHuggingFaceAPI(payload, options) {
94 try {
95 const response = await fetch(`${HUGGING_FACE_API_URL}/${this.model}`, {
96 method: "POST",
97 headers: {
98 "Authorization": `Bearer ${HUGGING_FACE_API_KEY}`,
99 "Content-Type": "application/json"
100 },
104 if (!response.ok) {
105 const error = await response.json();
106 console.error("Hugging Face API Error:", error);
107 return { error: `API request failed: ${error.error}` };
108 }
109
111 return data;
112 } catch (error) {
113 console.error("Error calling Hugging Face API:", error);
114 return { error: "Error calling Hugging Face API" };
115 }
116 }
3// Get environment variables
4const url = Deno.env.get("INFLUXDB_URL");
5const token = Deno.env.get("INFLUXDB_API_TOKEN_2");
6const org = Deno.env.get("INFLUXDB_ORG");
7const bucket = Deno.env.get("INFLUXDB_BUCKET");
8const apiKey = Deno.env.get("WUNDERGROUND_API_KEY");
9const stationId = Deno.env.get("WUNDERGROUND_STATION_ID");
10
11// Interface for the history API response with proper null handling
12interface WeatherHistoryData {
13 observations: Array<{
55
56/**
57 * Gets today's date in YYYYMMDD format for the API
58 */
59function getTodayDateFormatted(): string {
66
67/**
68 * Fetches today's weather history data from the Weather Underground API
69 */
70async function fetchTodayWeatherData(): Promise<WeatherHistoryData> {
71 const todayDate = getTodayDateFormatted();
72 const apiUrl =
73 `https://api.weather.com/v2/pws/history/all?stationId=${stationId}&format=json&units=m&numericPrecision=decimal&date=${todayDate}&apiKey=${apiKey}`;
74
75 console.log(`Fetching weather data for ${todayDate}`);
76
77 const response = await fetch(apiUrl);
78 if (!response.ok) {
79 const errorText = await response.text();
80 console.error(`API error response: ${errorText}`);
81 throw new Error(`HTTP error! status: ${response.status}`);
82 }
185
186 const influxDB = new InfluxDB({ url, token });
187 const writeApi = influxDB.getWriteApi(org, bucket);
188 writeApi.useDefaultTags({ region: "west" });
189
190 // Write points using the same approach as working script
191 for (const point of points) {
192 writeApi.writePoint(point);
193 }
194
195 try {
196 await writeApi.close();
197 console.log(`Successfully wrote ${points.length} observations to InfluxDB`);
198 } catch (error) {
212 const requiredEnvVars = [
213 "INFLUXDB_URL",
214 "INFLUXDB_API_TOKEN_2",
215 "INFLUXDB_ORG",
216 "INFLUXDB_BUCKET",
217 "WUNDERGROUND_API_KEY",
218 "WUNDERGROUND_STATION_ID",
219 ];
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let getDadJoke = () => fetchJSON("https://official-joke-api.appspot.com/random_joke");