From 8af7e8311d5f6022a05f47162562ab030ac2fcc6 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 13 Feb 2023 01:43:47 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chatgpt-api.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/chatgpt-api.ts b/src/chatgpt-api.ts index 8caaf16..cd26df9 100644 --- a/src/chatgpt-api.ts +++ b/src/chatgpt-api.ts @@ -294,6 +294,7 @@ export class ChatGPTAPI { if (response?.id) { result.id = response.id } + if (response?.choices?.length) { result.text = response.choices[0].text.trim() } else { @@ -337,6 +338,14 @@ export class ChatGPTAPI { } } + get apiKey(): string { + return this._apiKey + } + + set apiKey(apiKey: string) { + this._apiKey = apiKey + } + protected async _buildPrompt( message: string, opts: types.SendMessageOptions