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/image-url.jpg%20%22Optional%20title%22?q=openai&page=1&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 1578 results for "openai"(1058ms)

blogget-old-posts.ts5 matches

@fil•Updated 48 mins ago
198 },
199 {
200 "title": "An Introduction to OpenAI fine-tuning",
201 "slug": "an-introduction-to-openai-fine-tuning",
202 "link": "/blog/an-introduction-to-openai-fine-tuning",
203 "description": "How to customize OpenAI to your liking",
204 "pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205 "author": "Steve Krouse",
417 "slug": "val-town-newsletter-16",
418 "link": "/blog/val-town-newsletter-16",
419 "description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420 "pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421 "author": "Steve Krouse",

Towniesystem_prompt.txt4 matches

@charmaine•Updated 1 hour ago
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },

growingEmeraldGrasshoppermain.tsx5 matches

@speedadd•Updated 15 hours ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import OpenAI from "https://esm.sh/openai@4.28.4";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
423 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
424 try {
425 const openai = new OpenAI({
426 apiKey:
427 "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",
432 console.log("Received messages:", JSON.stringify(messages, null, 2));
433
434 // Prepare messages for OpenAI API
435 const formattedMessages = [
436 { role: "system", content: CHARACTER_DESCRIPTION },
443 console.log("Formatted messages:", JSON.stringify(formattedMessages, null, 2));
444
445 const completion = await openai.chat.completions.create({
446 messages: formattedMessages,
447 model: "gpt-3.5-turbo",
453 });
454
455 console.log("OpenAI Response:", JSON.stringify(completion.choices[0].message, null, 2));
456
457 return Response.json({

untitled-9126new-file-3797.tsx3 matches

@xiaofei•Updated 23 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {

untitled-6223README.md3 matches

@xiaofei•Updated 23 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {

untitled-5891new-file-3120.tsx3 matches

@xiaofei•Updated 23 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {

untitled-2604new-file-9513.tsx22 matches

@al0•Updated 1 day ago
73 // Seleccionar el proveedor de LLM
74 switch (provider.toLowerCase()) {
75 case 'openai':
76 result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000);
77 break;
78 case 'anthropic':
82 return new Response(
83 JSON.stringify({
84 error: 'Proveedor no soportado. Utilice "openai" o "anthropic"'
85 }),
86 { status: 400, headers }
111}
112
113// Función para llamar a la API de OpenAI
114async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
115 const url = 'https://api.openai.com/v1/chat/completions';
116
117 console.log(`Llamando a OpenAI con modelo: ${model}`);
118
119 try {
142 // Si la respuesta no es JSON válido, usar el texto de respuesta
143 const text = await response.text();
144 throw new Error(`Error de OpenAI: Status ${response.status}, Respuesta: ${text}`);
145 }
146 throw new Error(`Error de OpenAI: ${errorData.error?.message || JSON.stringify(errorData)}`);
147 }
148
153 } catch (e) {
154 const text = await response.text();
155 throw new Error(`Error al parsear la respuesta de OpenAI: ${e.message}, Respuesta recibida: ${text}`);
156 }
157
158 console.log('Respuesta de OpenAI recibida correctamente');
159
160 return {
161 provider: 'openai',
162 model: model,
163 response: data.choices[0].message.content,
165 };
166 } catch (error) {
167 console.error('Error en llamada a OpenAI:', error);
168 throw error;
169 }
330 <body>
331 <h1>Probador de APIs de LLMs</h1>
332 <p>Esta herramienta te permite probar diferentes APIs de modelos de lenguaje como OpenAI (ChatGPT) y Claude (Anthropic).</p>
333
334 <div class="container">
336 <label for="provider">Proveedor:</label>
337 <select id="provider">
338 <option value="openai">OpenAI (ChatGPT)</option>
339 <option value="anthropic">Anthropic (Claude)</option>
340 </select>
349 <label for="model">Modelo:</label>
350 <select id="model">
351 <option value="gpt-4o">OpenAI: GPT-4o</option>
352 <option value="gpt-4-0613">OpenAI: GPT-4</option>
353 <option value="gpt-3.5-turbo">OpenAI: GPT-3.5 Turbo</option>
354 <option value="claude-3-5-sonnet-20240521">Claude: Claude 3.5 Sonnet</option>
355 <option value="claude-3-opus-20240229">Claude: Claude 3 Opus</option>
440
441 // Agregar opciones según el proveedor
442 if (provider === 'openai') {
443 addOption(modelSelect, 'gpt-4o', 'OpenAI: GPT-4o');
444 addOption(modelSelect, 'gpt-4-0613', 'OpenAI: GPT-4');
445 addOption(modelSelect, 'gpt-3.5-turbo', 'OpenAI: GPT-3.5 Turbo');
446 } else if (provider === 'anthropic') {
447 addOption(modelSelect, 'claude-3-5-sonnet-20240521', 'Claude: Claude 3.5 Sonnet');

testOpenAInew-file-2085.tsx3 matches

@stevekrouse•Updated 1 day ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const openai = new OpenAI();
4
5const completion = await openai.chat.completions.create({
6 messages: [
7 { role: "user", content: "Say hello in a creative way" },

Towniesystem_prompt.txt4 matches

@valdottown•Updated 1 day ago
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },

Towniesystem_prompt.txt4 matches

@std•Updated 1 day ago
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },

testOpenAI1 file match

@stevekrouse•Updated 1 day ago

testOpenAI1 file match

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