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/$%7Bart_info.art.src%7D?q=openai&page=57&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 1623 results for "openai"(1175ms)

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 }
cerebras_coder

cerebras_coderqueries5 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",
70 return completion.choices[0].message?.content || "No response";
71 } catch (error) {
72 console.error("OpenAI Error:", error);
73 return "Error generating text";
74 }
cerebras_coder

cerebras_codergenerate-code5 matches

@Proking2005•Updated 1 month ago
1import OpenAI from "openai";
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
16 };
17 } else {
18 const openai = new OpenAI({
19 apiKey: Deno.env.get(
20 "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",
21 ),
22 });
23 const completion = await openai.chat.completions.create({
24 messages: [
25 {
46 },
47 ].filter(Boolean),
48 model: "gpt-4-turbo-preview", // Or another suitable OpenAI model
49 max_tokens: 2000, // Adjust as needed
50 });
52 return {
53 code: extractCodeFromFence(completion.choices[0].message.content),
54 time: 0, // OpenAI doesn't directly provide completion time
55 totalTokens: completion.usage?.total_tokens || 1,
56 };

adaptableLimePelicanmain.tsx3 matches

@ritam_09•Updated 1 month ago
191export default async function server(request: Request): Promise<Response> {
192 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
193 const { OpenAI } = await import("https://esm.town/v/std/openai");
194 const openai = new OpenAI();
195
196 const { messages, rawInput } = await request.json();
219 ];
220
221 const stream = await openai.chat.completions.create({
222 model: "gpt-4o-mini",
223 messages: constrainedMessages,

chatGPTClonemain.tsx6 matches

@Ritam•Updated 1 month ago
79 setIsLoading(true);
80 try {
81 const { OpenAI } = await import("https://esm.town/v/std/openai");
82 const openai = new OpenAI();
83
84 const analysisPrompt = `Comprehensive Medical Report Analysis:
100Respond with a structured, compassionate, and informative analysis that prioritizes patient understanding and next steps.`;
101
102 const analysis = await openai.chat.completions.create({
103 model: "gpt-4o-mini",
104 messages: [
340export default async function server(request: Request): Promise<Response> {
341 if (request.method === 'POST' && new URL(request.url).pathname === '/chat') {
342 const { OpenAI } = await import("https://esm.town/v/std/openai");
343 const openai = new OpenAI();
344
345 const { messages } = await request.json();
346
347 const stream = await openai.chat.completions.create({
348 model: "gpt-4o-mini",
349 messages: messages,

traves_complimentsmain.tsx2 matches

@ajax•Updated 1 month ago
1import { openai } from "npm:@ai-sdk/openai";
2import { generateText } from "npm:ai";
3
8 try {
9 const { text: compliments } = await generateText({
10 model: openai("gpt-4o-mini"),
11 system: "You are a creative compliment generator.",
12 prompt: "Generate 5 unique, thoughtful, and specific compliments about a person named Traves.",

generate_complimentmain.tsx1 match

@ajax•Updated 1 month ago
1import { openai } from "npm:@ai-sdk/openai";
2import { generateText } from "npm:ai";
3

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 4 days ago

testOpenAI1 file match

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