101_2 or _3) to create a fresh table.
102
103### OpenAI
104
105```ts
106import { OpenAI } from "https://esm.town/v/std/openai";
107const openai = new OpenAI();
108const completion = await openai.chat.completions.create({
109 messages: [
110 { role: "user", content: "Say hello in a creative way" },
14
151. The user submits a question or prompt
162. The bot generates a response using OpenAI
173. The response is split into appropriate chunks based on length
184. Each chunk is rendered as text on a solid-color background
21## Technical Implementation
22
23- **Text Generation**: Uses OpenAI's API to generate informative responses
24- **Text Splitting**: Intelligently splits text at natural breaking points (sentences, spaces)
25- **Image Generation**: Uses Val Town's image generation URL with explicit solid-color background prompts
28## Environment Variables
29
30- `OPENAI_API_KEY`: Your OpenAI API key (required)
31
32## Benefits of Solid-Color Backgrounds
71
72 <footer class="mt-4 text-center text-sm text-gray-500">
73 <p>Powered by OpenAI and Val Town Image Generation</p>
74 </footer>
75 </div>
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7// Constants
110 }
111
112 // Get response from OpenAI
113 const completion = await openai.chat.completions.create({
114 model: "gpt-4o-mini",
115 messages: [
3## Configuration
4
5Configure the following two environment variables: `OPENAI_API_KEY` and `EXA_API_KEY`
1import { Hono } from "https://esm.sh/hono@3.12.6";
2import { cors } from "https://esm.sh/hono@3.12.6/cors";
3import { OpenAI } from "https://esm.town/v/std/openai";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
53 }
54
55 const openai = new OpenAI();
56
57 const completion = await openai.chat.completions.create({
58 messages: [
59 {
34
35- Modern, responsive design using React and Tailwind CSS
36- IDESA virtual design assistant powered by OpenAI
37- Interactive sections showcasing IDES INTERIOR services and portfolio
38- Contact form for client inquiries
42- Frontend: React, Tailwind CSS
43- Backend: Hono (API framework)
44- AI Integration: OpenAI API
45- Deployment: Val Town
196 let statusHtml = '<h3 class="font-medium">System Status</h3><ul class="mt-2 text-sm">';
197
198 // Check OpenAI
199 if (data.environment.hasOpenAIKey) {
200 statusHtml += '<li class="text-green-700">✅ OpenAI API key is configured</li>';
201 } else {
202 statusHtml += '<li class="text-red-700">❌ OpenAI API key is missing</li>';
203 }
204
3import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { fetchWikipediaArticle } from "./wikipedia.ts";
5import { generatePodcastScript } from "./openai.ts";
6import { textToSpeech } from "./tts.ts";
7import { blob } from "https://esm.town/v/std/blob";
30// Debug endpoint to check environment
31app.get("/api/debug", async (c) => {
32 const hasOpenAI = !!Deno.env.get("OPENAI_API_KEY");
33 const hasGoogleCreds = !!Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS");
34
35 return c.json({
36 environment: {
37 hasOpenAIKey: hasOpenAI,
38 hasGoogleCredentials: hasGoogleCreds,
39 googleCredsLength: hasGoogleCreds ? Deno.env.get("GOOGLE_APPLICATION_CREDENTIALS")?.length : 0
78 console.log(`Successfully fetched article: "${title}" (${content.length} characters)`);
79
80 // Step 2: Generate podcast script using OpenAI
81 console.log("Generating podcast script with OpenAI...");
82 const script = await generatePodcastScript(title, content);
83 console.log(`Successfully generated script (${script.length} characters)`);
1/**
2 * OpenAI integration for generating podcast scripts from Wikipedia articles
3 */
4import { OpenAI } from "https://esm.town/v/std/openai";
5import { truncateContent } from "./wikipedia.ts";
6
7// Initialize OpenAI client
8const openai = new OpenAI();
9
10/**
19
20 try {
21 const completion = await openai.chat.completions.create({
22 model: "gpt-4o",
23 messages: [