Search

2,096 results found for openai (931ms)

Code
2,017

import { fetch } from "https://esm.town/v/std/fetch";
import { OpenAI } from "https://esm.town/v/std/openai";
import { z } from "npm:zod";
}
// --- OpenAI Call Wrapper ---
async function callOpenAI(
sysP: string,
userP: string,
log("DB", "oai", `Call tid=${tid}`, { spL: sysP.length, upL: userP.length }, mid, tid);
try {
const oai = new OpenAI(); // Assumes OPENAI_API_KEY is set in environment
const comp = await oai.chat.completions.create({
model: "gpt-4o-mini",
try {
const { sys, user } = cfg.p(p);
const rawC = await callOpenAI(sys, user, mid, tid, log);
if (!rawC) {
log("WN", cfg.n, `No LLM content tid=${tid}.`, {}, mid, tid);
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" },
import { OpenAI } from "https://esm.town/v/std/openai";
import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
// Initialize OpenAI client
const openai = new OpenAI();
// Define response types
}
// Call OpenAI Vision API to analyze the image
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
console.error("Error analyzing image:", error);
// Determine if it's an OpenAI API error
const errorMessage = error instanceof Error
? error.message
# AI Image Recognition App
This Val Town app uses OpenAI's Vision API to analyze images and provide descriptions of their c
## Features
## Technologies Used
- OpenAI Vision API
- TailwindCSS for styling
- Val Town's blob storage for caching (optional future enhancement)
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" },
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" },
import { OpenAI } from "https://esm.town/v/std/openai";
import { StoryOptions, generateCuteCharacterName } from "../../shared/types.ts";
const openai = new OpenAI();
export async function generateStory(options: StoryOptions): Promise<{ title: string; content: st
`;
// Generate the story using OpenAI
const completion = await openai.chat.completions.create({
messages: [
{ role: "system", content: "You are a creative children's sci-fi storyteller who creates e