Search

3,305 results found for openai (1771ms)

Code
3,210

import { openai } from "npm:@ai-sdk/openai";
import ValTown from "npm:@valtown/sdk";
import { generateObject, generateText } from "npm:ai";
const generateImplStart = Date.now();
const { text: implementation } = await generateText({
model: openai("gpt-4o"),
system: `
# VALTOWN HTTP Cloud Function Generator Prompt
5. **AI API Integration (if applicable)**:
- If the toolDescription indicates that creative enrichment or additional processing via AI i
- Import { openai } from "npm:@ai-sdk/openai" and { generateText } from "npm:ai".
- Use the model "gpt-4o-mini".
- Construct a detailed, context-appropriate prompt for the AI call and integrate its response
---typescript
import { openai } from "npm:@ai-sdk/openai";
import { generateText } from "npm:ai";
}
const { text: analysis } = await generateText({
model: openai("gpt-4o-mini"),
system: "You are a creative code analyst.",
prompt: "Analyze the following recent changes in the code: " + body.recent_changes,
const { object: manifestoConfig } = await generateObject({
model: openai("gpt-4o"),
schema: z.object({
manifestoConfigPureJson: z.string(),
const { object: updatedManifestoConfigTypescript } = await generateObject({
model: openai("gpt-4o"),
system: promptForUpdatedManifest,
schema: z.object({
import { openai } from "npm:@ai-sdk/openai";
import ValTown from "npm:@valtown/sdk";
import { generateObject, generateText } from "npm:ai";
const generateImplStart = Date.now();
const { text: implementation } = await generateText({
model: openai("gpt-4o"),
system: `
# VALTOWN HTTP Cloud Function Generator Prompt
5. **AI API Integration (if applicable)**:
- If the toolDescription indicates that creative enrichment or additional processing via AI i
- Import { openai } from "npm:@ai-sdk/openai" and { generateText } from "npm:ai".
- Use the model "gpt-4o-mini".
- Construct a detailed, context-appropriate prompt for the AI call and integrate its response
---typescript
import { openai } from "npm:@ai-sdk/openai";
import { generateText } from "npm:ai";
}
const { text: analysis } = await generateText({
model: openai("gpt-4o-mini"),
system: "You are a creative code analyst.",
prompt: "Analyze the following recent changes in the code: " + body.recent_changes,
const { object: manifestoConfig } = await generateObject({
model: openai("gpt-4o"),
schema: z.object({
manifestoConfigPureJson: z.string(),
const { object: updatedManifestoConfigTypescript } = await generateObject({
model: openai("gpt-4o"),
system: promptForUpdatedManifest,
schema: z.object({
"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 {