* 🐛 fix(api.ts): return message content instead of whole response object

* 🚀 chore(generateCommitMessageFromGitDiff.ts): filter out null promises and update TODO comment
* 🚀 chore(tsconfig.json): update target to ES2020 and remove ES5 from lib
This commit is contained in:
di-sukharev
2023-03-07 15:51:10 +08:00
parent 55e9adf73d
commit 1ea5fbc430
3 changed files with 14 additions and 14 deletions
+2 -3
View File
@@ -1,7 +1,6 @@
import { intro, outro } from '@clack/prompts';
import {
ChatCompletionRequestMessage,
ChatCompletionResponseMessage,
Configuration as OpenAiApiConfiguration,
OpenAIApi
} from 'openai';
@@ -43,7 +42,7 @@ class OpenAi {
public generateCommitMessage = async (
messages: Array<ChatCompletionRequestMessage>
): Promise<ChatCompletionResponseMessage | undefined> => {
): Promise<string | undefined> => {
try {
const { data } = await this.openAI.createChatCompletion({
model: 'gpt-3.5-turbo',
@@ -55,7 +54,7 @@ class OpenAi {
const message = data.choices[0].message;
return message;
return message?.content;
} catch (error) {
console.error('openAI api error', { error });
throw error;