Commit 9e891f52 authored by simon3000's avatar simon3000

added some comment

parent d716a35b
...@@ -10,19 +10,35 @@ const KEY_ACCESS_TOKEN = 'accessToken' ...@@ -10,19 +10,35 @@ const KEY_ACCESS_TOKEN = 'accessToken'
const USER_AGENT = const USER_AGENT =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
/**
* A conversation wrapper around the ChatGPT API. This allows you to send
* multiple messages to ChatGPT and receive responses, without having to
* manually pass the conversation ID and parent message ID for each message.
*/
class Conversation { class Conversation {
protected _api: ChatGPTAPI protected _api: ChatGPTAPI
protected _conversationId: string = undefined protected _conversationId: string = undefined
protected _parentMessageId: string = undefined protected _parentMessageId: string = undefined
/**
* Creates a new conversation wrapper around the ChatGPT API.
* @param api - The ChatGPT API instance to use.
*/
constructor(api: ChatGPTAPI) { constructor(api: ChatGPTAPI) {
this._api = api this._api = api
} }
/** /**
* Sends a message to ChatGPT, waits for the response to resolve, and returns * Sends a message to ChatGPT, waits for the response to resolve, and returns
* the response. If the conversation has not yet been started, this will * the response.
* automatically start the conversation. * If this is the first message in the conversation, the conversation ID and
* parent message ID will be automatically set.
* This allows you to send multiple messages to ChatGPT and receive responses,
* without having to manually pass the conversation ID and parent message ID
* for each message.
* If you want to manually pass the conversation ID and parent message ID,
* use `api.sendMessage` instead.
*
* @param message - The plaintext message to send. * @param message - The plaintext message to send.
* @param opts.onProgress - Optional listener which will be called every time the partial response is updated * @param opts.onProgress - Optional listener which will be called every time the partial response is updated
* @param opts.onConversationResponse - Optional listener which will be called every time a conversation response is received * @param opts.onConversationResponse - Optional listener which will be called every time a conversation response is received
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment