1import process from "node:process";
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
110}
111
112function createPoeClient(apiKey: string): OpenAI {
113 return new OpenAI({
114 apiKey: apiKey || "YOUR_POE_API_KEY",
115 baseURL: "https://api.poe.com/v1",
1import process from "node:process";
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
84].filter(Boolean);
85
86function createPoeClient(apiKey: string): OpenAI {
87 return new OpenAI({
88 apiKey: apiKey || "YOUR_POE_API_KEY",
89 baseURL: "https://api.poe.com/v1",
40- ✅ Chat message display with user/assistant styling
41- ✅ Message input with textarea and send button
42- ✅ OpenAI API integration (GPT-4o-mini)
43- ✅ Real-time message updates
44- ✅ Loading states and typing indicators
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite/main.tsx";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { OpenAI } from "https://esm.town/v/std/openai";
6
7const app = new Hono();
8const openai = new OpenAI();
9
10// Unwrap Hono errors to see original error details
177});
178
179// Send a message and get OpenAI response
180app.post("/api/threads/:threadId/messages", async (c) => {
181 const email = c.req.header('X-LastLogin-Email');
214 );
215
216 // Prepare messages for OpenAI (limit to last 20 messages to avoid token limits)
217 const messages = messageHistory.slice(-20).map(msg => ({
218 role: msg.role as 'user' | 'assistant',
220 }));
221
222 // Get OpenAI response
223 const completion = await openai.chat.completions.create({
224 model: "gpt-4o-mini",
225 messages: messages,
231
232 if (!assistantResponse) {
233 throw new Error("No response from OpenAI");
234 }
235
1import { PresidentDocs } from "./nonprofitDocs";
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4const openai = new OpenAI();
5
6export default async function (req: Request): Promise<Response> {
19 // { role: "user", content: "Say hello in a creative way" },
20
21 const completion = await openai.chat.completions.create({
22 messages: [
23 { role: "system", content: systemPrompt },
1import { nanoid } from "https://deno.land/x/nanoid@v3.0.0/mod.ts";
2import { blob } from "https://esm.town/v/std/blob?v=11";
3import { OpenAI } from "https://esm.town/v/std/openai?v=4";
4
5const AUDIT_DEPTH_INTERVAL = 2;
40
41// --- BACKEND LOGIC ---
42const openai = new OpenAI();
43
44async function callAI(
47): Promise<Prerequisite[]> {
48 try {
49 const completion = await openai.chat.completions.create({
50 model: "gpt-4o",
51 messages: [
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },