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;
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",
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" },
37 language,
38 offset = 0,
39 model = 'openai/gpt-oss-120b',
40 reasoning_effort = 'medium',
41 tools,
54 }
55
56 const isGptOss = typeof model === 'string' && model.startsWith('openai/gpt-oss');
57 const supportsReasoning = isGptOss;
58 const supportsTools = isGptOss;
101 language,
102 offset = 0,
103 model = "openai/gpt-oss-120b",
104 reasoning_effort = "medium",
105 tools = [],
118 }
119
120 const isGptOss = typeof model === "string" && model.startsWith("openai/gpt-oss");
121 const supportsReasoning = isGptOss;
122 const supportsTools = isGptOss;
171
172 const baseUrl = (typeof base_url === "string" && base_url.trim()) ? base_url.trim().replace(/\/$/, "") : "";
173 let endpoint = "https://api.groq.com/openai/v1/chat/completions";
174 if (baseUrl) {
175 if (/(\/v\d+)?\/(chat\/)?completions$/i.test(baseUrl)) {
3export async function groqChatCompletion(apiKey, payload) {
4 console.log('>>> [groqChatCompletion] Payload:', payload);
5 const response = await fetch('https://api.groq.com/openai/v1/chat/completions', {
6 method: 'POST',
7 headers: {
56 try {
57 const res = await groqChatCompletion(apiKey, {
58 model: 'openai/gpt-oss-120b',
59 messages: [
60 { role: 'system', content: 'Classify the user request as either links or text. Respond with a single token: links or text. Use links if the user appears to want a search results list of sources; use text if the user is asking for an explanation/summary/definition.' },
36 language,
37 offset = 0,
38 model = 'openai/gpt-oss-120b',
39 reasoning_effort = 'medium',
40 tools = [],
53 }
54
55 const isGptOss = typeof model === 'string' && model.startsWith('openai/gpt-oss');
56 const supportsReasoning = isGptOss;
57 const supportsTools = isGptOss;
108 const encoder = new TextEncoder();
109 const baseUrl = (typeof base_url === 'string' && base_url.trim()) ? base_url.trim().replace(/\/$/, '') : '';
110 let endpoint = 'https://api.groq.com/openai/v1/chat/completions';
111 if (baseUrl) {
112 if (/(\/v\d+)?\/(chat\/)?completions$/i.test(baseUrl)) {
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { email } from "https://esm.town/v/std/email";
4import type { ChatRequest, ChatResponse, InviteRequest, InviteDetails } from "../../shared/types.ts";
30
31const api = new Hono();
32const openai = new OpenAI();
33
34// Middleware to ensure user is authenticated
280 const messages = await getConversationMessages(currentConversationId);
281
282 // Prepare messages for OpenAI (exclude the current user message since we'll add it)
283 const chatMessages = messages
284 .filter(m => m.id !== userMessage.id) // Exclude the message we just added
293 try {
294 // Get response from ChatGPT
295 const completion = await openai.chat.completions.create({
296 messages: chatMessages,
297 model: "gpt-4o-mini",
49- **Automatic user creation** on first login
50- **Conversation history storage** with full message history
51- **ChatGPT integration** via OpenAI API
52- **Group chat functionality** with role-based permissions
53- **Email invitations** with secure tokens
37## Tech Stack
38
39- **Backend**: Hono, LastLogin auth, SQLite, OpenAI, Server-Sent Events
40- **Frontend**: React, TailwindCSS, Real-time SSE connections
41- **Database**: SQLite with participant and invitation tables