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
187
188 const contextWindow: any = await valleGetValsContextWindow(model);
189 const openai = new OpenAI();
190 const stream = await openai.chat.completions.create({
191 model,
192 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
207
208 const contextWindow: any = await valleGetValsContextWindow(model);
209 const openai = new OpenAI();
210 const stream = await openai.chat.completions.create({
211 model,
212 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
299
300 const contextWindow: any = await valleGetValsContextWindow(model);
301 const openai = new OpenAI();
302 const stream = await openai.chat.completions.create({
303 model,
304 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
310
311 const contextWindow: any = await valleGetValsContextWindow(model);
312 const openai = new OpenAI();
313 const stream = await openai.chat.completions.create({
314 model,
315 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
309
310 const contextWindow: any = await valleGetValsContextWindow(model);
311 const openai = new OpenAI();
312 const stream = await openai.chat.completions.create({
313 model,
314 stream: true,
1
2import { OpenAI } from "https://esm.town/v/yawnxyz/OpenAI";
3import { fetch } from "https://esm.town/v/std/fetch";
4
44export class AudioManager {
45 constructor(apiKey=null, uploadFunction = null, downloadFunction = null) {
46 this.openai = new OpenAI(apiKey);
47 this.uploadFunction = uploadFunction || this.blobUpload;
48 }
68 };
69 const mergedOptions = { ...defaultOptions, ...options };
70 const transcription = await this.openai.audio.transcriptions.create(mergedOptions);
71 return transcription;
72 }
80 const mergedOptions = { ...defaultOptions, ...options };
81
82 const translation = await this.openai.audio.translations.create(mergedOptions);
83 return translation;
84 }
85
86 // returns an openai speech object
87 async textToSpeech(text, options = {}) {
88 const defaultOptions = {
92 };
93 const mergedOptions = { ...defaultOptions, ...options };
94 const speech = await this.openai.audio.speech.create(mergedOptions);
95 const arrayBuffer = await speech.arrayBuffer();
96 const blob = new Blob([arrayBuffer], { type: "audio/mpeg" });
106 };
107 const mergedOptions = { ...defaultOptions, ...options };
108 const speech = await this.openai.audio.speech.create(mergedOptions);
109 const arrayBuffer = await speech.arrayBuffer();
110 const blob = new Blob([arrayBuffer], { type: "audio/mpeg" });
7import { Hono } from "npm:hono@3";
8import _ from "npm:lodash@4";
9import OpenAI from "npm:openai";
10import { renderToString } from "npm:react-dom/server";
11
195
196 const contextWindow: any = await valleGetValsContextWindow(model);
197 const openai = new OpenAI();
198 const stream = await openai.chat.completions.create({
199 model,
200 stream: true,
7import { Hono } from "npm:hono@3";
8import _ from "npm:lodash@4";
9import OpenAI from "npm:openai";
10import { renderToString } from "npm:react-dom/server";
11const vt = new ValTown({ bearerToken: Deno.env.get("valtown") });
172
173 const contextWindow = await valleGetValsContextWindow(model);
174 const openai = new OpenAI();
175 const stream = await openai.chat.completions.create({
176 model,
177 stream: true,