1/** @jsxImportSource npm:hono@3/jsx */
2import { chat } from "https://esm.town/v/stevekrouse/openai";
3import cronstrue from "npm:cronstrue";
4import { Hono } from "npm:hono@3";
8* Hono JSX
9* HTML (probably overcomplicates things; should remove)
10* @stevekrouse/openai, which is a light wrapper around @std/openai
11
12Migrated from folder: Archive/cron_client_side_script_fork
2import { html } from "npm:hono@3/html";
3import { cors } from 'npm:hono/cors';
4import { OpenAI } from "npm:openai";
5
6const app = new Hono();
7const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
8
9class TranscriptionService {
10 async transcribeAudio(audioFile) {
11 try {
12 const transcription = await openai.audio.transcriptions.create({
13 file: audioFile,
14 model: "whisper-1",
18 return transcription;
19 } catch (error) {
20 console.error('OpenAI API error:', error);
21 throw error;
22 }
350
351 try {
352 const response = await openai.chat.completions.create({
353 model: "gpt-3.5-turbo",
354 messages: [
368 return c.text(translation);
369 } catch (error) {
370 console.error('OpenAI API error:', error);
371 return c.text('Error occurred during translation', 500);
372 }
383
384 try {
385 const mp3 = await openai.audio.speech.create({
386 model: "tts-1",
387 voice: voice,
395 });
396 } catch (error) {
397 console.error('OpenAI API error:', error);
398 return c.text('Error occurred during speech generation', 500);
399 }
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
6
7Migrated from folder: Projects/VoiceTranslator/translator
5 options = {},
6) => {
7 // Initialize OpenAI API stub
8 const { Configuration, OpenAIApi } = await import(
9 "https://esm.sh/openai@3.3.0"
10 );
11 console.log(process.env);
12 // const configuration = new Configuration({
13 // apiKey: process.env.OPENAI,
14 // });
15 // const openai = new OpenAIApi(configuration);
16 // // Request chat completion
17 // const messages = typeof prompt === "string"
18 // ? [{ role: "user", content: prompt }]
19 // : prompt;
20 // const { data } = await openai.createChatCompletion({
21 // model: "gpt-3.5-turbo-0613",
22 // messages,
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
30 };
31 }
32 const stream = await openai.chat.completions.create(body);
33 if (!body.stream) {
34 return new Response(JSON.stringify(body), {
1import { api } from "https://esm.town/v/pomdtr/api";
2import { email } from "https://esm.town/v/std/email?v=12";
3import { OpenAI } from "https://esm.town/v/std/OpenAI";
4
5async function getValByAlias({ author, name }: { author: string; name: string }) {
88
89export function askAI(content: string) {
90 const client = new OpenAI();
91 const runner = client.beta.chat.completions.runTools({
92 model: "gpt-3.5-turbo",
1import { OpenAI } from "https://esm.town/v/std/openai?v=4";
2
3const openai = new OpenAI();
4
5async function runConversation() {
13 `.replaceAll(/\s+/g, "");
14
15 const response = await openai.chat.completions.create({
16 messages: [
17 { role: "user", content: prompt },
1Migrated from folder: openai_function_calling/grayWildfowl
1import { Hono } from "npm:hono";
2import { OpenAI } from "npm:openai";
3
4const defaultUser = {
95
96const personalizationGPT = async (user: UserObject) => {
97 const openai = new OpenAI();
98 let chatCompletion = await openai.chat.completions.create({
99 messages: [
100 {