Search
Code3,280
import { Hono } from 'https://esm.sh/hono@3.11.7';import { OpenAI } from "https://esm.town/v/std/openai";const app = new Hono();// Initialize OpenAI clientconst openai = new OpenAI();// Test a prompt with GPT } const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: prompt }4. A brief explanation of why each alternative might perform better`; const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: systemPrompt },4. A percentage score (0-100%) for each prompt based on the criteria`; const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: systemPrompt },
- **Backend**: Hono.js API framework- **Database**: SQLite for storing prompts and history- **AI**: OpenAI GPT models## Project Structure
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 { 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" },
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