5.8 KiB
chatgpt / Exports / ChatGPTAPIBrowser
Class: ChatGPTAPIBrowser
Hierarchy
-
↳
ChatGPTAPIBrowser
Table of contents
Constructors
Accessors
Methods
- _onRequest
- _onResponse
- closeSession
- getIsAuthenticated
- initSession
- refreshSession
- resetSession
- resetThread
- sendMessage
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.markdown? |
boolean |
Default Value true * |
opts.minimize? |
boolean |
Default Value true * |
opts.password |
string |
- |
Overrides
Defined in
Accessors
isChatPage
• get
isChatPage(): boolean
Returns
boolean
Defined in
src/chatgpt-api-browser.ts:524
Methods
_onRequest
▸ _onRequest(request
): void
Parameters
Name | Type |
---|---|
request |
HTTPRequest |
Returns
void
Defined in
src/chatgpt-api-browser.ts:173
_onResponse
▸ _onResponse(response
): Promise
<void
>
Parameters
Name | Type |
---|---|
response |
HTTPResponse |
Returns
Promise
<void
>
Defined in
src/chatgpt-api-browser.ts:210
closeSession
▸ closeSession(): Promise
<void
>
Closes the active session.
Throws
An error if it fails.
Returns
Promise
<void
>
Overrides
Defined in
src/chatgpt-api-browser.ts:512
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:302
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
Defined in
refreshSession
▸ refreshSession(): Promise
<void
>
Attempts to handle 403 errors by refreshing the page.
Returns
Promise
<void
>
Overrides
Defined in
src/chatgpt-api-browser.ts:282
resetSession
▸ resetSession(): Promise
<void
>
Attempts to handle 401 errors by re-authenticating.
Returns
Promise
<void
>
Overrides
Defined in
src/chatgpt-api-browser.ts:263
resetThread
▸ resetThread(): Promise
<void
>
Returns
Promise
<void
>
Defined in
src/chatgpt-api-browser.ts:504
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.