sqliteExplorerAppmain.tsx2 matches
27<head>
28<title>SQLite Explorer</title>
29<link rel="preconnect" href="https://fonts.googleapis.com" />
3031<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32<link
33href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34rel="stylesheet"
35/>
153setIsLoading(true);
154try {
155const response = await fetch(`/api/${syncId}/last-watered`);
156if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
157const data = await response.json();
240if (!syncId) return;
241try {
242const response = await fetch(`/api/${syncId}/waterers`);
243if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
244const data = await response.json();
253if (!syncId) return;
254try {
255const response = await fetch(`/api/${syncId}/history`);
256if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
257const data = await response.json();
312313try {
314await fetch(`/api/${syncId}/water`, {
315method: "POST",
316headers: { "Content-Type": "application/json" },
323if (newWatererName.trim() && !selectedWaterer) {
324// Add the new waterer to the list
325await fetch(`/api/${syncId}/waterers`, {
326method: "POST",
327headers: { "Content-Type": "application/json" },
481try {
482const [waterersResponse, historyResponse] = await Promise.all([
483fetch(`/api/${syncId}/waterers`),
484fetch(`/api/${syncId}/history`),
485]);
486if (!waterersResponse.ok) throw new Error(`Waterers fetch error! status: ${waterersResponse.status}`);
510setIsProcessing(true);
511try {
512await fetch(`/api/${syncId}/history/${entryId}`, { method: "DELETE" });
513fetchDataInternal(); // Refresh
514} catch (error) {
678setIsProcessing(true);
679try {
680const waterersResponse = await fetch(`/api/${syncId}/waterers`);
681if (!waterersResponse.ok) throw new Error(`Waterers fetch error! status: ${waterersResponse.status}`);
682699setIsProcessing(true);
700try {
701const response = await fetch(`/api/${syncId}/waterers`, {
702method: "POST",
703headers: { "Content-Type": "application/json" },
723setIsProcessing(true);
724try {
725await fetch(`/api/${syncId}/waterers/${watererId}`, {
726method: "PUT",
727headers: { "Content-Type": "application/json" },
742setIsProcessing(true);
743try {
744await fetch(`/api/${syncId}/waterers/${watererId}`, { method: "DELETE" });
745fetchWaterersInternal(); // Refresh
746} catch (error) {
10651066const url = new URL(request.url);
1067// Path parts: e.g., ["api", "your-sync-id", "waterers", "waterer-item-id"]
1068const pathParts = url.pathname.split("/").filter(p => p.trim() !== "");
10691070if (pathParts[0] === "api" && pathParts.length >= 2) {
1071const syncId = pathParts[1];
1072const apiResource = pathParts.length > 2 ? pathParts[2] : null; // e.g., "waterers", "history", "water", "last-watered"
1073const itemId = pathParts.length > 3 ? pathParts[3] : null; // e.g., a specific watererId or historyEntryId
10741111}
11121113// --- API Route Handlers ---
11141115// Waterers: /api/:syncId/waterers
1116if (apiResource === "waterers") {
1117let instanceData = await getInstanceData(syncId);
1118if (request.method === "GET" && !itemId) {
1167}
1168}
1169// History: /api/:syncId/history
1170else if (apiResource === "history") {
1171let instanceData = await getInstanceData(syncId);
1172if (request.method === "GET" && !itemId) {
1192}
1193}
1194// Water Action: /api/:syncId/water
1195else if (apiResource === "water" && request.method === "POST") {
1196const { waterer, notes } = await request.json(); // Added notes parameter
1197if (!waterer || typeof waterer !== "string") {
1217});
1218}
1219// Last Watered: /api/:syncId/last-watered
1220else if (apiResource === "last-watered" && request.method === "GET") {
1221const instanceData = await getInstanceData(syncId);
1222return new Response(JSON.stringify({ lastWatered: instanceData.last_watered_timestamp }), {
1225}
1226// Optional: Endpoint to generate a new sync ID
1227// else if (pathParts[0] === 'api' && pathParts[1] === 'generate-sync-id' && request.method === 'GET') {
1228// const newSyncId = `sync_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
1229// return new Response(JSON.stringify({ syncId: newSyncId }), { headers: { 'Content-Type': 'application/json' } });
1230// }
12311232return new Response(JSON.stringify({ error: "API endpoint not found or method not allowed." }), {
1233status: 404,
1234headers: { "Content-Type": "application/json" },
1CEREBRAS_API_KEYcsk-phjx2jjh89eptw4854x28wjfemdkedr38f5nw4n66pw5ffdd
12},
13{
14"prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15"title": "Weather App",
16"code":
cerebras_coder-BELLOYARONREADME.md2 matches
891. 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) {
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_coder-BELLOYARONindex.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
16};
17} else {
18const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19const completion = await client.chat.completions.create({
20messages: [
acme-customsindex.tsx56 matches
1import "jsr:@std/dotenv/load"; // needed for deno run; not req for smallweb or valtown
2import { Hono } from "https://deno.land/x/hono@v3.11.7/mod.ts";
3// No streamSSE needed for client-side only VAPI handling
4// import { streamSSE } from "https://deno.land/x/hono@v3.11.7/helper/streaming/index.ts";
5import Groq from "npm:groq-sdk";
7const app = new Hono();
89const groq = new Groq({ apiKey: Deno.env.get("GROQ_API_KEY") });
1011// Add a simple in-memory rate limiter (per IP)
12const extractDataRateLimit = new Map();
1314// Define the VAPI browser code as a string that will be injected
15const vapiCode = `
16// Create a simple EventEmitter implementation
17class EventEmitter {
48}
4950// VapiEventEmitter extends our custom EventEmitter
51class VapiEventEmitter extends EventEmitter {
52constructor() {
53super();
55}
5657// Main Vapi class
58class Vapi extends VapiEventEmitter {
59constructor(apiKey, baseUrl = "https://api.vapi.ai", callConfig = {}, callObject = {}) {
60super();
61this.apiKey = apiKey;
62this.baseUrl = baseUrl;
63this.started = false;
71method: 'POST',
72headers: {
73'Authorization': \`Bearer \${this.apiKey}\`,
74'Content-Type': 'application/json',
75},
109110try {
111// 1. Get the room URL from VAPI API
112const callData = await this.createWebCall({
113assistantId: assistantId,
115});
116
117console.log('VAPI_DEBUG: Call data:', callData);
118console.log('VAPI_DEBUG: webCallUrl:', callData.webCallUrl);
119
120if (this.call) this.cleanup();
125
126// Create a function that will be run in the global context
127const joinVapiRoom = (url) => {
128return new Promise((resolve, reject) => {
129try {
166// Run the isolated function and get back the call object
167try {
168this.call = await joinVapiRoom(callData.webCallUrl);
169
170// If we get here, the join was successful
176return callData;
177} catch (error) {
178console.error('VAPI_DEBUG: Isolated join failed', error);
179this.emit('error', error);
180this.cleanup();
216if (!event || !event.participant) return;
217
218if (!event.participant.local && event.participant.user_name === 'Vapi Speaker') {
219if (event.track.kind === 'video') {
220this.emit('video', event.track);
286}
287288// Make Vapi available globally
289window.Vapi = Vapi;
290`;
291302<meta property="twitter:image" content="https://f2.phage.directory/capsid/64WqJMHP/acme-customs.png">
303<!-- Fonts -->
304<link rel="preconnect" href="https://fonts.googleapis.com">
305<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
306<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600&display=swap" rel="stylesheet">
307<!-- Alpine.js -->
308<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
309<!-- VAPI dependencies -->
310<script src="https://cdn.jsdelivr.net/npm/@daily-co/daily-js@0.79.0/dist/daily.min.js"></script>
311<script>${vapiCode}</script>
312
313<style>
905</style>
906</head>
907<body x-data="vapiCustomsDemo">
908<div class="main-container">
909<div class="cyber-marquee-top-wrapper">
1004<span class="micro-header">ACME CYBERNETICS // PROTOCOL OMEGA // SECTOR 7G</span>
1005<div class="footer-text">ACME Customs © 2024 // Advanced Cybernetic Modification Engineering</div>
1006<div class="footer-text">Powered by <a href="https://groq.com" target="_blank">Groq</a> and <a href="https://vapi.ai" target="_blank">Vapi</a>. <a href="https://www.val.town/x/yawnxyz/acme-customs" target="_blank">Source code</a></div>
1007</footer>
10081010// Define the Alpine.js component
1011document.addEventListener('alpine:init', () => {
1012Alpine.data('vapiCustomsDemo', () => ({
1013vapi: null,
1014callStatus: 'idle', // idle, connecting, started, ended
1015assistantIsSpeaking: false,
1018transcriptText: 'Awaiting connection... Stand by for vehicle consultation.',
1019extractedData: {}, // generic extracted data object
1020vapiPublicKey: '872dea2d-4afc-4ab4-b871-5797fdb1397e',
1021assistantId: '458bb70e-cc52-4122-9f3d-b260a6220830',
10221023init() {
1024if (typeof window.Vapi === 'undefined') {
1025console.error('VAPI SDK not loaded. Ensure VAPI script is included and loaded.');
1026alert('Critical system error: VAPI SDK failed to initialize.');
1027return;
1028}
1029
1030try {
1031this.vapi = new window.Vapi(this.vapiPublicKey);
1032this.setupVapiEventHandlers();
1033console.log('VAPI System Initialized. Standby.');
1034this.extractedData = {};
1035} catch (error) {
1036console.error('Error initializing Vapi:', error);
1037alert('VAPI initialization failed: ' + error.message);
1038}
1039},
10401041setupVapiEventHandlers() {
1042if (!this.vapi) return;
10431044this.vapi.on('call-start', () => {
1045console.log('Call initiated.');
1046this.callStatus = 'started';
1049});
10501051this.vapi.on('call-end', () => {
1052console.log('Call terminated.');
1053this.callStatus = 'ended';
1056});
10571058this.vapi.on('speech-start', () => { // Assistant speech
1059// console.log('Assistant speech started');
1060this.assistantIsSpeaking = true;
1061});
10621063this.vapi.on('speech-end', () => { // Assistant speech
1064// console.log('Assistant speech ended');
1065this.assistantIsSpeaking = false;
1066});
1067
1068this.vapi.on('user-speech-start', () => {
1069this.userIsSpeaking = true;
1070});
10711072this.vapi.on('user-speech-end', () => {
1073this.userIsSpeaking = false;
1074});
107510761077this.vapi.on('message', (msg) => {
1078// console.log('Message received:', msg);
1079if (msg.type === 'transcript') {
1103});
11041105this.vapi.on('error', (error) => {
1106console.error('VAPI Error:', error);
1107this.callStatus = 'idle'; // Reset status on error
1108alert('An error occurred during the call: ' + error.message);
11441145async startCall() {
1146if (!this.vapi) {
1147alert('VAPI system not ready. Please wait or refresh.');
1148return;
1149}
1154try {
1155// console.log('Attempting to start call with assistant ID:', this.assistantId);
1156await this.vapi.start(this.assistantId);
1157// call-start event will set status to 'started'
1158} catch (error) {
11641165async stopCall() {
1166if (!this.vapi || this.callStatus === 'ended' || this.callStatus === 'idle') return;
1167try {
1168// console.log('Attempting to stop call.');
1169await this.vapi.stop();
1170// call-end event will set status to 'ended' and then we can set to idle
1171// Forcing idle here to make button state reflect stopping action immediately
1209});
12101211// Add a route to serve the vapi-browser.js file
1212app.get('/vapi-browser.js', async (c) => {
1213return c.text(await Deno.readTextFile('./vapi-browser.js'), {
1214headers: {
1215'Content-Type': 'application/javascript',
12},
13{
14"prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15"title": "Weather App",
16"code":