1Migrated from folder: OpenAI/OpenAIStreaming
1Fork it and authenticate with your Val Town API token as the password. Needs an `OPENAI_API_KEY` env var to be set, and change the variables under "Set these to your own".
2
3https://x.com/JanPaul123/status/1812957150559211918
1import { zip } from "https://esm.town/v/pomdtr/sql";
2import { db } from "https://esm.town/v/sqlite/db";
3import OpenAI from "npm:openai";
4
5async function getVals(username, type, limit) {
22
23async function checkHTTPPreviewUpgrade(code) {
24 const openai = new OpenAI();
25 const completion = await openai.chat.completions.create({
26 messages: [
27 {
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
308
309 const contextWindow: any = await valleGetValsContextWindow(model);
310 const openai = new OpenAI();
311 const stream = await openai.chat.completions.create({
312 model,
313 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
323
324 const contextWindow: any = await valleGetValsContextWindow(model);
325 const openai = new OpenAI();
326 const stream = await openai.chat.completions.create({
327 model,
328 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
333
334 const contextWindow: any = await valleGetValsContextWindow(model);
335 const openai = new OpenAI();
336 const stream = await openai.chat.completions.create({
337 model,
338 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
302
303 const contextWindow: any = await valleGetValsContextWindow(model);
304 const openai = new OpenAI();
305 const stream = await openai.chat.completions.create({
306 model,
307 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
311
312 const contextWindow: any = await valleGetValsContextWindow(model);
313 const openai = new OpenAI();
314 const stream = await openai.chat.completions.create({
315 model,
316 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
212
213 const contextWindow: any = await valleGetValsContextWindow(model);
214 const openai = new OpenAI();
215 const stream = await openai.chat.completions.create({
216 model,
217 stream: true,
8import { Hono } from "npm:hono@3";
9import _ from "npm:lodash@4";
10import OpenAI from "npm:openai";
11import { renderToString } from "npm:react-dom/server";
12
287
288 const contextWindow: any = await valleGetValsContextWindow(model);
289 const openai = new OpenAI();
290 const stream = await openai.chat.completions.create({
291 model,
292 stream: true,