Search
Code168
name: { displayName: "Name", purpose: "What the todo says. May be cleaned up by AI if OpenAI is configured.", category: "core", required: true, </dd> {/* OpenAI */} <dt> <strong>OpenAI</strong> </dt> <dd> <details> <summary> {healthData.connections.openai.status === "connected" ? ( <code className="pico-background-green-100"> Connected </code> ) : healthData.connections.openai.status === "error" ? ( <code className="pico-background-red-500" <article> <dl> {healthData.connections.openai.status === "error" && ( <> <dt>Error</dt> <dd>{healthData.connections.openai.error}</dd> </> )} <dt>Environment variable</dt> <dd> <code>{healthData.connections.openai.envVar}</code> </dd> </dl> {healthData.connections.openai.status !== "connected" && ( <p> To connect to OpenAI, add to your{" "} {envUrl ? ( <a href={envUrl} target="_blank"> <br /> <code> {healthData.connections.openai.envVar}=your-api-key </code> </p> <pre> {JSON.stringify( healthData.connections.openai, null, 2 })); // 6. Check OpenAI connection (validate API key with actual API call) const openaiApiKey = Deno.env.get('OPENAI_API_KEY'); let openaiStatus: 'connected' | 'not_configured' | 'error' = 'not_configured'; let openaiError: string | null = null; if (openaiApiKey) { const openaiResult = await aiService.validateOpenAIConnection(); if (openaiResult.success) { openaiStatus = 'connected'; } else { openaiStatus = 'error'; openaiError = openaiResult.error || 'Failed to connect to OpenAI'; } } ...(databaseError ? { error: databaseError } : {}) }, openai: { envVar: 'OPENAI_API_KEY', status: openaiStatus, error: openaiError } },1. Click [**Remix**](/?intent=remix)2. Add environment variables: - `OPENAI_API_KEY` — for AI lead qualification - `GITHUB_TOKEN` — for accessing GitHub API ([create one here](https://github.com/settings/tokens))app.post("/", async (c) => { // Early API key check to avoid confusing when using the tester ui if (!Deno.env.get("OPENAI_API_KEY")) { return c.json( { error: "Add OPENAI_API_KEY in Environment Variables" }, 503, );// Test endpoint for the welcome UIapp.post("/test", async (c) => { if (!Deno.env.get("OPENAI_API_KEY")) { return c.json( { error: "Add OPENAI_API_KEY in Environment Variables" }, 503, );// Reanalyze a leadapp.post("/lead/:id/reanalyze", async (c) => { if (!Deno.env.get("OPENAI_API_KEY")) { return c.json( { error: "Add OPENAI_API_KEY in Environment Variables" }, 503, );import { readFile } from "https://esm.town/v/std/utils/index.ts";import { Agent, run, webSearchTool } from "npm:@openai/agents@0.3.0";import { getLeadById, storeLead, updateLeadOutput } from "./db.ts"; const { message, history } = await request.json(); const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") }); // System prompt includes info about Abdullah Abdulkareem ]; const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages,# OpenAI Agents TemplateA Val Town template for using the OpenAI Agents SDK.## Get Started1. **Remix this val**1. **Set the `OPENAI_API_KEY` environment variable.** Get your OpenAI API key here: <https://platform.openai.com/api-keys>1. **Customize your agent:** Edit the agent configuration in `main.ts`. You can provide custom `instructions`, choose a different model, or add custom tools.## Learn More- [OpenAI Agents SDK Documentation](https://openai.github.io/openai-agents-js/)- [OpenAI Agents Quickstart](https://openai.github.io/openai-agents-js/guides/quickstart/)- [Val Town Documentation](https://docs.val.town/)import { Agent, run, webSearchTool } from "npm:@openai/agents@0.3.0";const instructions = `You research the web looking for news stories│ │ │ ├── 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: (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):Users
No users found
Docs
No docs found