1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export async function cronprompt(prompt: string) {
4 const openai = new OpenAI();
5
6 const functionExpression = await openai.chat.completions.create({
7 messages: [
8 {
2
3export const langchainEx = (async () => {
4 const { OpenAI } = await import("https://esm.sh/langchain/llms/openai");
5 const { PromptTemplate } = await import("https://esm.sh/langchain/prompts");
6 const { LLMChain } = await import("https://esm.sh/langchain/chains");
7 const model = new OpenAI({
8 temperature: 0.9,
9 openAIApiKey: process.env.openai,
10 maxTokens: 100,
11 }, {});
1import { OpenAI } from "https://esm.town/v/std/openai?v=2";
2
3const openai = new OpenAI();
4const functionExpression = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "whats the weather in sf" },
1Migrated from folder: Libraries/ai/OpenAI/openAiHelloWorld
1import { OpenAI } from "npm:openai";
2
3// Create a secret named OPENAI_API_KEY at https://www.val.town/settings/environment-variables
4
5const openai = new OpenAI();
6const functionExpression = await openai.chat.completions.create({
7 "messages": [
8 { "role": "user", "content": "Say hello in a creative way" },
1Example of using Hono to stream OpenAI's streamed chat responses!
2
3Migrated from folder: Utils/ai/examples/openAIHonoChatStreamExample
1import { fetch } from "https://esm.town/v/std/fetch";
2import { Hono } from "npm:hono";
3import { OpenAI } from "npm:openai";
4
5const gistGPT = async (input: string, about?: boolean) => {
8 const chatInput = about ? input : await (await fetch(input)).text();
9
10 const openai = new OpenAI();
11 let chatCompletion = await openai.chat.completions.create({
12 messages: [
13 {
1/** @jsxImportSource npm:hono@3/jsx */
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
3import { chat } from "https://esm.town/v/stevekrouse/openai";
4import cronstrue from "npm:cronstrue";
5import { Hono } from "npm:hono@3";
1import { Hono } from "npm:hono";
2import { OpenAI } from "npm:openai";
3
4const priestGPT = async (verse: string, about?: boolean) => {
5 const openai = new OpenAI();
6 let chatCompletion = await openai.chat.completions.create({
7 messages: [
8 {
11
12
13If you fork this, you'll need to set `OPENAI_API_KEY` in your [Val Town Secrets](https://www.val.town/settings/secrets).
14
15