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" },
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" },
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" },
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" },
52{
53 "emoji": "Single emoji summarizing the text",
54 "fullResponse": "JSON string containing the full OpenAI API response",
55 "fromCache": "Boolean indicating whether the response was retrieved from cache"
56}
59{
60 "emoji": "🍕",
61 "fullResponse": "{ ... full OpenAI API response ... }",
62 "fromCache": false
63}
64
65Note: The fullResponse field contains the complete OpenAI API response as a JSON string.
66You may want to parse this JSON string to access specific details of the API response.
67
110Caching:
111The API now uses SQLite to cache responses. If a request for the same text is made again,
112the cached emoji will be returned without calling the OpenAI API. This reduces API calls
113and improves response times for repeated queries.`}
114 </pre>
243
244export default async function server(request: Request): Promise<Response> {
245 const { OpenAI } = await import("https://esm.town/v/std/openai");
246 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
247 const openai = new OpenAI();
248
249 const url = new URL(request.url);
284 }
285
286 // If not in cache, call OpenAI API
287 const completion = await openai.chat.completions.create({
288 messages: [
289 { role: "system", content: "You are an emoji summarizer. Given a text, respond with exactly one emoji that best summarizes the content. Only respond with the single emoji, nothing else." },
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" },
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" },
5 - subscription
6 - chatgpt
7 - openai
8 - billing
9---
13### Quick Links
14
15- [ChatGPT Website](https://chat.openai.com)
16- [Account Settings](https://chat.openai.com/settings)
17
18### Subscription Details
50### Support
51
52- [ChatGPT Help Center](https://help.openai.com)
53- [OpenAI Documentation](https://platform.openai.com/docs)
54
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" },
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" },