2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {
58};
59
60function SoundWave({ isActive }) {
61 return (
62 <div style={styles.soundWaveContainer}>
77}
78
79function App() {
80 const [isListening, setIsListening] = useState(false);
81 const [isSpeaking, setIsSpeaking] = useState(false);
266}
267
268function client() {
269 createRoot(document.getElementById("root")).render(<App />);
270}
275}
276
277export default async function server(request: Request): Promise<Response> {
278 if (request.method === "POST") {
279 const { OpenAI } = await import("https://esm.town/v/std/openai");
9import Prism from 'https://esm.sh/prismjs@1.29.0';
10
11function App() {
12 const [messages, setMessages] = useState([]);
13 const [input, setInput] = useState("");
148}
149
150function client() {
151 createRoot(document.getElementById("root")).render(<App />);
152}
153if (typeof document !== "undefined") { client(); }
154
155export default async function server(request: Request): Promise<Response> {
156 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
157 const { OpenAI } = await import("https://esm.town/v/std/openai");
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({
7 name: "New York",
148}
149
150function client() {
151 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
152}
153if (typeof document !== "undefined") { client(); }
154
155export default async function server(request: Request): Promise<Response> {
156 return new Response(`
157 <html>
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({
7 name: "New York",
148}
149
150function client() {
151 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
152}
153if (typeof document !== "undefined") { client(); }
154
155export default async function server(request: Request): Promise<Response> {
156 return new Response(`
157 <html>
12const isProd = false;
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
7const serpApiKey = Deno.env.get("SERP_API_KEY");
8
9export async function redditAlert({ lastRunAt }: Interval) {
10 if (!serpApiKey || !mentionsDiscord) {
11 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
7const serpApiKey = Deno.env.get("SERP_API_KEY");
8
9export async function redditAlert({ lastRunAt }: Interval) {
10 if (!serpApiKey || !mentionsDiscord) {
11 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.