Search
Code3,898
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI BEHAVIORAL GUIDELINES --- try { const openai = new OpenAI(); // Construct the precise user message for the AI `; const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [brian@airbnb.com,Brian Cheskydrew@dropbox.com,Drew Houstonsam@openai.com,Sam Altmantim@apple.com,Tim Cookjeff@amazon.com,Jeff BezosNote: 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" }], model: "gpt-4o-mini",// Version 1.0.0import OpenAI from "npm:openai@4.73.0";// ============================================================================/** * Analyzes a company using OpenAI with web search to generate a lead score */export async function analyzeCompany( apiKey: string): Promise<LeadAssessment> { const client = new OpenAI({ apiKey }); // Clean up the URL } const apiKey = Deno.env.get("OPENAI_API_KEY"); if (!apiKey) { return Response.json( { error: "OpenAI API key not configured" }, { status: 500 } );# Val Town Lead Scoring SystemA sophisticated lead scoring system that analyzes B2B SaaS companies to determine their fit as Val Town customers. Uses OpenAI's latest GPT-4o model with web search capabilities to provide comprehensive, data-driven assessments.## Overview```┌─────────────┐ ┌──────────────┐ ┌─────────────┐│ Web UI │────▶│ HTTP Handler│────▶│ OpenAI API │└─────────────┘ └──────────────┘ └─────────────┘ │ │2. **Score Engine** (`analyzeCompany`) - Orchestrates OpenAI analysis - Enforces structured output schema - Applies scoring weights- **Runtime**: Deno (Val Town environment)- **AI Model**: OpenAI GPT-4o-2024-11-20- **Language**: TypeScript- **Styling**: Inline CSS (Val Town design system)### Environment Variables- `OPENAI_API_KEY`: Required for AI analysis- `VAL_TOWN_URL`: Base URL for the Val (auto-configured)- **Invalid URLs**: Returns 400 with error message- **API Key Missing**: Returns 500 with configuration error- **OpenAI Errors**: Gracefully degrades with error display- **Network Issues**: Timeout and retry logic included1. Fork this Val to your account2. Set your `OPENAI_API_KEY` in environment variables3. The Val auto-deploys on save4. Access via the generated URL- **Analysis Time**: 10-20 seconds per company- **Rate Limits**: Respects OpenAI rate limits- **Caching**: Results can be cached client-side- **Concurrent Requests**: Handle multiple via API### Updating the ModelTo use a different OpenAI model, change:```typescript1. Check the Val Town logs for errors2. Ensure environment variables are set3. Verify OpenAI API key has sufficient credits4. Test with known-good company URLs---Built with Val Town • Powered by OpenAIimport { sqlite } from "https://esm.town/v/std/sqlite?v=4";// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- TYPE DEFINITIONS ---const app = new Hono();const openai = new OpenAI();/** `; const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ `; const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ try { const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [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" },const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";const 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;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