1import { OpenAI } from "https://esm.town/v/std/openai?v=5"
2import { sqlite } from "https://esm.town/v/std/sqlite?v=6"
3import { Chess } from "npm:chess.js"
131 return c.html(`<body>
132 <div class='p-4'>
133 <h2 class='font-bold'>OpenAI Chess</h2>
134 <p class='pb-4'>Play chess against ChatGPT-4</p>
135 <div id="myBoard" style="width: 400px"></div>
171 chess.move(san)
172
173 const openai = new OpenAI()
174
175 let messages = []
182 args: [c.req.param().id, `Requesting response to ${san}`],
183 })
184 const completion = await openai.chat.completions.create({
185 messages: [
186 {
670 }
671
672 const { OpenAI } = await import("https://esm.town/v/std/openai");
673 const regenerateKey = request.headers.get("Regenerate-Key") || "0";
674 const openai = new OpenAI();
675
676 const { sport, skillLevel, ageGroup, groupSize, selectedSkills, sessionDuration } = await request.json();
707 Ensure that the conclusion ties together all the main concepts covered in the training, reinforces the learning objectives, and provides clear takeaways for both participants and coaches. The questions in the conclusion should prompt critical thinking about the skills practiced and their application in the sport.`;
708
709 const completion = await openai.chat.completions.create({
710 messages: [{ role: "user", content: prompt + `\n\nRegenerate key: ${regenerateKey}` }],
711 model: "gpt-4o-mini",
209
210 try {
211 // More robust OpenAI import and initialization
212 const openaiModule = await import("https://esm.town/v/std/openai");
213
214 // Detailed logging and error checking
215 console.log("OpenAI Module:", Object.keys(openaiModule));
216
217 // Use a more flexible approach to accessing OpenAI
218 const OpenAI = openaiModule.default || openaiModule.OpenAI;
219
220 if (!OpenAI) {
221 throw new Error("Unable to find OpenAI constructor in the imported module");
222 }
223
224 const openai = new OpenAI({
225 // Add any necessary configuration if required
226 // For example: apiKey might be needed depending on the library version
227 });
228
229 // Verify the openai object has the required methods
230 if (!openai.chat || !openai.chat.completions || !openai.chat.completions.create) {
231 throw new Error("OpenAI object does not have the expected chat completion method");
232 }
233
244 };
245
246 const completion = await openai.chat.completions.create({
247 messages: [systemPrompt, ...messages],
248 model: "gpt-4o-mini",
259 if (url.pathname === '/generate-image') {
260 // Verify images method exists
261 if (!openai.images || !openai.images.generate) {
262 throw new Error("OpenAI object does not have the expected image generation method");
263 }
264
266 const { prompt, style, count } = body;
267
268 const imageResponse = await openai.images.generate({
269 model: "dall-e-3",
270 prompt: `A ${style} image of: ${prompt}.
2import React, { useState, useRef, useCallback, useEffect } from "https://esm.sh/react";
3import { createRoot } from "https://esm.sh/react-dom/client";
4import OpenAI from "https://esm.sh/openai";
5
6// Plant Database
121 const base64Image = reader.result.split(',')[1];
122
123 const openai = new OpenAI({
124 apiKey: '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',
125 dangerouslyAllowBrowser: true
127
128 try {
129 const response = await openai.chat.completions.create({
130 model: "gpt-4o",
131 messages: [
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { z } from "npm:zod";
3
33 }
34
35 const openai = new OpenAI();
36
37 const completion = await openai.chat.completions.create({
38 messages: [
39 { role: "user", content: prompt(topic, level.data, stage, difficulty.data) },
30 "settings": {
31 "model": "gpt-4o-mini",
32 "provider": "openai",
33 "system": "please summarize the following article in a 2-4 sentences, describing it from a 3rd person point of view",
34 "prompt": "{jina.content}"
18brian@airbnb.com,Brian Chesky
19drew@dropbox.com,Drew Houston
20sam@openai.com,Sam Altman
21tim@apple.com,Tim Cook
22jeff@amazon.com,Jeff Bezos
1import { email } from "https://esm.town/v/std/email?v=11";
2import { OpenAI } from "npm:openai";
3
4let location = "munchen";
8).then(r => r.json());
9
10const openai = new OpenAI();
11let chatCompletion = await openai.chat.completions.create({
12 messages: [{
13 role: "user",
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: "C#怎么实现一个线程安全的求和" },
149
150 try {
151 // Dynamic imports for SQLite and OpenAI
152 const [{ sqlite }, { OpenAI }] = await Promise.all([
153 import("https://esm.town/v/stevekrouse/sqlite"),
154 import("https://esm.town/v/std/openai")
155 ]);
156
157 const openai = new OpenAI();
158 const SPECIFICATIONS_TABLE = "val_town_agent_specifications";
159 const IMPLEMENTATIONS_TABLE = "val_town_agent_implementations";
227
228 // Generate implementation using GPT-4o-mini
229 const completion = await openai.chat.completions.create({
230 messages: [
231 {