Search
Code3,172
sip.post("/", async (c) => { // Verify the webhook. const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET"); if (!OPENAI_SIGNING_SECRET) { console.error("š“ webhook secret not configured"); return c.text("Internal error", 500); } const webhook = new Webhook(OPENAI_SIGNING_SECRET); const bodyStr = await c.req.text(); let callId: string | undefined;
<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>OpenAI Realtime API Voice Agent</title> <style> :root {
const MODEL = "gpt-realtime";const INSTRUCTIONS = ` Greet the user in English, and thank them for trying the new OpenAI Realtime API. Give them a brief summary based on the list below, and then ask if they have any questions. Answer questions using the information below. For questions outside this scope, - higher audio quality - improved handling of alphanumerics (eg, properly understanding credit card and phone numbers) - support for the OpenAI Prompts API - support for MCP-based tools - auto-truncation to reduce context size//const VOICE = "verse"; //male tenorconst OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");if (!OPENAI_API_KEY) { throw new Error("š“ OpenAI API key not configured");}export function makeHeaders(contentType?: string) { const obj: Record<string, string> = { Authorization: `Bearer ${OPENAI_API_KEY}`, }; if (contentType) obj["Content-Type"] = contentType;
# hello-realtime**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP(telephone) users. You can access the app via WebRTC at[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by calling 425-800-0042.server-side websocket interface.If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from[platform.openai.com](https://platform.openai.com)), and if you want SIP, the `OPENAI_SIGNING_SECRET`.## Architecture - Browser connects to frontend - creates WebRTC offer - `/rtc` endpoint handles SDP negotiation with OpenAI - observer established to monitor session2. **SIP Flow**:
# hello-realtime**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP(telephone) users. You can access the app via WebRTC at[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by calling 425-800-0042.server-side websocket interface.If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from[platform.openai.com](https://platform.openai.com)), and if you want SIP, the `OPENAI_SIGNING_SECRET`.## Architecture - Browser connects to frontend - creates WebRTC offer - `/rtc` endpoint handles SDP negotiation with OpenAI - observer established to monitor session2. **SIP Flow**:
import { OpenAI } from "https://esm.town/v/std/openai";import { createSummarization,/** * OpenAI-powered summarization service for grouped tweets * Extends the existing sentiment analysis to provide topic-based summaries */ const groupedData = this.groupPostsForSummarization(recentPosts); // Generate summary using OpenAI const summary = await this.generateSummaryWithAI( topic, /** * Generate summary using OpenAI */ private async generateSummaryWithAI( try { const openai = new OpenAI(); const response = await openai.chat.completions.create({ model: "gpt-3.5-turbo", messages: [ const result = response.choices[0].message.content?.trim(); if (!result) { throw new Error("No response from OpenAI"); } // Validate response structure if (!summaryData.mainSummary || !Array.isArray(summaryData.keyPoints)) { throw new Error("Invalid response format from OpenAI"); } /** * Build the summarization prompt for OpenAI */ private buildSummarizationPrompt(
- Fetch tweets from your Twitter home feed- Organize tweets by user-defined topics- Generate AI-powered summaries using OpenAI- Deliver summaries via email or Discord- Web dashboard for configuration and viewing summaries
"ANTHROPIC_API_KEY": "your_key_here", "PERPLEXITY_API_KEY": "your_key_here", "OPENAI_API_KEY": "OPENAI_API_KEY_HERE", "GOOGLE_API_KEY": "GOOGLE_API_KEY_HERE", "XAI_API_KEY": "XAI_API_KEY_HERE", "OPENROUTER_API_KEY": "OPENROUTER_API_KEY_HERE", "MISTRAL_API_KEY": "MISTRAL_API_KEY_HERE", "AZURE_OPENAI_API_KEY": "AZURE_OPENAI_API_KEY_HERE", "OLLAMA_API_KEY": "OLLAMA_API_KEY_HERE" }- `ANTHROPIC_API_KEY` (Claude models) - **Recommended**- `PERPLEXITY_API_KEY` (Research features) - **Highly recommended**- `OPENAI_API_KEY` (GPT models)- `GOOGLE_API_KEY` (Gemini models)- `MISTRAL_API_KEY` (Mistral models)
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" },
"ANTHROPIC_API_KEY": "your_key_here", "PERPLEXITY_API_KEY": "your_key_here", "OPENAI_API_KEY": "OPENAI_API_KEY_HERE", "GOOGLE_API_KEY": "GOOGLE_API_KEY_HERE", "XAI_API_KEY": "XAI_API_KEY_HERE", "OPENROUTER_API_KEY": "OPENROUTER_API_KEY_HERE", "MISTRAL_API_KEY": "MISTRAL_API_KEY_HERE", "AZURE_OPENAI_API_KEY": "AZURE_OPENAI_API_KEY_HERE", "OLLAMA_API_KEY": "OLLAMA_API_KEY_HERE" }- `ANTHROPIC_API_KEY` (Claude models) - **Recommended**- `PERPLEXITY_API_KEY` (Research features) - **Highly recommended**- `OPENAI_API_KEY` (GPT models)- `GOOGLE_API_KEY` (Gemini models)- `MISTRAL_API_KEY` (Mistral models)
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