Search

3,307 results found for openai (1817ms)

Code
3,212

real/Mold/main.tsx
5 matches
// @ts-ignore
import { 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.");
}
join/chef/main.tsx
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { Hono } from "npm:hono@4.4.12";
`;
const openai = new OpenAI();
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 { Hono } from "npm:hono@4.4.12";
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
join/cto/main.tsx
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { Hono } from "npm:hono@4.4.12";
`;
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
join/mlb/main.tsx
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// @ts-ignore
import { Hono } from "npm:hono@4.4.12";
};
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
join/sb/main.tsx
6 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { InteractionResponseType, InteractionType, verifyKey } from "npm:discord-interactions@3.
`;
// 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 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" },
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 function
async 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 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" },