3
4/**
5 * OpenAI text completion. https://platform.openai.com/docs/api-reference/completions
6 *
7 * val.town and rlimit.com has generously provided a free daily quota. Until the quota is met, no need to provide an API key.
9 query: string;
10}): Promise<number[]> =>
11 fetchJSON("https://api.openai.com/v1/embeddings", {
12 method: "POST",
13 headers: {
2
3export const questionsWithGuidelinesChain = (async () => {
4 const { ChatOpenAI } = await import(
5 "https://esm.sh/langchain@0.0.150/chat_models/openai"
6 );
7 const { LLMChain } = await import("https://esm.sh/langchain@0.0.150/chains");
19 ]);
20 const questionChain = questionPrompt
21 .pipe(new ChatOpenAI({
22 openAIApiKey: process.env.OPENAI_API_KEY,
23 })
24 .pipe(new StringOutputParser()));
31 const styleChain = stylePrompt
32 .pipe(
33 new ChatOpenAI({
34 openAIApiKey: process.env.OPENAI_API_KEY,
35 }),
36 )
15 );
16 const { SupabaseVectorStore } = await import("npm:langchain/vectorstores");
17 const { ChatOpenAI } = await import("npm:langchain/chat_models");
18 const { OpenAIEmbeddings } = await import("npm:langchain/embeddings");
19 const { createClient } = await import(
20 "https://esm.sh/@supabase/supabase-js@2"
25 );
26 let streamedResponse = "";
27 const chat = new ChatOpenAI({
28 modelName: "gpt-3.5-turbo",
29 openAIApiKey: process.env.OPEN_API_KEY,
30 streaming: true,
31 callbacks: [{
35 });
36 const vectorStore = await SupabaseVectorStore.fromExistingIndex(
37 new OpenAIEmbeddings({
38 openAIApiKey: process.env.OPEN_API_KEY,
39 }),
40 {
4export let generateValCodeAPI = (description: string) =>
5 generateValCode(
6 process.env.VT_OPENAI_KEY,
7 description,
8 );
61 "ranks": [[1689676050115, 8], [1689679650435, 9], [1689683250422, 9], [1689686850141, 9], [1689690449649, 9], [1689694050066, 10]]
62 },
63 "https://www.nytimes.com/2023/07/18/technology/openai-chatgpt-facial-recognition.html": {
64 "title": "OpenAI Worries About What Its Chatbot Will Say About People’s Faces",
65 "url": "https://www.nytimes.com/2023/07/18/technology/openai-chatgpt-facial-recognition.html",
66 "section": "technology",
67 "ranks": [[1689676050115, 9], [1689679650435, 10], [1689683250422, 10], [1689686850141, 10], [1689690449649, 10], [1689694050066, 11]]
2
3export let unserializeableLogEx = (async () => {
4 const { Configuration, OpenAIApi } = await import("npm:openai");
5 const configuration = new Configuration({
6 apiKey: process.env.openai,
7 });
8 const openai = new OpenAIApi(configuration);
9 console.log(openai);
10})();
2
3export let unserializeableLogEx = (async () => {
4 const { Configuration, OpenAIApi } = await import("npm:openai");
5 const configuration = new Configuration({
6 apiKey: process.env.openai,
7 });
8 const openai = new OpenAIApi(configuration);
9 console.log(openai);
10})();
4export let kindness = async () => {
5 return await gpt3({
6 openAiKey: process.env.OPENAI_API_KEY,
7 prompt:
8 "Speaking as universal consciousness, say something short, true, uplifting, loving, and kind.",
1import { openaiChatCompletion } from "https://esm.town/v/andreterron/openaiChatCompletion";
2
3export const generateValCode = async (
16 \`\`\`
17 `;
18 const response = await openaiChatCompletion({
19 openaiKey: key,
20 organization: org,
21 body: {