Search
Code2,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 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" },
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" },
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 clientconst 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 AppThis Val Town app uses OpenAI's Vision API to analyze images and provide descriptions of their content.## 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 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" },
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" },
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" },
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" },
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: string; characterName: string }> { `; // 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 engaging, age-appropriate bedtime stories with robots, aliens, spaceships and other space themes." },
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