From 9d01e7cb8aceeeec6751ffc481993594b489a49d Mon Sep 17 00:00:00 2001 From: ArneBouillon Date: Sun, 25 Jun 2023 20:33:08 +0200 Subject: [PATCH] Support 'continue' action --- src/chatgpt-unofficial-proxy-api.ts | 22 +++++++++++++--------- src/types.ts | 6 ++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/chatgpt-unofficial-proxy-api.ts b/src/chatgpt-unofficial-proxy-api.ts index e67813e..db97a3d 100644 --- a/src/chatgpt-unofficial-proxy-api.ts +++ b/src/chatgpt-unofficial-proxy-api.ts @@ -141,16 +141,20 @@ export class ChatGPTUnofficialProxyAPI { const body: types.ConversationJSONBody = { action, - messages: [ - { - id: messageId, - role: 'user', - content: { - content_type: 'text', - parts: [text] - } + ...( + action === 'continue' ? {} : { + messages: [ + { + id: messageId, + role: 'user', + content: { + content_type: 'text', + parts: [text] + } + } + ], } - ], + ), model: this._model, parent_message_id: parentMessageId } diff --git a/src/types.ts b/src/types.ts index 2328584..cf095db 100644 --- a/src/types.ts +++ b/src/types.ts @@ -50,7 +50,7 @@ export type SendMessageOptions = { > } -export type MessageActionType = 'next' | 'variant' +export type MessageActionType = 'next' | 'continue' | 'variant' export type SendMessageBrowserOptions = { conversationId?: string @@ -118,8 +118,10 @@ export type ConversationJSONBody = { /** * Prompts to provide + * + * Should be null when the action is 'continue' */ - messages: Prompt[] + messages?: Prompt[] /** * The model to use