stevensDemoApp.tsx8 matches
10import { NotebookView } from "./NotebookView.tsx";
1112const API_BASE = "/api/memories";
13const MEMORIES_PER_PAGE = 20; // Increased from 7 to 20 memories per page
149091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
606<div className="font-pixel text-[#f8f1e0]">
607<style jsx>{`
608@import url("https://fonts.googleapis.com/css2?family=Pixelify+Sans&display=swap");
609610@tailwind base;
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans
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/>
live_pricesmain.tsx2 matches
3// Helper function to fetch exchange rates
4async function fetchExchangeRates() {
5const response = await fetch('https://open.er-api.com/v6/latest/USD');
6const data = await response.json();
7return data.rates;
10// Helper function to fetch global news
11async function fetchGlobalNews() {
12const response = await fetch('https://newsapi.org/v2/top-headlines?country=us&apiKey=YOUR_NEWS_API_KEY');
13const data = await response.json();
14return data.articles.slice(0, 5);
groqAudioChatgroqAudioChat48 matches
6import "jsr:@std/dotenv/load"; // needed for deno run; not req for smallweb or valtown
78// Function to handle audio transcription using Groq's Whisper API
9export const audioTranscriptionHandler = async (c) => {
10console.log("๐ค Audio transcription request received");
20}
2122// Get API key from environment variable
23const apiKey = Deno.env.get("GROQ_API_KEY");
24if (!apiKey) {
25console.error("โ Transcription error: Missing API key");
26return c.json({ error: "API key not configured" }, 500);
27}
283839// If the file doesn't have a proper name or type, add one
40// This ensures the file has the right extension for the API
41if (!audioFile.name || !audioFile.type.startsWith("audio/")) {
42const newFile = new File(
50}
5152// Prepare the form data for Groq API
53const groqFormData = new FormData();
5465groqFormData.append("timestamp_granularities[]", "word");
6667// Call Groq API
68console.log("๐ค Sending request to Groq Whisper API");
69const start = Date.now();
70const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
71method: "POST",
72headers: {
73"Authorization": `Bearer ${apiKey}`,
74},
75body: groqFormData,
76});
77const elapsed = Date.now() - start;
78console.log(`๐ค Groq Whisper API response received in ${elapsed}ms, status: ${response.status}`);
7980// Get response content type
99errorMessage = `Server error: ${response.status} ${response.statusText}`;
100// Log the full response for debugging
101console.error("โ Transcription API error response:", {
102status: response.status,
103statusText: response.statusText,
108}
109} catch (parseError) {
110console.error("โ Error parsing Groq API response:", parseError);
111errorMessage = "Failed to parse error response from server";
112}
113114return c.json({
115error: `Groq API error: ${errorMessage}`,
116status: response.status,
117}, response.status);
150console.log(`๐ต Last user message: "${messages.find(m => m.role === "user")?.content?.substring(0, 50)}..."`);
151152const GROQ_API_KEY = Deno.env.get("GROQ_API_KEY");
153if (!GROQ_API_KEY) {
154console.error("โ Missing GROQ_API_KEY environment variable");
155return c.json({ error: "GROQ_API_KEY environment variable is not set" }, 500);
156}
157158console.log("๐ต Sending request to Groq API");
159const start = Date.now();
160const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
161method: "POST",
162headers: {
163"Content-Type": "application/json",
164"Authorization": `Bearer ${GROQ_API_KEY}`,
165},
166body: JSON.stringify({
171});
172const elapsed = Date.now() - start;
173console.log(`๐ต Groq API response received in ${elapsed}ms, status: ${response.status}`);
174175if (!response.ok) {
176const errorData = await response.json();
177console.error("โ Chat API error:", errorData);
178return c.json({ error: "Failed to get chat completion", details: errorData }, response.status);
179}
206}
207208// Get API key from environment variable
209const apiKey = Deno.env.get("GROQ_API_KEY");
210if (!apiKey) {
211console.error("โ TTS error: Missing API key");
212return c.json({ error: "API key not configured" }, 500);
213}
214215// Call Groq Speech API
216console.log("๐ Sending request to Groq Speech API");
217const start = Date.now();
218const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
219method: "POST",
220headers: {
221"Content-Type": "application/json",
222"Authorization": `Bearer ${apiKey}`,
223},
224body: JSON.stringify({
230});
231const elapsed = Date.now() - start;
232console.log(`๐ Groq Speech API response received in ${elapsed}ms, status: ${response.status}`);
233234if (!response.ok) {
237const errorData = await response.json();
238errorMessage = errorData.error?.message || JSON.stringify(errorData);
239console.error("โ TTS API error:", errorData);
240} catch (e) {
241// If response is not JSON
242errorMessage = `Server error: ${response.status} ${response.statusText}`;
243console.error("โ TTS API non-JSON error:", errorMessage);
244}
245603// Now immediately send this message to get AI response
604try {
605// Prepare messages for the API
606const apiMessages = this.messages.map(({ role, content }) => ({ role, content }));
607
608// Ensure first message is always the correct system message for current mode
609if (apiMessages.length > 0 && apiMessages[0].role === 'system') {
610const systemMessage = this.chatMode === 'concise'
611? 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Keep your responses short, concise and conversational. Aim for 1-3 sentences when possible.'
612: 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Respond conversationally and accurately to the user.';
613
614apiMessages[0].content = systemMessage;
615}
616
618method: 'POST',
619headers: { 'Content-Type': 'application/json' },
620body: JSON.stringify({ messages: apiMessages })
621});
622
681this.statusMessage = 'Thinking...';
682
683// Prepare messages for the API (excluding UI-only properties)
684const apiMessages = this.messages.map(({ role, content }) => ({ role, content }));
685
686// Ensure first message is always the correct system message for current mode
687if (apiMessages.length > 0 && apiMessages[0].role === 'system') {
688const systemMessage = this.chatMode === 'concise'
689? 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Keep your responses short, concise and conversational. Aim for 1-3 sentences when possible.'
690: 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Respond conversationally and accurately to the user.';
691
692apiMessages[0].content = systemMessage;
693}
694
697method: 'POST',
698headers: { 'Content-Type': 'application/json' },
699body: JSON.stringify({ messages: apiMessages })
700});
701
969970<p class="text-center text-sm text-gray-600 mt-4">
971Powered by Llama-3.3-70b-versatile through Groq API. Audio transcription and speech synthesis provided by Groq. Text-to-speech provided through PlayHT. <a class="underline" href="https://console.groq.com/docs/speech-to-text" target="_blank" rel="noopener noreferrer">Documentation here</a>. <a class="underline" href="https://www.val.town/v/yawnxyz/groqAudioChat" target="_blank" rel="noopener noreferrer">Code here</a>
972</p>
973<div class="text-center text-sm text-gray-600 mt-4 w-full mx-auto">
groqAudioChattts.ts12 matches
16}
1718// Get API key from environment variable
19const apiKey = Deno.env.get("GROQ_API_KEY");
20if (!apiKey) {
21console.error("โ TTS error: Missing API key");
22return c.json({ error: "API key not configured" }, 500);
23}
2425// Call Groq Speech API
26console.log("๐ Sending request to Groq Speech API");
27const start = Date.now();
28const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
29method: "POST",
30headers: {
31"Content-Type": "application/json",
32"Authorization": `Bearer ${apiKey}`
33},
34body: JSON.stringify({
40});
41const elapsed = Date.now() - start;
42console.log(`๐ Groq Speech API response received in ${elapsed}ms, status: ${response.status}`);
4344if (!response.ok) {
47const errorData = await response.json();
48errorMessage = errorData.error?.message || JSON.stringify(errorData);
49console.error("โ TTS API error:", errorData);
50} catch (e) {
51// If response is not JSON
52errorMessage = `Server error: ${response.status} ${response.statusText}`;
53console.error("โ TTS API non-JSON error:", errorMessage);
54}
55
groqAudioChatREADME.md8 matches
1# Groq Audio Chat
23A web-based chat application powered by Groq's LLM API with audio transcription and text-to-speech capabilities.
45## Features
67- Chat with the Llama-3.3-70b-versatile model through Groq API
8- Multiple ways to record audio input:
9- Hold spacebar to record audio (keyboard shortcut)
22/
23โโโ index.ts # Main entry point
24โโโ handlers/ # API endpoint handlers
25โ โโโ index.ts # Exports all handlers
26โ โโโ audio.ts # Audio transcription handler
35```
3637## API Endpoints
3839- `GET /` - Main web interface
44## Voice Options
4546The application features 19 different PlayHT voices through Groq's API:
47- Arista-PlayAI
48- Atlas-PlayAI
67## Environment Variables
6869- `GROQ_API_KEY` - Your Groq API key
7071## Technologies Used
74- Alpine.js - Front-end JavaScript framework
75- Tailwind CSS - Utility-first CSS framework
76- Groq API - LLM provider with Llama-3.3-70b-versatile model
77- Groq Whisper API - Audio transcription
78- PlayHT (via Groq) - Text-to-speech synthesis
79
groqAudioChathtml.ts1 match
198<footer class="text-center text-gray-500 text-sm mt-8">
199<p class="text-center text-sm text-gray-600 mt-4">
200Powered by Llama-3.3-70b-versatile through Groq API. Audio transcription and speech synthesis provided by Groq. Text-to-speech provided through PlayHT.
201</p>
202<p class="text-center text-sm text-gray-600 mt-2">
groqAudioChatchat.ts9 matches
12console.log(`๐ต Last user message: "${messages.find(m => m.role === 'user')?.content?.substring(0, 50)}..."`);
13
14const GROQ_API_KEY = Deno.env.get("GROQ_API_KEY");
15if (!GROQ_API_KEY) {
16console.error("โ Missing GROQ_API_KEY environment variable");
17return c.json({ error: "GROQ_API_KEY environment variable is not set" }, 500);
18}
1920console.log("๐ต Sending request to Groq API");
21const start = Date.now();
22const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
23method: "POST",
24headers: {
25"Content-Type": "application/json",
26"Authorization": `Bearer ${GROQ_API_KEY}`
27},
28body: JSON.stringify({
33});
34const elapsed = Date.now() - start;
35console.log(`๐ต Groq API response received in ${elapsed}ms, status: ${response.status}`);
3637if (!response.ok) {
38const errorData = await response.json();
39console.error("โ Chat API error:", errorData);
40return c.json({ error: "Failed to get chat completion", details: errorData }, response.status);
41}
groqAudioChataudio.ts16 matches
1import { Context } from "https://deno.land/x/hono@v3.11.7/mod.ts";
23// Function to handle audio transcription using Groq's Whisper API
4export const audioTranscriptionHandler = async (c: Context) => {
5console.log("๐ค Audio transcription request received");
15}
1617// Get API key from environment variable
18const apiKey = Deno.env.get("GROQ_API_KEY");
19if (!apiKey) {
20console.error("โ Transcription error: Missing API key");
21return c.json({ error: "API key not configured" }, 500);
22}
2333
34// If the file doesn't have a proper name or type, add one
35// This ensures the file has the right extension for the API
36if (!audioFile.name || !audioFile.type.startsWith('audio/')) {
37const newFile = new File(
45}
4647// Prepare the form data for Groq API
48const groqFormData = new FormData();
49
60groqFormData.append("timestamp_granularities[]", "word");
6162// Call Groq API
63console.log("๐ค Sending request to Groq Whisper API");
64const start = Date.now();
65const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
66method: "POST",
67headers: {
68"Authorization": `Bearer ${apiKey}`
69},
70body: groqFormData
71});
72const elapsed = Date.now() - start;
73console.log(`๐ค Groq Whisper API response received in ${elapsed}ms, status: ${response.status}`);
7475// Get response content type
94errorMessage = `Server error: ${response.status} ${response.statusText}`;
95// Log the full response for debugging
96console.error("โ Transcription API error response:", {
97status: response.status,
98statusText: response.statusText,
103}
104} catch (parseError) {
105console.error("โ Error parsing Groq API response:", parseError);
106errorMessage = "Failed to parse error response from server";
107}
108109return c.json({
110error: `Groq API error: ${errorMessage}`,
111status: response.status
112}, response.status);