From 8f6ee88f2230b46c9ae5b90b85123d4bc62e070d Mon Sep 17 00:00:00 2001 From: yi-ge Date: Fri, 10 Mar 2023 00:29:57 +0800 Subject: [PATCH] to: Allow the user string to be empty to get the remaining information --- src/chatgpt-api.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/chatgpt-api.ts b/src/chatgpt-api.ts index 14e3a17..17792d6 100644 --- a/src/chatgpt-api.ts +++ b/src/chatgpt-api.ts @@ -331,15 +331,17 @@ export class ChatGPTAPI { } const systemMessageOffset = messages.length - let nextMessages = messages.concat([ - { - ...{ - role: 'user', - content: text, - name: opts.name - } - } - ]) + let nextMessages = text + ? messages.concat([ + { + ...{ + role: 'user', + content: text, + name: opts.name + } + } + ]) + : messages let numTokens = 0 do {