Search
Code175
handler- Environment variables via `Deno.env.get()`- Val Town std libraries used: `email` (forwarding), `openai` (LLM fallback)## Code Standards- **Geocoder**: US Census Bureau (`geocoding.geo.census.gov`) — free, no API key, handles DC intersections- **LLM fallback**: OpenAI gpt-4o-mini via Val Town `std/openai` for locations that resist deterministic parsing- **Email format**: Location is always in intersections well)- **LLM fallback**: When deterministic parsing can't produce a geocodable address, OpenAI gpt-4o-mini rewrites the location string before a second geocode attempt- **Email parsing**: Location is extracted from the pattern_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" },async function geocodeWithLLM(rawLocation: string): Promise<GeoResult | null> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const completion = await openai.chat.completions.create({ 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" },import { IncomingWebhook } from "npm:@slack/webhook";import { Octokit } from "npm:octokit";import { OpenAI } from "npm:openai";// Environment variables commits: any[],): Promise<string> { const openai = new OpenAI(); // Extract commit messages try { console.log("prompt", prompt); const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-5.2-2025-12-11",// Vibe Engine - Synthesizes prompt stack into OpenAI calls
import { OpenAI } from "https://esm.town/v/std/openai";
import type { PlayedCard, PromptResult } from "../../shared/types.ts";
const prompt = buildPrompt(config, userQuery);
const openai = new OpenAI();
const messages: any[] = [
}
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages,
});
// API: Generate vibe (run OpenAI)
app.post("/api/session/:sessionId/generate", async c => {
const sessionId = c.req.param("sessionId");
### Generation fails
Check that OpenAI integration is working in Val Town console.
## Tips for Fun Sessions
- Val Town account
- Val Town MCP tools installed
- OpenAI API key (automatically provided by Val Town)
## Deployment Steps
## Environment Variables
OpenAI API key is automatically provided by Val Town. No manual setup needed!
If you want to use your own API key:
```bash
mcp_valtown_add_env_var --val "<your-username>/vibe-draft" --key "OPENAI_API_KEY" --value "sk-..." --description "OpenAI API key"
```
Check that `shared/cards.ts` is uploaded correctly and importing properly.
### OpenAI Errors
Verify OpenAI API key is set (should be automatic). Check Val Town console for API errors.
### Database Errors
Users
No users found
Docs
No docs found