diff options
author | bobzel <zzzman@gmail.com> | 2024-05-20 16:25:06 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-05-20 16:25:06 -0400 |
commit | f51ce092018a8b452d5e178ddd2a1e5a2c38cc77 (patch) | |
tree | 9dc99279a84c3f2f19f9aff9733586be659152f4 /src/client/apis/gpt/GPT.ts | |
parent | bb11e8c07f86b1ba0148f1e406a070c14e9abc7c (diff) |
lint cleanup for diagrams. reorg of some gpt stuff.
Diffstat (limited to 'src/client/apis/gpt/GPT.ts')
-rw-r--r-- | src/client/apis/gpt/GPT.ts | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts index cca9d58f3..05007960d 100644 --- a/src/client/apis/gpt/GPT.ts +++ b/src/client/apis/gpt/GPT.ts @@ -1,5 +1,5 @@ -import { ClientOptions, OpenAI } from 'openai'; import { ChatCompletionMessageParam } from 'openai/resources'; +import { openai } from './setup'; enum GPTCallType { SUMMARY = 'summary', @@ -68,12 +68,7 @@ const gptAPICall = async (inputTextIn: string, callType: GPTCallType, prompt?: a const opts: GPTCallOpts = callTypeMap[callType]; if (lastCall === inputText) return lastResp; try { - const configuration: ClientOptions = { - apiKey: process.env.OPENAI_KEY, - dangerouslyAllowBrowser: true, - }; lastCall = inputText; - const openai = new OpenAI(configuration); const usePrompt = prompt ? opts.prompt + prompt : opts.prompt; const messages: ChatCompletionMessageParam[] = [ @@ -96,12 +91,6 @@ const gptAPICall = async (inputTextIn: string, callType: GPTCallType, prompt?: a }; const gptImageCall = async (prompt: string, n?: number) => { try { - const configuration: ClientOptions = { - apiKey: process.env.OPENAI_KEY, - dangerouslyAllowBrowser: true, - }; - - const openai = new OpenAI(configuration); const response = await openai.images.generate({ prompt: prompt, n: n ?? 1, @@ -114,14 +103,8 @@ const gptImageCall = async (prompt: string, n?: number) => { } return undefined; }; - const gptGetEmbedding = async (src: string): Promise<number[]> => { try { - const configuration: ClientOptions = { - apiKey: process.env.OPENAI_KEY, - dangerouslyAllowBrowser: true, - }; - const openai = new OpenAI(configuration); const embeddingResponse = await openai.embeddings.create({ model: 'text-embedding-3-large', input: [src], @@ -137,15 +120,8 @@ const gptGetEmbedding = async (src: string): Promise<number[]> => { return []; } }; - const gptImageLabel = async (src: string): Promise<string> => { try { - const configuration: ClientOptions = { - apiKey: process.env.OPENAI_KEY, - dangerouslyAllowBrowser: true, - }; - - const openai = new OpenAI(configuration); const response = await openai.chat.completions.create({ model: 'gpt-4o', messages: [ |