untitled-9126new-file-3797.tsx3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
11});
12}
13const openai = new OpenAI();
1415try {
28}
2930const stream = await openai.chat.completions.create(body);
3132if (!body.stream) {
untitled-6223README.md3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
11});
12}
13const openai = new OpenAI();
1415try {
28}
2930const stream = await openai.chat.completions.create(body);
3132if (!body.stream) {
untitled-5891new-file-3120.tsx3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
11});
12}
13const openai = new OpenAI();
1415try {
28}
2930const stream = await openai.chat.completions.create(body);
3132if (!body.stream) {
untitled-2604new-file-9513.tsx22 matches
73// Seleccionar el proveedor de LLM
74switch (provider.toLowerCase()) {
75case 'openai':
76result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000);
77break;
78case 'anthropic':
82return new Response(
83JSON.stringify({
84error: 'Proveedor no soportado. Utilice "openai" o "anthropic"'
85}),
86{ status: 400, headers }
111}
112113// Función para llamar a la API de OpenAI
114async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
115const url = 'https://api.openai.com/v1/chat/completions';
116
117console.log(`Llamando a OpenAI con modelo: ${model}`);
118
119try {
142// Si la respuesta no es JSON válido, usar el texto de respuesta
143const text = await response.text();
144throw new Error(`Error de OpenAI: Status ${response.status}, Respuesta: ${text}`);
145}
146throw new Error(`Error de OpenAI: ${errorData.error?.message || JSON.stringify(errorData)}`);
147}
148
153} catch (e) {
154const text = await response.text();
155throw new Error(`Error al parsear la respuesta de OpenAI: ${e.message}, Respuesta recibida: ${text}`);
156}
157
158console.log('Respuesta de OpenAI recibida correctamente');
159
160return {
161provider: 'openai',
162model: model,
163response: data.choices[0].message.content,
165};
166} catch (error) {
167console.error('Error en llamada a OpenAI:', error);
168throw 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
442if (provider === 'openai') {
443addOption(modelSelect, 'gpt-4o', 'OpenAI: GPT-4o');
444addOption(modelSelect, 'gpt-4-0613', 'OpenAI: GPT-4');
445addOption(modelSelect, 'gpt-3.5-turbo', 'OpenAI: GPT-3.5 Turbo');
446} else if (provider === 'anthropic') {
447addOption(modelSelect, 'claude-3-5-sonnet-20240521', 'Claude: Claude 3.5 Sonnet');
testOpenAInew-file-2085.tsx3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23const openai = new OpenAI();
45const completion = await openai.chat.completions.create({
6messages: [
7{ role: "user", content: "Say hello in a creative way" },
Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
image-inpaintingApp.tsx3 matches
142return (
143<div style={{ padding: 16 }}>
144<h1>OpenAI In-painting Mask Editor</h1>
145146<input type="file" accept="image/*" onChange={onFileChange} />
184correspond to your strokes – exactly what{" "}
185<a
186href="https://platform.openai.com/docs/guides/image-generation#mask-requirements"
187target="_blank"
188rel="noopener noreferrer"
189>
190OpenAI’s in-painting API
191</a>{" "}
192expects.
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },