Search

3,919 results found for openai (1239ms)

Code
3,816

if (!apiKey) {
return Response.json({ error: "OpenAI APIキーが必要です" }, { status: 400 });
}
// OpenAI APIにプロンプトを作成
const prompt = createPrompt(nationName, geographyType, politicalSystem, timePeriod, cultureT
// OpenAI API呼び出し
const aiResponse = await callOpenAI(prompt, apiKey);
// 生成結果を解析
}
async function callOpenAI(prompt, apiKey) {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
if (!response.ok) {
const error = await response.text();
throw new Error(`OpenAI API error: ${response.status} - ${error}`);
}
/**
* AI Command Parsing Module
* Handles OpenAI integration for natural language command interpretation
*/
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
// AI Command Interface
- Don't use both placeholderType and elementId in the same response`;
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
For "replace" commands, identify what they want to replace (even if descriptive like "large text
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
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 cre
### OpenAI
```ts
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 cre
### OpenAI
```ts
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" },
bomb/whim/main.ts
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { blob } from "https://esm.town/v/std/blob?v=11";
// --- CONSTANTS ---
const MAX_DEPTH = 15; // Safety brake for distillation
const openai = new OpenAI();
const INDEX_KEY = "wim_distillation_index";
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
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" },
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { blob } from "https://esm.town/v/std/blob?v=11";
const MAX_DEPTH = 50; // Max number of sentences
const NUM_CHOICES = 3; // Number of branches to generate at each step
const openai = new OpenAI();
const INDEX_KEY = "scribe_index";
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { blob } from "https://esm.town/v/std/blob?v=11";
// --- CONSTANTS ---
const MAX_STEPS = 30; // Safety brake
const openai = new OpenAI();
const INDEX_KEY = "vs_story_index";
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
Note: When changing a SQLite table's schema, change the table's name (e.g., add \_2 or \_3) to c
### OpenAI
```ts
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" }],
model: "gpt-4o-mini",