aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/gpt
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-04 17:38:36 -0500
committerbobzel <zzzman@gmail.com>2023-12-04 17:38:36 -0500
commit2bd239e39264a362d1fbb013ce2613d03247d78e (patch)
tree6e537dc0c35529c6ee27758a4dec03e23210dbc6 /src/client/apis/gpt
parentcf7a7dc34426dacf018ac98a83a9589106ae7256 (diff)
trying to do version updates on all npm packages.
Diffstat (limited to 'src/client/apis/gpt')
-rw-r--r--src/client/apis/gpt/GPT.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts
index 6bde7989b..85634bc8b 100644
--- a/src/client/apis/gpt/GPT.ts
+++ b/src/client/apis/gpt/GPT.ts
@@ -1,4 +1,4 @@
-import { Configuration, OpenAIApi } from 'openai';
+import { ClientOptions, OpenAI } from 'openai';
enum GPTCallType {
SUMMARY = 'summary',
@@ -29,17 +29,17 @@ const gptAPICall = async (inputText: string, callType: GPTCallType) => {
if (callType === GPTCallType.SUMMARY) inputText += '.';
const opts: GPTCallOpts = callTypeMap[callType];
try {
- const configuration = new Configuration({
+ const configuration:ClientOptions ={
apiKey: process.env.OPENAI_KEY,
- });
- const openai = new OpenAIApi(configuration);
- const response = await openai.createCompletion({
+ };
+ const openai = new OpenAI(configuration);
+ const response = await openai.completions.create({
model: opts.model,
max_tokens: opts.maxTokens,
temperature: opts.temp,
prompt: `${opts.prompt}${inputText}`,
});
- return response.data.choices[0].text;
+ return response.choices[0].text;
} catch (err) {
console.log(err);
return 'Error connecting with API.';
@@ -48,16 +48,16 @@ const gptAPICall = async (inputText: string, callType: GPTCallType) => {
const gptImageCall = async (prompt: string, n?: number) => {
try {
- const configuration = new Configuration({
+ const configuration:ClientOptions = {
apiKey: process.env.OPENAI_KEY,
- });
- const openai = new OpenAIApi(configuration);
- const response = await openai.createImage({
+ };
+ const openai = new OpenAI(configuration);
+ const response = await openai.images.generate({
prompt: prompt,
n: n ?? 1,
size: '1024x1024',
});
- return response.data.data.map(data => data.url);
+ return response.data.map((data:any) => data.url);
// return response.data.data[0].url;
} catch (err) {
console.error(err);