Search
Code3,212
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI KNOWLEDGE BASE & BEHAVIORAL GUIDELINES --- if (req.method === "POST") { try { const openai = new OpenAI(); const { image } = await req.json(); } const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ parsedContent = JSON.parse(messageContent); } catch (e) { console.error("OpenAI returned non-JSON response:", messageContent); throw new Error("AI failed to generate a valid analysis structure."); } || !Array.isArray(parsedContent.recommendedActions) ) { console.error("OpenAI returned improperly structured JSON:", parsedContent); throw new Error("AI analysis returned an incomplete data structure."); }
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// @ts-ignoreimport { Hono } from "npm:hono@4.4.12"; `; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// @ts-ignoreimport { Hono } from "npm:hono@4.4.12"; } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// @ts-ignoreimport { Hono } from "npm:hono@4.4.12"; `; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// @ts-ignoreimport { Hono } from "npm:hono@4.4.12"; }; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";import { InteractionResponseType, InteractionType, verifyKey } from "npm:discord-interactions@3.4.0";`;// This 'tools' array is the schema that tells the OpenAI model what functions it can call.const tools = [ { // --- Start AI Tool-Using Logic --- const userQuery = interaction.data.options[0].value; const openai = new OpenAI({ apiKey: OPENAI_API_KEY }); const messages: any = [ { role: "system", content: AI_PERSONA_PROMPT }, try { // First call to OpenAI to see if it wants to use a tool let response = await openai.chat.completions.create({ model: "gpt-4o", messages: messages, // Call AI again with the tool results response = await openai.chat.completions.create({ model: "gpt-4o", messages: messages,
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" },
class MovieMatcher { constructor(openaiApiKey, tmdbApiKey) { this.openaiApiKey = openaiApiKey; this.tmdbApiKey = tmdbApiKey; this.openaiBaseUrl = "https://api.openai.com/v1"; this.tmdbBaseUrl = "https://api.themoviedb.org/3"; } } // Use OpenAI to extract/match movie title from input string async extractMovieTitle(inputString) { const prompt =Movie title:`; const response = await fetch(`${this.openaiBaseUrl}/chat/completions`, { method: "POST", headers: { "Authorization": `Bearer ${this.openaiApiKey}`, "Content-Type": "application/json", }, if (!response.ok) { throw new Error( `OpenAI API error: ${response.status} ${response.statusText}`, ); }// Usage example and main execution functionasync function findMovie(inputString, openaiApiKey, tmdbApiKey) { const matcher = new MovieMatcher(openaiApiKey, tmdbApiKey); return await matcher.matchAndFetchMovie(inputString);}
import { OpenAI } from "https://esm.town/v/std/openai?v=4";import { Hono } from "npm:hono@4.4.12";import { stream } from "npm:hono@4.4.12/streaming"; } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } const openai = new OpenAI(); const userMessageContent = `Here is the Property_Data (P):`; const streamResponse = 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 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