Search

3,329 results found for openai (4158ms)

Code
3,234

## Voice Options
The 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 API
export 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 examples
Create a character that perfectly fits this absurd meme universe without mentioning any specific
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,
Get/svvc/main.tsx
17 matches
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 }, man
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: err
log("ERROR", "callOpenAI", `OpenAI API call failed for task ${taskId}`, { error: errorDetail
throw new Error(`OpenAI API error: ${error.message}`);
}
}
`Please generate the ${payload.contentType} for ${payload.platform} based on the details pro
try {
const generatedContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
if (!generatedContent) {
log("WARN", "ContentCreationAgent", `LLM returned no content for task ${taskId}`, undefine
const userPrompt = `Please develop the marketing strategy based on the details provided in the
try {
const strategyContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
if (!strategyContent) {
log("WARN", "MarketingStrategyAgent", `LLM returned no content for task ${taskId}`, undefi
const userPrompt = `Generate logo concepts for "${payload.businessName}" based on the details
try {
const conceptContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
if (!conceptContent) {
log("WARN", "LogoConceptAgent", `LLM returned no content for task ${taskId}`, undefined, m
`Build the brand identity guide for "${payload.businessName}" based on the details in the sy
try {
const identityContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
if (!identityContent) {
log("WARN", "BrandIdentityAgent", `LLM returned no content for task ${taskId}`, undefined,
const userPrompt = `Run the ${payload.simulationType} simulation using the parameters provided
try {
const simContent = await callOpenAI(systemPrompt, userPrompt, mandateId, taskId, log);
if (!simContent) {
log("WARN", "SimulationAgent", `LLM returned no content for task ${taskId}`, undefined, ma
`Generate or refine the system prompt based on my request provided in the system prompt cont
try {
const genSysPrompt = await callOpenAI(systemPromptForMeta, userPromptForMeta, mandateId, tas
if (!genSysPrompt) {
log("WARN", "MetaPromptAgent", `LLM returned no content for task ${taskId}`, undefined, ma
salon/svvc/main.tsx
18 matches
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: L
lg("DEBUG", "callOpenAI", `Initiating OpenAI call tid=${tid}`, { spLen: sysPrompt.length, upLe
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, finis
return null;
}
lg("INFO", "callOpenAI", `OpenAI call OK tid=${tid}`, { resLen: resText.length, usage: usage
return resText.trim();
} catch (err: any) {
const errDtls = { msg: err.message, name: err.name, status: err.status, type: err.type, 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 provide
try {
const genContent = await callOpenAI(sysP, userP, mid, tid, lg);
if (!genContent) { lg("WARN", "CntAgent", `LLM returned no content tid=${tid}.`, undefined,
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}.`, undefi
let adIdeas: string[] = [];
const userP = `Generate 2-3 distinct logo concepts for "${p.bName}" based on the system prompt
try {
const conceptContent = await callOpenAI(sysP, userP, mid, tid, lg);
if (!conceptContent) { lg("WARN", "LogoAgent", `LLM no content for logo tid=${tid}.`, undefi
const concepts: string[] = []; const prompts: string[] = [];
const userP = `Develop foundational brand ID guide for "${p.bName}" based on system prompt con
try {
const idContent = await callOpenAI(sysP, userP, mid, tid, lg);
if (!idContent) { lg("WARN", "BrandAgent", `LLM no content for brand ID tid=${tid}.`, undefi
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. Follo
try {
const simContent = await callOpenAI(sysP, userP, mid, tid, lg);
if (!simContent) { lg("WARN", "SimAgent", `LLM no content for sim tid=${tid}.`, undefined, m
let simResult = simContent; let analysis: string | undefined = undefined;
const userP = `Based on my request in system context, generate/refine the system prompt per gu
try {
const genSysP = await callOpenAI(sysP, userP, mid, tid, lg);
if (!genSysP) { lg("WARN", "MetaAgent", `LLM no content for meta-prompt tid=${tid}.`, undefi
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 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" },