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" },
14
15 <div id="apiKeySection" class="bg-white rounded-lg shadow-md p-6 mb-8">
16 <h2 class="text-xl font-semibold mb-4 text-gray-800">OpenAI API Key</h2>
17 <div class="flex gap-4">
18 <input
19 type="password"
20 id="apiKey"
21 placeholder="Enter your OpenAI API key"
22 class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
23 />
1import OpenAI from "npm:openai";
2import { Hono } from "https://esm.sh/hono@3.12.6";
3import {
25// API endpoint
26app.post("/api/enrich", async (c) => {
27 const apiKey = c.req.header("X-OpenAI-API-Key");
28 if (!apiKey) {
29 return c.json(
30 {
31 success: false,
32 error: "OpenAI API key is required",
33 },
34 401
84Format your response as a structured report. If you cannot find information for any section, please indicate "No information found" for that section.`;
85
86 // Initialize OpenAI client
87 const client = new OpenAI({
88 apiKey: apiKey,
89 });
105
106 if (!content) {
107 throw new Error("No content returned from OpenAI");
108 }
109
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" },
29
30// API Key Management
31const API_KEY_STORAGE_KEY = "openai_api_key";
32
33function getStoredApiKey(): string | null {
76 const apiKey = getStoredApiKey();
77 if (!apiKey) {
78 alert("Please enter your OpenAI API key first");
79 apiKeySection?.classList.remove("hidden");
80 enrichmentForm?.classList.add("hidden");
98 headers: {
99 "Content-Type": "application/json",
100 "X-OpenAI-API-Key": apiKey,
101 },
102 body: JSON.stringify(data),
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" },