Search
Code4,083
<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>OpenAI Realtime API Voice Agent</title> <style> :root {│ │ │ ├── blocks.ts # Block operations│ │ │ └── search.ts # Search operations│ │ ├── aiService.ts # OpenAI for fuzzy matching│ │ └── blobService.ts # Val Town blob storage│ └── utils/ # Utility functions### Strategy 4: AI Fuzzy Matching with Date DisambiguationIf strategies 1-3 don't find a match, the system uses OpenAI (via Val Town's `@std/openai`) to match the todo text against project names and client names.**Initial AI Match**:- Sends the todo text and list of projects (with client names) to OpenAI (`gpt-4o-mini`)- AI returns one of: - A specific project ID (if confident match to a project name)4. The relation named in `TODOS_PROPERTIES.projects` also gets AI matching (Strategies 4-5)**OpenAI Integration**:- Uses Val Town's built-in OpenAI integration (`@std/openai`)- Model: `gpt-4o-mini` (fast, cost-effective)- AI calls per todo (when needed):/** * AI service for fuzzy matching using OpenAI * * Uses OPENAI_API_KEY env var if set (recommended for production). * Falls back to Val Town's shared @std/openai (has 10 req/min limit). */import { OpenAI as ValTownOpenAI } from "https://esm.town/v/std/openai";import OpenAINpm from "npm:openai@4";import type { ProjectWithDates } from '../utils/projectUtils.ts';import type { SummaryResult } from '../../shared/types.ts';// Use own API key if available, otherwise fall back to Val Town's shared clientfunction getOpenAIClient() { const apiKey = Deno.env.get("OPENAI_API_KEY"); if (apiKey) { return new OpenAINpm({ apiKey }); } // Fall back to Val Town's shared OpenAI (has rate limits) return new ValTownOpenAI();} } const openai = getOpenAIClient(); const projectList = projects try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, } const openai = getOpenAIClient(); const projectList = candidates try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, } const openai = getOpenAIClient(); const candidateList = candidates try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, */export async function generateSummary(context: SummaryContext): Promise<SummaryResult> { const openai = getOpenAIClient(); // Build context sections for the prompt try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 200,│ │ │ ├── blocks.ts # Block operations│ │ │ └── search.ts # Search operations│ │ ├── aiService.ts # OpenAI for fuzzy matching│ │ └── blobService.ts # Val Town blob storage│ └── utils/ # Utility functions### Strategy 4: AI Fuzzy Matching with Date DisambiguationIf strategies 1-3 don't find a match, the system uses OpenAI (via Val Town's `@std/openai`) to match the todo text against project names and client names.**Initial AI Match**:- Sends the todo text and list of projects (with client names) to OpenAI (`gpt-4o-mini`)- AI returns one of: - A specific project ID (if confident match to a project name)4. The relation named in `TODOS_PROPERTIES.projects` also gets AI matching (Strategies 4-5)**OpenAI Integration**:- Uses Val Town's built-in OpenAI integration (`@std/openai`)- Model: `gpt-4o-mini` (fast, cost-effective)- AI calls per todo (when needed):/** * AI service for fuzzy matching using OpenAI * * Uses OPENAI_API_KEY env var if set (recommended for production). * Falls back to Val Town's shared @std/openai (has 10 req/min limit). */import { OpenAI as ValTownOpenAI } from "https://esm.town/v/std/openai";import OpenAINpm from "npm:openai@4";import type { ProjectWithDates } from '../utils/projectUtils.ts';import type { SummaryResult } from '../../shared/types.ts';// Use own API key if available, otherwise fall back to Val Town's shared clientfunction getOpenAIClient() { const apiKey = Deno.env.get("OPENAI_API_KEY"); if (apiKey) { return new OpenAINpm({ apiKey }); } // Fall back to Val Town's shared OpenAI (has rate limits) return new ValTownOpenAI();} } const openai = getOpenAIClient(); const projectList = projects try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, } const openai = getOpenAIClient(); const projectList = candidates try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, } const openai = getOpenAIClient(); const candidateList = candidates try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 100, */export async function generateSummary(context: SummaryContext): Promise<SummaryResult> { const openai = getOpenAIClient(); // Build context sections for the prompt try { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", max_tokens: 200,_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" },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" },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" },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" },_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