This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from "fs"; | |
import path from "path"; | |
import OpenAI from "openai"; | |
const openai = new OpenAI({ | |
apiKey: "<OPENAI_API_KEY>", // ← your OpenAI API key here | |
}); | |
const speechFile = path.resolve("./speech_tts-1-hd_javascript.mp3"); | |
const mp3 = await openai.audio.speech.create({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const toolSet = { | |
displayWeather, | |
askForPreferences, | |
askPageContext, | |
translatePage, | |
toggleTheme, | |
articleSearch, | |
podcastTranscript, | |
synthesizeComments, | |
navigateToPage, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { openai } from "@ai-sdk/openai"; | |
import { smoothStream, streamText } from "ai"; | |
import { toolSet } from "./tools"; | |
import { articles } from "@/lib/data"; | |
// Allow streaming responses up to 60 seconds | |
export const maxDuration = 60; | |
export async function POST(req: Request) { | |
try { |