Search
Code4,173
/** * OpenAI connection status */export interface OpenAIConnection { envVar: string; status: ConnectionStatus; notion: NotionConnection; database: DatabaseConnection; openai: OpenAIConnection;}│ │ │ ├── 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): name: { displayName: "Name", purpose: "What the todo says. May be cleaned up by AI if OpenAI is configured.", category: "core", required: true, })); // 6. Check OpenAI connection (just check if env var is set) const openaiApiKey = Deno.env.get('OPENAI_API_KEY'); const openaiStatus: 'connected' | 'not_configured' = openaiApiKey ? 'connected' : 'not_configured'; return { ...(databaseError ? { error: databaseError } : {}) }, openai: { envVar: 'OPENAI_API_KEY', status: openaiStatus } }, </dd> {/* OpenAI */} <dt>OpenAI</dt> <dd> <details> <summary> {healthData.connections.openai.status === "connected" ? "OpenAI is connected" : "OpenAI is not configured"} </summary> <article> <dt>Environment variable</dt> <dd> <code>{healthData.connections.openai.envVar}</code> </dd> </dl> {healthData.connections.openai.status !== "connected" && ( <p> To enable AI summaries, add to your Val Town <br /> <code> {healthData.connections.openai.envVar}=your-api-key </code> </p> for (const post of search.data.posts) { const groqRes = await fetch("https://api.groq.com/openai/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${Deno.env.get("GROQ_API_KEY")}`, "Content-Type": "application/json" },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" },# PineconeIndexA simple interface for making and querying Pinecone vector databases. Use OpenAIembeddings to vectorize and searchCreate keys for[Pinecone](https://docs.pinecone.io/guides/projects/manage-api-keys) and[OpenAI](https://platform.openai.com/docs/api-reference/project-api-keys), andstore then in your environment variables. Then,// set up your environment variablesconst pineconeKey = Deno.env.get("PINECONE_KEY");const modelToken = Deno.env.get("OPENAI_KEY");const index = new PineconeIndex({PineconeIndex also provides `handleRequest` as a convenience method to accessyour indices via HTTP. This is useful when accessing the index from other vals,especially without sharing Pinecone and OpenAI credentials.### Server setupimport { Hono } from "npm:hono";import { sqlite } from "https://esm.town/v/std/sqlite";import { OpenAI } from "npm:openai";const app = new Hono();const TABLE_ID = "PATH_GEN_STABLE_V1";const openai = new OpenAI();// --- DATABASE LAYER ---async function generatePage(path: string) { const topic = path.replace(/[^a-zA-Z0-9]/g, " "); const completion = await openai.chat.completions.create({ messages: [ {import pg from "npm:pg@8.11.3";import OpenAI from "npm:openai@4.20.1";const { Client } = pg;// Environment variables (set in Val.town secrets)const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");const RDS_HOST = Deno.env.get("RDS_HOST");const RDS_USER = Deno.env.get("RDS_USER");const EMBEDDING_MODEL = "text-embedding-ada-002";const openai = new OpenAI({ apiKey: OPENAI_API_KEY });async function generateQueryEmbedding(query: string): Promise<number[]> { const response = await openai.embeddings.create({ model: EMBEDDING_MODEL, input: query,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