Search

3,263 results found for openai (1942ms)

Code
3,168

"description": "A sample blah manifest demonstrating various tool types and configurations."
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here",
},
"tools": [
import { openai } from "npm:@ai-sdk/openai";
import { generateText } from "npm:ai";
}
const { text: fact } = await generateText({
model: openai("gpt-4o-mini"),
system: "You are an expert in world trivia.",
prompt: `Provide an interesting and fun fact about the country: ${body.country}.`,
import { openai } from "npm:@ai-sdk/openai";
import { generateText } from "npm:ai";
const countriesList = body.countries.join(", ");
const { text: recipes } = await generateText({
model: openai("gpt-4o-mini"),
system: "You are a culinary expert.",
prompt: `Provide a list of popular recipes from the following countries: ${countriesList}.
];
// Mock fallacy detection for when OpenAI fails
function mockFallacyDetection(text) {
const lowercaseText = text.toLowerCase();
try {
// Dynamically import OpenAI with error handling
const openAIModule = await import("https://esm.town/v/std/openai").catch(err => {
console.error("Failed to import OpenAI module:", err);
throw new Error("Could not load AI analysis module");
});
const OpenAI = openAIModule.OpenAI;
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
// Parse multipart form data
// Transcribe audio
const transcriptionResponse = await openai.audio.transcriptions.create({
file: base64Audio,
model: "whisper-1",
// Generate AI response
const chatCompletion = await openai.chat.completions.create({
messages: [
{
// Generate audio response
const speechResponse = await openai.audio.speech.create({
model: "tts-1",
voice: "nova",
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { theme } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { theme } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const body = await request.json();
try {
const completion = await openai.chat.completions.create({
messages: [
{
});
} catch (error) {
console.error('OpenAI Analysis Error:', error);
return new Response(JSON.stringify({
diagnosis: 'Unable to generate analysis',
function parseAnalysis(analysis: string) {
// Basic parsing of OpenAI response
const sections = analysis.split('\n\n');
return {
}
// Dynamically import OpenAI with error handling
let OpenAI;
try {
const module = await import("https://esm.town/v/std/openai");
OpenAI = module.OpenAI;
} catch (importError) {
console.error("OpenAI Import Error:", importError);
return new Response(
JSON.stringify({
error: "Failed to import OpenAI module",
details: String(importError),
}),
}
// Ensure OpenAI is available
if (!OpenAI) {
return new Response(
JSON.stringify({
error: "OpenAI module not found",
}),
{
}
// Create OpenAI instance
const openai = new OpenAI();
// Create OpenAI completion with comprehensive error handling
let completion;
try {
completion = await openai.chat.completions.create({
messages: body.messages,
model: "gpt-4o-mini",
});
} catch (completionError) {
console.error("OpenAI Completion Error:", completionError);
return new Response(
JSON.stringify({
api/mando/main.tsx
8 matches
export default async function server(request: Request): Promise<Response> {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
};
const openai = new OpenAI();
const KEY = extractKey(new URL(import.meta.url));
const SCHEMA_VERSION = 3; // Increment schema version for tool support
// Call Maverick to create the tool definition
const maverickCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },
`;
const oracleCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },
`;
const agentBCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },
`;
const agentBCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },
// Make completion call with the appropriate agent prompt
const analysisCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },
// Make completion call with the appropriate agent prompt
const agentCompletion = await openai.chat.completions.create({
model: "gpt-4o-mini",
response_format: { type: "json_object" },