Search
Code3,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 clientconst openai = new OpenAI();// Constants } // Get response from OpenAI const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [
## ConfigurationConfigure 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 environmentapp.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 : 0 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 clientconst openai = new OpenAI();/** try { const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
1. Fetches content from Wikipedia articles2. Transforms the content into engaging podcast scripts using OpenAI3. Converts the scripts to audio using Google's Text-to-Speech serviceTo 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 create a fresh table.### OpenAI```tsimport { 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" },
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
No docs found