Search

3,363 results found for openai (1900ms)

Code
3,268

import { OpenAI } from "https://esm.town/v/std/openai";
import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
// Initialize OpenAI client
const openai = new OpenAI();
// Constants
}
// Get response from OpenAI
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
## Configuration
Configure the following two environment variables: `OPENAI_API_KEY` and `EXA_API_KEY`
import { Hono } from "https://esm.sh/hono@3.12.6";
import { cors } from "https://esm.sh/hono@3.12.6/cors";
import { OpenAI } from "https://esm.town/v/std/openai";
import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{
- Modern, responsive design using React and Tailwind CSS
- IDESA virtual design assistant powered by OpenAI
- Interactive sections showcasing IDES INTERIOR services and portfolio
- Contact form for client inquiries
- Frontend: React, Tailwind CSS
- Backend: Hono (API framework)
- AI Integration: OpenAI API
- Deployment: Val Town
let statusHtml = '<h3 class="font-medium">System Status</h3><ul class="mt-2 text-sm">'
// Check OpenAI
if (data.environment.hasOpenAIKey) {
statusHtml += '<li class="text-green-700">✅ OpenAI API key is configured</li>';
} else {
statusHtml += '<li class="text-red-700">❌ OpenAI API key is missing</li>';
}
import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
import { fetchWikipediaArticle } from "./wikipedia.ts";
import { generatePodcastScript } from "./openai.ts";
import { textToSpeech } from "./tts.ts";
import { blob } from "https://esm.town/v/std/blob";
// Debug endpoint to check environment
app.get("/api/debug", async (c) => {
const hasOpenAI = !!Deno.env.get("OPENAI_API_KEY");
const hasGoogleCreds = !!Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS");
return c.json({
environment: {
hasOpenAIKey: hasOpenAI,
hasGoogleCredentials: hasGoogleCreds,
googleCredsLength: hasGoogleCreds ? Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS")?.length
console.log(`Successfully fetched article: "${title}" (${content.length} characters)`);
// Step 2: Generate podcast script using OpenAI
console.log("Generating podcast script with OpenAI...");
const script = await generatePodcastScript(title, content);
console.log(`Successfully generated script (${script.length} characters)`);
/**
* OpenAI integration for generating podcast scripts from Wikipedia articles
*/
import { OpenAI } from "https://esm.town/v/std/openai";
import { truncateContent } from "./wikipedia.ts";
// Initialize OpenAI client
const openai = new OpenAI();
/**
try {
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
1. Fetches content from Wikipedia articles
2. Transforms the content into engaging podcast scripts using OpenAI
3. Converts the scripts to audio using Google's Text-to-Speech service
To use this app, you'll need to set up the following environment variables in Val Town:
- `OPENAI_API_KEY`: Your OpenAI API key
- `GOOGLE_APPLICATION_CREDENTIALS`: Your Google Cloud credentials JSON (stringified)
- `index.ts`: Main HTTP handler
- `wikipedia.ts`: Wikipedia article fetching
- `openai.ts`: Script generation with OpenAI
- `tts.ts`: Google Text-to-Speech integration
- `frontend/`: Simple web interface for the app
import { openai } from "npm:@ai-sdk/openai";
import { Mastra } from "npm:@mastra/core";
import { LibSQLStore, LibSQLVector } from "@mastra/libsql";
name: "My Agent",
instructions: "You are a helpful assistant.",
model: openai("gpt-4o-mini"),
memory: new Memory(),
});
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" },