Search
Code3,234
## Voice OptionsThe app uses OpenAI's Text-to-Speech API with these voices:- Alloy - Neutral, versatile voice
const { text, voice } = await request.json(); // Using the OpenAI standard library for TTS const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const mp3 = await openai.audio.speech.create({ model: "tts-1", voice: voice || "alloy",
// List of available voices for OpenAI TTS APIexport const voices = [ { id: "alloy", name: "Alloy", description: "Neutral, versatile voice" },
const { text } = await request.json(); // Using the OpenAI standard library for TTS const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const mp3 = await openai.audio.speech.create({ model: "tts-1", voice: "alloy",
const urls = [ "https://console.groq.com/docs/quickstart", "https://console.groq.com/docs/openai", "https://console.groq.com/docs/models", "https://console.groq.com/docs/rate-limits",
if (url.pathname === "/generate-character") { try { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); // Define the Italian Brainrot character templates based on popular examplesCreate a character that perfectly fits this absurd meme universe without mentioning any specific brands or companies in the description.`; const nameCompletion = await openai.chat.completions.create({ messages: [ { role: "system", content: brainrotSystemPrompt }, const characterName = nameCompletion.choices[0].message.content.trim(); const descriptionCompletion = await openai.chat.completions.create({ messages: [ { role: "system", content: brainrotSystemPrompt }, // Get a viral catchphrase const catchphraseCompletion = await openai.chat.completions.create({ messages: [ { role: "system", content: brainrotSystemPrompt },
import { Bot } from "https://deno.land/x/grammy@v1.35.0/mod.ts";import { DateTime } from "https://esm.sh/luxon@3.4.4";import { OpenAI } from "npm:openai";import { backstory } from "../backstory.ts";import {} from "../memoryUtils.ts";async function generateBriefingContent(openai, memories, today, isSunday) { try { const weekdaysHelp = generateWeekDays(today); }; console.log("Sending prompt to openai...", userMessage); const response = await openai.messages.create({ model: "claude-3-7-sonnet-latest", max_tokens: 30000,export async function sendDailyBriefing(chatId?: string, today?: DateTime) { // Get API keys from environment const apiKey = Deno.env.get("OPENAI_API_KEY"); const telegramToken = Deno.env.get("TELEGRAM_TOKEN"); if (!apiKey) { console.error("openai API key is not configured."); return; } } // Initialize openai client const openai = new OpenAI({ apiKey }); // Initialize Telegram bot // Generate briefing content const content = await generateBriefingContent( openai, memories, today,
import { fetch } from "https://esm.town/v/std/fetch";import { OpenAI } from "https://esm.town/v/std/openai";import { z } from "npm:zod";}async function callOpenAI( systemPrompt: string, userPrompt: string, log( "DEBUG", "callOpenAI", `Calling OpenAI for task ${taskId}`, { sysLen: systemPrompt.length, usrLen: userPrompt.length }, mandateId, ); try { const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userPrompt }], const usage = completion.usage; if (!resultText) { log("WARN", "callOpenAI", `OpenAI returned no content for task ${taskId}.`, { usage }, mandateId, taskId); return null; } log( "DEBUG", "callOpenAI", `OpenAI call successful for task ${taskId}`, { resLen: resultText.length, usage }, mandateId, } catch (error) { const errorDetails = { msg: error.message, name: error.name, status: error.status, type: error.type }; log("ERROR", "callOpenAI", `OpenAI API call failed for task ${taskId}`, { error: errorDetails }, mandateId, taskId); throw new Error(`OpenAI API error: ${error.message}`); }} `Please generate the ${payload.contentType} for ${payload.platform} based on the details provided in the system prompt.`; try { const generatedContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log); if (!generatedContent) { log("WARN", "ContentCreationAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId); const userPrompt = `Please develop the marketing strategy based on the details provided in the system prompt.`; try { const strategyContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log); if (!strategyContent) { log("WARN", "MarketingStrategyAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId); const userPrompt = `Generate logo concepts for "${payload.businessName}" based on the details in the system prompt.`; try { const conceptContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log); if (!conceptContent) { log("WARN", "LogoConceptAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId); `Build the brand identity guide for "${payload.businessName}" based on the details in the system prompt.`; try { const identityContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log); if (!identityContent) { log("WARN", "BrandIdentityAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId); const userPrompt = `Run the ${payload.simulationType} simulation using the parameters provided in the system prompt.`; try { const simContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log); if (!simContent) { log("WARN", "SimulationAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId); `Generate or refine the system prompt based on my request provided in the system prompt context.`; try { const genSysPrompt = await callOpenAI(systemPromptForMeta, userPromptForMeta, mandateId, taskId, log); if (!genSysPrompt) { log("WARN", "MetaPromptAgent", `LLM returned no content for task ${taskId}`, undefined, mandateId, taskId);
import { fetch } from "https://esm.town/v/std/fetch";import { OpenAI } from "https://esm.town/v/std/openai";import { z } from "npm:zod";}async function callOpenAI(sysPrompt: string, userPrompt: string, mid: string, tid: string, lg: LogFn): Promise<string | null> { lg("DEBUG", "callOpenAI", `Initiating OpenAI call tid=${tid}`, { spLen: sysPrompt.length, upLen: userPrompt.length }, mid, tid); try { if (!process.env.OPENAI_API_KEY) { lg("ERROR", "callOpenAI", "OpenAI API key missing.", undefined, mid, tid); throw new Error("OpenAI API key not configured."); } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "system", content: sysPrompt }, { role: "user", content: userPrompt }], const usage = completion.usage; if (!resText) { lg("WARN", "callOpenAI", `OpenAI call returned no text tid=${tid}.`, { usage: usage, finishReason: completion.choices[0]?.finish_reason }, mid, tid); return null; } lg("INFO", "callOpenAI", `OpenAI call OK tid=${tid}`, { resLen: resText.length, usage: usage, finishReason: completion.choices[0]?.finish_reason }, mid, tid); return resText.trim(); } catch (err: any) { const errDtls = { msg: err.message, name: err.name, status: err.status, type: err.type, code: err.code }; lg("ERROR", "callOpenAI", `OpenAI API call failed tid=${tid}`, { error: errDtls }, mid, tid); throw new Error(`OpenAI API failed: ${err.message}` + (err.code ? ` (Code: ${err.code})` : '')); }} const userP = `Generate the ${p.cType} for the specified platform based on the context provided in the system prompt.`; try { const genContent = await callOpenAI(sysP, userP, mid, tid, lg); if (!genContent) { lg("WARN", "CntAgent", `LLM returned no content tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { content: "" }, e: "AI failed to generate content." }; } const output: CntOut = { content: genContent }; const userP = `Develop the marketing strategy based on the system prompt context & framework.`; try { const stratContent = await callOpenAI(sysP, userP, mid, tid, lg); if (!stratContent) { lg("WARN", "StratAgent", `LLM no content for strat tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { strategy: "" }, e: "AI failed strategy." }; } let adIdeas: string[] = []; const userP = `Generate 2-3 distinct logo concepts for "${p.bName}" based on the system prompt. Provide descriptions and AI prompts.`; try { const conceptContent = await callOpenAI(sysP, userP, mid, tid, lg); if (!conceptContent) { lg("WARN", "LogoAgent", `LLM no content for logo tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { concepts: [], prompts: [] }, e: "AI failed logo concepts." }; } const concepts: string[] = []; const prompts: string[] = []; const userP = `Develop foundational brand ID guide for "${p.bName}" based on system prompt context/instructions. Ensure cohesive & practical.`; try { const idContent = await callOpenAI(sysP, userP, mid, tid, lg); if (!idContent) { lg("WARN", "BrandAgent", `LLM no content for brand ID tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { bVoice: "", kMsgs: [], cPalSugs: "", typo: "" }, e: "AI failed brand ID guide." }; } const voiceM = idContent.match(/## Brand Voice & Personality\n([\s\S]*?)(?=\n##|$)/i); const userP = `Run simulation type '${p.simType}' based on system prompt context/params. Follow format.`; try { const simContent = await callOpenAI(sysP, userP, mid, tid, lg); if (!simContent) { lg("WARN", "SimAgent", `LLM no content for sim tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { simResult: "" }, e: "AI failed sim." }; } let simResult = simContent; let analysis: string | undefined = undefined; const userP = `Based on my request in system context, generate/refine the system prompt per guidelines. Output only resulting prompt text.`; try { const genSysP = await callOpenAI(sysP, userP, mid, tid, lg); if (!genSysP) { lg("WARN", "MetaAgent", `LLM no content for meta-prompt tid=${tid}.`, undefined, mid, tid); return { mid, cid: tid, p: { sysPrompt: "" }, e: "AI failed to generate system prompt." }; } const finalP = genSysP.replace(/^```(markdown|text)?\s*/i, '').replace(/\s*```$/, '').trim();
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