1// @ts-ignore
2import { OpenAI } from "https://esm.town/v/std/openai?v=4";
3
4// --- AI BEHAVIORAL GUIDELINES ---
420 const url = new URL(req.url);
421 const action = url.searchParams.get("action");
422 const openai = new OpenAI();
423
424 if (req.method === "POST") {
426 switch (action) {
427 case "newGame": {
428 const completion = await openai.chat.completions.create({
429 model: "gpt-4o",
430 messages: [{ role: "system", content: NEW_GAME_PROMPT }],
440 throw new Error("Guess and secretWord are required.");
441 }
442 const completion = await openai.chat.completions.create({
443 model: "gpt-4o",
444 messages: [
24- **Backend:** Hono.js API framework
25- **Database:** SQLite for data persistence
26- **AI:** OpenAI GPT-4 for blend generation and sensory prediction
27- **Frontend:** React with TailwindCSS
28- **Storage:** Val Town Blob storage for file uploads
131## Technology Stack
132
133- **Backend:** Hono.js, SQLite, OpenAI GPT-4
134- **Frontend:** React, TailwindCSS
135- **Platform:** Val Town serverless environment
136- **Database:** SQLite with comprehensive wine data schema
137- **AI Integration:** OpenAI API for blend generation and sensory prediction
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import type {
4 BlendGenerationRequest,
18
19const app = new Hono();
20const openai = new OpenAI();
21
22// Generate a new wine blend using AI
35 const prompt = createBlendGenerationPrompt(request, availableBlocks);
36
37 const completion = await openai.chat.completions.create({
38 model: "gpt-4o-mini",
39 messages: [
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },
300 { getRandomRegexExplanation, saveRegexExplanation, getRegexExplanationById },
301 ReactMarkdown,
302 { OpenAI },
303 { renderToString },
304 { jsx, jsxs, Fragment },
306 import("https://esm.town/v/stainless_em/brainrotdb"),
307 import("npm:react-markdown@7"),
308 import("https://esm.town/v/std/openai"),
309 import("npm:react-dom@19/server.browser"),
310 import("npm:react@19/jsx-runtime"),
336 }
337
338 const openai = new OpenAI();
339
340 const abortController = new AbortController();
341 const completion = await openai.chat.completions.create({
342 messages: [
343 {
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },
78 const {model, modelToken} = this.options;
79 const response = await axios.post(
80 "https://api.openai.com/v1/embeddings",
81 {model, input: text },
82 {
119 for $3.5m, and <code>aunty.com</code>{" "}
120 for $60k. These prices are, of course, negotiable. I can't imagine anyone paying more for{" "}
121 <code>craze.com</code> than OpenAI paid for <code>chat.com</code>{" "}
122 a couple years ago, for example. In the book I'll cover how these aftermarkets work and what shady behavior
123 goes on behind the scenes.
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" },