Search
Code3,903
<div class="relative"> <select x-model="selectedModel" @change="onModelChange()" class="px-2 py-1 pr-8 border border-gray-200 bg-white rounded-md focus:ring-2 focus:ring-blue-500 appearance-none text-xs w-full"> <option value="openai/gpt-oss-120b">openai/gpt-oss-120b</option> <option value="openai/gpt-oss-20b">openai/gpt-oss-20b</option> <option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option> <option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile</option> <span>JSON mode</span> </label> <label class="inline-flex items-center gap-2 text-xs" x-show="selectedModel && selectedModel.startsWith('openai/gpt-oss')"> <input type="checkbox" x-model="useBrowserSearch" @change="onUseBrowserSearchChange()" class="rounded border-gray-300"> <span>browser search</span> </label> <label class="inline-flex items-center gap-2 text-xs" x-show="selectedModel && selectedModel.startsWith('openai/gpt-oss')"> <input type="checkbox" x-model="useCodeInterpreter" @change="onUseCodeInterpreterChange()" class="rounded border-gray-300"> <span>code interpreter</span>Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },- `main.tsx` - Main cron function and Discord webhook- `fetch-vals.ts` - Fetches and filters new vals using Val Town SDK- `ai-summarizer.ts` - Generates OpenAI summaries for vals without READMEs## Additional logic- Filter out commonly remixed utility vals like Blob Admin, SQLiteExplorer- Skip shallow remixes (forks with ≤3 versions)- Prioritize `main.tsx` files for AI summaries and limit code sent to OpenAI to 5KB to avoid token limits## Setup1. Set `DISCORD_WEBHOOK` environment variable2. Set `OPENAI_API_KEY` environment variable3. Set `testMode = false` in main.tsx for productionimport { OpenAI } from "npm:openai";import ValTown from "npm:@valtown/sdk";const openai = new OpenAI();const client = new ValTown(); } const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ } const openaiApiKey = __secrets['OPENAI_API_KEY']; if (!openaiApiKey) { return Response.json( { error: 'OpenAI API key not configured' }, { status: 500 } );Please respond with only the poem, no explanations or additional text:`; const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { 'Authorization': `Bearer ${openaiApiKey}`, 'Content-Type': 'application/json', }, if (!response.ok) { const errorData = await response.text(); console.error('OpenAI API error:', errorData); return Response.json( { error: 'Failed to generate poem' }, } const apiKey = __secrets['openai_api_key']; if (!apiKey) { return Response.json({ error: 'API key not configured' }, { status: 500 }); } const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { if (!response.ok) { console.error('OpenAI API error:', await response.text()); return Response.json({ error: 'Failed to generate poem' }, { status: 500 }); } } const apiKey = __secrets['openai_api_key']; if (!apiKey) { return Response.json( { error: "OpenAI API key not configured" }, { status: 500 } ); } const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { if (!response.ok) { const error = await response.text(); console.error('OpenAI API error:', error); return Response.json( { error: "Failed to generate poem. Please try again." }, } // Get OpenAI API key from environment const apiKey = __secrets['OPENAI_KEY']; if (!apiKey) { console.error('OpenAI API key not configured'); return Response.json( { error: 'API key not configured' }, } // Call OpenAI API const openaiResponse = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { }); if (!openaiResponse.ok) { const error = await openaiResponse.text(); console.error('OpenAI API error:', error); return Response.json( { error: 'Failed to generate poem' }, } const data = await openaiResponse.json(); const poem = data.choices[0]?.message?.content?.trim();reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
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": "*",
No docs found