Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bsuccess?q=openai&page=11&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=openai

Returns an array of strings in format "username" or "username/projectName"

Found 1576 results for "openai"(1341ms)

textToAudioPlayertts.ts1 match

@dcm31•Updated 1 week ago
35 console.log("🔊 Sending request to Groq Speech API");
36 const start = Date.now();
37 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
38 method: "POST",
39 headers: {

SimpleAudioPlayerPWAapp.tsx4 matches

@dcm31•Updated 1 week ago
291 }
292
293 // Using the OpenAI standard library for TTS
294 const { OpenAI } = await import("https://esm.town/v/std/openai");
295 const openai = new OpenAI();
296
297 const mp3 = await openai.audio.speech.create({
298 model: "tts-1",
299 voice: voice || "alloy",

SimpleAudioPlayerPWAREADME.md1 match

@dcm31•Updated 1 week ago
23## Voice Options
24
25The app uses OpenAI's Text-to-Speech API with these voices:
26
27- Alloy - Neutral, versatile voice

SimpleAudioPlayerPWAindex.ts4 matches

@dcm31•Updated 1 week ago
223 const { text, voice } = await request.json();
224
225 // Using the OpenAI standard library for TTS
226 const { OpenAI } = await import("https://esm.town/v/std/openai");
227 const openai = new OpenAI();
228
229 const mp3 = await openai.audio.speech.create({
230 model: "tts-1",
231 voice: voice || "alloy",

SimpleAudioPlayerPWAvoices.tsx1 match

@dcm31•Updated 1 week ago
1// List of available voices for OpenAI TTS API
2export const voices = [
3 { id: "alloy", name: "Alloy", description: "Neutral, versatile voice" },

SimpleAudioPlayerindex.ts4 matches

@dcm31•Updated 1 week ago
190 const { text } = await request.json();
191
192 // Using the OpenAI standard library for TTS
193 const { OpenAI } = await import("https://esm.town/v/std/openai");
194 const openai = new OpenAI();
195
196 const mp3 = await openai.audio.speech.create({
197 model: "tts-1",
198 voice: "alloy",

groqllmsmain.tsx1 match

@yawnxyz•Updated 1 week ago
14const urls = [
15 "https://console.groq.com/docs/quickstart",
16 "https://console.groq.com/docs/openai",
17 "https://console.groq.com/docs/models",
18 "https://console.groq.com/docs/rate-limits",

ItalianBrainRotGeneratormain.tsx5 matches

@dcm31•Updated 1 week ago
128 if (url.pathname === "/generate-character") {
129 try {
130 const { OpenAI } = await import("https://esm.town/v/std/openai");
131 const openai = new OpenAI();
132
133 // Define the Italian Brainrot character templates based on popular examples
158Create a character that perfectly fits this absurd meme universe without mentioning any specific brands or companies in the description.`;
159
160 const nameCompletion = await openai.chat.completions.create({
161 messages: [
162 { role: "system", content: brainrotSystemPrompt },
169 const characterName = nameCompletion.choices[0].message.content.trim();
170
171 const descriptionCompletion = await openai.chat.completions.create({
172 messages: [
173 { role: "system", content: brainrotSystemPrompt },
187
188 // Get a viral catchphrase
189 const catchphraseCompletion = await openai.chat.completions.create({
190 messages: [
191 { role: "system", content: brainrotSystemPrompt },

MyStevenssendDailyBrief.ts9 matches

@billogiovanni•Updated 1 week ago
1import { Bot } from "https://deno.land/x/grammy@v1.35.0/mod.ts";
2import { DateTime } from "https://esm.sh/luxon@3.4.4";
3import { OpenAI } from "npm:openai";
4import { backstory } from "../backstory.ts";
5import {
13} from "../memoryUtils.ts";
14
15async function generateBriefingContent(openai, memories, today, isSunday) {
16 try {
17 const weekdaysHelp = generateWeekDays(today);
74 };
75
76 console.log("Sending prompt to openai...", userMessage);
77
78 const response = await openai.messages.create({
79 model: "claude-3-7-sonnet-latest",
80 max_tokens: 30000,
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("OPENAI_API_KEY");
101 const telegramToken = Deno.env.get("TELEGRAM_TOKEN");
102
107
108 if (!apiKey) {
109 console.error("openai API key is not configured.");
110 return;
111 }
121 }
122
123 // Initialize openai client
124 const openai = new OpenAI({ apiKey });
125
126 // Initialize Telegram bot
145 // Generate briefing content
146 const content = await generateBriefingContent(
147 openai,
148 memories,
149 today,

svvcmain.tsx17 matches

@Get•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
666}
667
668async function callOpenAI(
669 systemPrompt: string,
670 userPrompt: string,
675 log(
676 "DEBUG",
677 "callOpenAI",
678 `Calling OpenAI for task ${taskId}`,
679 { sysLen: systemPrompt.length, usrLen: userPrompt.length },
680 mandateId,
682 );
683 try {
684 const openai = new OpenAI();
685 const completion = await openai.chat.completions.create({
686 model: "gpt-4o-mini",
687 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userPrompt }],
692 const usage = completion.usage;
693 if (!resultText) {
694 log("WARN", "callOpenAI", `OpenAI returned no content for task ${taskId}.`, { usage }, mandateId, taskId);
695 return null;
696 }
697 log(
698 "DEBUG",
699 "callOpenAI",
700 `OpenAI call successful for task ${taskId}`,
701 { resLen: resultText.length, usage },
702 mandateId,
706 } catch (error) {
707 const errorDetails = { msg: error.message, name: error.name, status: error.status, type: error.type };
708 log("ERROR", "callOpenAI", `OpenAI API call failed for task ${taskId}`, { error: errorDetails }, mandateId, taskId);
709 throw new Error(`OpenAI API error: ${error.message}`);
710 }
711}
1096 `Please generate the ${payload.contentType} for ${payload.platform} based on the details provided in the system prompt.`;
1097 try {
1098 const generatedContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
1099 if (!generatedContent) {
1100 log("WARN", "ContentCreationAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
1154 const userPrompt = `Please develop the marketing strategy based on the details provided in the system prompt.`;
1155 try {
1156 const strategyContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
1157 if (!strategyContent) {
1158 log("WARN", "MarketingStrategyAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
1217 const userPrompt = `Generate logo concepts for "${payload.businessName}" based on the details in the system prompt.`;
1218 try {
1219 const conceptContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
1220 if (!conceptContent) {
1221 log("WARN", "LogoConceptAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
1283 `Build the brand identity guide for "${payload.businessName}" based on the details in the system prompt.`;
1284 try {
1285 const identityContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
1286 if (!identityContent) {
1287 log("WARN", "BrandIdentityAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
1333 const userPrompt = `Run the ${payload.simulationType} simulation using the parameters provided in the system prompt.`;
1334 try {
1335 const simContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
1336 if (!simContent) {
1337 log("WARN", "SimulationAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
1384 `Generate or refine the system prompt based on my request provided in the system prompt context.`;
1385 try {
1386 const genSysPrompt = await callOpenAI(systemPromptForMeta, userPromptForMeta, mandateId, taskId, log);
1387 if (!genSysPrompt) {
1388 log("WARN", "MetaPromptAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);

testOpenAI1 file match

@stevekrouse•Updated 6 hours ago

testOpenAI1 file match

@shouser•Updated 2 days ago
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": "*",