aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/apis')
-rw-r--r--src/client/apis/google_docs/GoogleApiClientUtils.ts4
-rw-r--r--src/client/apis/gpt/GPT.ts22
2 files changed, 13 insertions, 13 deletions
diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts
index 551dca073..c8f381cc0 100644
--- a/src/client/apis/google_docs/GoogleApiClientUtils.ts
+++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts
@@ -84,7 +84,7 @@ export namespace GoogleApiClientUtils {
};
try {
const schema: docs_v1.Schema$Document = await Networking.PostToServer(path, parameters);
- return schema.documentId;
+ return schema.documentId === null ? undefined : schema.documentId;
} catch {
return undefined;
}
@@ -195,7 +195,7 @@ export namespace GoogleApiClientUtils {
const title = document.title;
let bodyLines = Utils.extractText(document).text.split("\n");
options.removeNewlines && (bodyLines = bodyLines.filter(line => line.length));
- return { title, bodyLines };
+ return { title: title ?? "", bodyLines };
}
});
};
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);