Skip to content

Latest commit

 

History

History
277 lines (156 loc) · 6.23 KB

ChatGPTAPIBrowser.md

File metadata and controls

277 lines (156 loc) · 6.23 KB

chatgpt / Exports / ChatGPTAPIBrowser

Class: ChatGPTAPIBrowser

Hierarchy

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new ChatGPTAPIBrowser(opts)

Creates a new client for automating the ChatGPT webapp.

Parameters

Name Type Description
opts Object -
opts.captchaToken? string Default Value undefined *
opts.debug? boolean Default Value false *
opts.email string -
opts.executablePath? string Default Value undefined *
opts.isGoogleLogin? boolean Default Value false *
opts.isMicrosoftLogin? boolean Default Value false *
opts.isProAccount? boolean Default Value false *
opts.markdown? boolean Default Value true *
opts.minimize? boolean Default Value true *
opts.nopechaKey? string Default Value undefined *
opts.password string -
opts.proxyServer? string Default Value undefined *
opts.userDataDir? string Default Value random directory with email as prefix *

Overrides

AChatGPTAPI.constructor

Defined in

src/chatgpt-api-browser.ts:48

Accessors

isChatPage

get isChatPage(): boolean

Returns

boolean

Defined in

src/chatgpt-api-browser.ts:640

Methods

_onRequest

_onRequest(request): void

Parameters

Name Type
request HTTPRequest

Returns

void

Defined in

src/chatgpt-api-browser.ts:255


_onResponse

_onResponse(response): Promise<void>

Parameters

Name Type
response HTTPResponse

Returns

Promise<void>

Defined in

src/chatgpt-api-browser.ts:292


closeSession

closeSession(): Promise<void>

Closes the active session.

Throws

An error if it fails.

Returns

Promise<void>

Overrides

AChatGPTAPI.closeSession

Defined in

src/chatgpt-api-browser.ts:586


getIsAuthenticated

getIsAuthenticated(): Promise<boolean>

Returns

Promise<boolean>

true if the client is authenticated with a valid session or false otherwise.

Overrides

AChatGPTAPI.getIsAuthenticated

Defined in

src/chatgpt-api-browser.ts:425


initSession

initSession(): Promise<void>

Performs any async initialization work required to ensure that this API is properly authenticated.

Throws

An error if the session failed to initialize properly.

Returns

Promise<void>

Overrides

AChatGPTAPI.initSession

Defined in

src/chatgpt-api-browser.ts:133


refreshSession

refreshSession(): Promise<void>

Attempts to handle 403 errors by refreshing the page.

Returns

Promise<void>

Overrides

AChatGPTAPI.refreshSession

Defined in

src/chatgpt-api-browser.ts:367


resetSession

resetSession(): Promise<void>

Attempts to handle 401 errors by re-authenticating.

Returns

Promise<void>

Overrides

AChatGPTAPI.resetSession

Defined in

src/chatgpt-api-browser.ts:348


resetThread

resetThread(): Promise<void>

Returns

Promise<void>

Defined in

src/chatgpt-api-browser.ts:578


sendMessage

sendMessage(message, opts?): Promise<ChatResponse>

Sends a message to ChatGPT, waits for the response to resolve, and returns the response.

If you want to receive a stream of partial responses, use opts.onProgress.

Parameters

Name Type Description
message string The prompt message to send
opts SendMessageOptions -

Returns

Promise<ChatResponse>

The response from ChatGPT, including conversationId, messageId, and the response text.

Overrides

AChatGPTAPI.sendMessage

Defined in

src/chatgpt-api-browser.ts:439