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=55&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 1609 results for "openai"(527ms)

get_country_factmain.tsx2 matches

@ajax•Updated 1 month ago
1import { openai } from "npm:@ai-sdk/openai";
2import { generateText } from "npm:ai";
3
12 }
13 const { text: fact } = await generateText({
14 model: openai("gpt-4o-mini"),
15 system: "You are an expert in world trivia.",
16 prompt: `Provide an interesting and fun fact about the country: ${body.country}.`,

get_recipes_by_countrymain.tsx2 matches

@ajax•Updated 1 month ago
1import { openai } from "npm:@ai-sdk/openai";
2import { generateText } from "npm:ai";
3
13 const countriesList = body.countries.join(", ");
14 const { text: recipes } = await generateText({
15 model: openai("gpt-4o-mini"),
16 system: "You are a culinary expert.",
17 prompt: `Provide a list of popular recipes from the following countries: ${countriesList}.`,

fallacyDetectorAImain.tsx7 matches

@davincidreams•Updated 1 month ago
42];
43
44// Mock fallacy detection for when OpenAI fails
45function mockFallacyDetection(text) {
46 const lowercaseText = text.toLowerCase();
95
96 try {
97 // Dynamically import OpenAI with error handling
98 const openAIModule = await import("https://esm.town/v/std/openai").catch(err => {
99 console.error("Failed to import OpenAI module:", err);
100 throw new Error("Could not load AI analysis module");
101 });
102
103 const OpenAI = openAIModule.OpenAI;
104 const openai = new OpenAI();
105
106 const response = await openai.chat.completions.create({
107 model: "gpt-4o-mini",
108 messages: [

audioAIChatmain.tsx5 matches

@davincidreams•Updated 1 month ago
136export default async function server(request: Request): Promise<Response> {
137 if (request.method === 'POST') {
138 const { OpenAI } = await import("https://esm.town/v/std/openai");
139 const openai = new OpenAI();
140
141 // Parse multipart form data
148
149 // Transcribe audio
150 const transcriptionResponse = await openai.audio.transcriptions.create({
151 file: base64Audio,
152 model: "whisper-1",
157
158 // Generate AI response
159 const chatCompletion = await openai.chat.completions.create({
160 messages: [
161 {
175
176 // Generate audio response
177 const speechResponse = await openai.audio.speech.create({
178 model: "tts-1",
179 voice: "nova",

avatarGeneratormain.tsx3 matches

@davincidreams•Updated 1 month ago
82export default async function server(request: Request): Promise<Response> {
83 if (request.method === 'POST') {
84 const { OpenAI } = await import("https://esm.town/v/std/openai");
85 const openai = new OpenAI();
86
87 const { theme } = await request.json();
88
89 const completion = await openai.chat.completions.create({
90 messages: [
91 {

vtuberAppmain.tsx3 matches

@davincidreams•Updated 1 month ago
75export default async function server(request: Request): Promise<Response> {
76 if (request.method === 'POST') {
77 const { OpenAI } = await import("https://esm.town/v/std/openai");
78 const openai = new OpenAI();
79
80 const { theme } = await request.json();
81
82 const completion = await openai.chat.completions.create({
83 messages: [
84 {

MEDIANALIZE_PROMedicalreport.tsx5 matches

@UndiscoverableERA•Updated 1 month ago
224export default async function server(request: Request): Promise<Response> {
225 if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
226 const { OpenAI } = await import("https://esm.town/v/std/openai");
227 const openai = new OpenAI();
228
229 const body = await request.json();
234
235 try {
236 const completion = await openai.chat.completions.create({
237 messages: [
238 {
265 });
266 } catch (error) {
267 console.error('OpenAI Analysis Error:', error);
268 return new Response(JSON.stringify({
269 diagnosis: 'Unable to generate analysis',
298
299function parseAnalysis(analysis: string) {
300 // Basic parsing of OpenAI response
301 const sections = analysis.split('\n\n');
302 return {

MEDIANALIZE_PROhealthcare.tsx14 matches

@UndiscoverableERA•Updated 1 month ago
222 }
223
224 // Dynamically import OpenAI with error handling
225 let OpenAI;
226 try {
227 const module = await import("https://esm.town/v/std/openai");
228 OpenAI = module.OpenAI;
229 } catch (importError) {
230 console.error("OpenAI Import Error:", importError);
231 return new Response(
232 JSON.stringify({
233 error: "Failed to import OpenAI module",
234 details: String(importError),
235 }),
244 }
245
246 // Ensure OpenAI is available
247 if (!OpenAI) {
248 return new Response(
249 JSON.stringify({
250 error: "OpenAI module not found",
251 }),
252 {
260 }
261
262 // Create OpenAI instance
263 const openai = new OpenAI();
264
265 // Create OpenAI completion with comprehensive error handling
266 let completion;
267 try {
268 completion = await openai.chat.completions.create({
269 messages: body.messages,
270 model: "gpt-4o-mini",
272 });
273 } catch (completionError) {
274 console.error("OpenAI Completion Error:", completionError);
275 return new Response(
276 JSON.stringify({

mandomain.tsx8 matches

@api•Updated 1 month ago
311
312export default async function server(request: Request): Promise<Response> {
313 const { OpenAI } = await import("https://esm.town/v/std/openai");
314 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
315
339 };
340
341 const openai = new OpenAI();
342 const KEY = extractKey(new URL(import.meta.url));
343 const SCHEMA_VERSION = 3; // Increment schema version for tool support
627
628 // Call Maverick to create the tool definition
629 const maverickCompletion = await openai.chat.completions.create({
630 model: "gpt-4o-mini",
631 response_format: { type: "json_object" },
717 `;
718
719 const oracleCompletion = await openai.chat.completions.create({
720 model: "gpt-4o-mini",
721 response_format: { type: "json_object" },
783 `;
784
785 const agentBCompletion = await openai.chat.completions.create({
786 model: "gpt-4o-mini",
787 response_format: { type: "json_object" },
916 `;
917
918 const agentBCompletion = await openai.chat.completions.create({
919 model: "gpt-4o-mini",
920 response_format: { type: "json_object" },
1110
1111 // Make completion call with the appropriate agent prompt
1112 const analysisCompletion = await openai.chat.completions.create({
1113 model: "gpt-4o-mini",
1114 response_format: { type: "json_object" },
1269
1270 // Make completion call with the appropriate agent prompt
1271 const agentCompletion = await openai.chat.completions.create({
1272 model: "gpt-4o-mini",
1273 response_format: { type: "json_object" },
cerebras_coder

cerebras_codermigrations5 matches

@Proking2005•Updated 1 month ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2import OpenAI from "openai";
3import { ITERATIONS_TABLE, KEY, PROJECTS_TABLE, SCHEMA_VERSION } from "./migrations";
4
5const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
6
7export async function createProject(prompt: string) {
59}
60
61// Example of using OpenAI (you'll need to adapt this to your specific use case)
62export async function generateText(prompt: string) {
63 try {
64 const completion = await openai.chat.completions.create({
65 messages: [{ role: "user", content: prompt }],
66 model: "gpt-4-turbo-preview",
71 return completion.choices[0].message?.content || "No response";
72 } catch (error) {
73 console.error("OpenAI Error:", error);
74 return "Error generating text";
75 }

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 2 days ago

testOpenAI1 file match

@stevekrouse•Updated 4 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": "*",