Search
Code3,249
import { OpenAI } from "https://esm.town/v/std/openai";export default async function(req: Request): Promise<Response> { }); } const openai = new OpenAI(); try { } const stream = await openai.chat.completions.create(body); if (!body.stream) {
import { OpenAI } from "https://esm.town/v/std/openai";export default async function(req: Request): Promise<Response> { }); } const openai = new OpenAI(); try { } const stream = await openai.chat.completions.create(body); if (!body.stream) {
import { OpenAI } from "https://esm.town/v/std/openai";export default async function(req: Request): Promise<Response> { }); } const openai = new OpenAI(); try { } const stream = await openai.chat.completions.create(body); if (!body.stream) {
// Seleccionar el proveedor de LLM switch (provider.toLowerCase()) { case 'openai': result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000); break; case 'anthropic': return new Response( JSON.stringify({ error: 'Proveedor no soportado. Utilice "openai" o "anthropic"' }), { status: 400, headers }}// Función para llamar a la API de OpenAIasync function callOpenAI(apiKey, prompt, model, temperature, maxTokens) { const url = 'https://api.openai.com/v1/chat/completions'; console.log(`Llamando a OpenAI con modelo: ${model}`); try { // Si la respuesta no es JSON válido, usar el texto de respuesta const text = await response.text(); throw new Error(`Error de OpenAI: Status ${response.status}, Respuesta: ${text}`); } throw new Error(`Error de OpenAI: ${errorData.error?.message || JSON.stringify(errorData)}`); } } catch (e) { const text = await response.text(); throw new Error(`Error al parsear la respuesta de OpenAI: ${e.message}, Respuesta recibida: ${text}`); } console.log('Respuesta de OpenAI recibida correctamente'); return { provider: 'openai', model: model, response: data.choices[0].message.content, }; } catch (error) { console.error('Error en llamada a OpenAI:', error); throw error; } <body> <h1>Probador de APIs de LLMs</h1> <p>Esta herramienta te permite probar diferentes APIs de modelos de lenguaje como OpenAI (ChatGPT) y Claude (Anthropic).</p> <div class="container"> <label for="provider">Proveedor:</label> <select id="provider"> <option value="openai">OpenAI (ChatGPT)</option> <option value="anthropic">Anthropic (Claude)</option> </select> <label for="model">Modelo:</label> <select id="model"> <option value="gpt-4o">OpenAI: GPT-4o</option> <option value="gpt-4-0613">OpenAI: GPT-4</option> <option value="gpt-3.5-turbo">OpenAI: GPT-3.5 Turbo</option> <option value="claude-3-5-sonnet-20240521">Claude: Claude 3.5 Sonnet</option> <option value="claude-3-opus-20240229">Claude: Claude 3 Opus</option> // Agregar opciones según el proveedor if (provider === 'openai') { addOption(modelSelect, 'gpt-4o', 'OpenAI: GPT-4o'); addOption(modelSelect, 'gpt-4-0613', 'OpenAI: GPT-4'); addOption(modelSelect, 'gpt-3.5-turbo', 'OpenAI: GPT-3.5 Turbo'); } else if (provider === 'anthropic') { addOption(modelSelect, 'claude-3-5-sonnet-20240521', 'Claude: Claude 3.5 Sonnet');
import { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({messages: [{ role: "user", content: "Say hello in a creative way" },
return ( <div style={{ padding: 16 }}> <h1>OpenAI In-painting Mask Editor</h1> <input type="file" accept="image/*" onChange={onFileChange} /> correspond to your strokes – exactly what{" "} <a href="https://platform.openai.com/docs/guides/image-generation#mask-requirements" target="_blank" rel="noopener noreferrer" > OpenAI’s in-painting API </a>{" "} expects.
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },
brian@airbnb.com,Brian Cheskydrew@dropbox.com,Drew Houstonsam@openai.com,Sam Altmantim@apple.com,Tim Cookjeff@amazon.com,Jeff Bezos
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
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": "*",
No docs found