diff --git a/docs/classes/ChatGPTAPI.md b/docs/classes/ChatGPTAPI.md index c78d20a..78072d9 100644 --- a/docs/classes/ChatGPTAPI.md +++ b/docs/classes/ChatGPTAPI.md @@ -8,6 +8,10 @@ - [constructor](ChatGPTAPI.md#constructor) +### Accessors + +- [user](ChatGPTAPI.md#user) + ### Methods - [ensureAuth](ChatGPTAPI.md#ensureauth) @@ -29,16 +33,34 @@ Creates a new client wrapper around the unofficial ChatGPT REST API. | Name | Type | Description | | :------ | :------ | :------ | | `opts` | `Object` | - | +| `opts.accessToken?` | `string` | - | | `opts.accessTokenTTL?` | `number` | **`Default Value`** 60000 (60 seconds) | | `opts.apiBaseUrl?` | `string` | **`Default Value`** `'https://chat.openai.com/api'` * | | `opts.backendApiBaseUrl?` | `string` | **`Default Value`** `'https://chat.openai.com/backend-api'` * | +| `opts.clearanceToken` | `string` | - | | `opts.markdown?` | `boolean` | **`Default Value`** `true` * | | `opts.sessionToken` | `string` | = **Required** OpenAI session token which can be found in a valid session's cookies (see readme for instructions) | | `opts.userAgent?` | `string` | **`Default Value`** `'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'` * | #### Defined in -[chatgpt-api.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L35) +[src/chatgpt-api.ts:39](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L39) + +## Accessors + +### user + +• `get` **user**(): [`User`](../modules.md#user) + +Gets the currently signed-in user, if authenticated, `null` otherwise. + +#### Returns + +[`User`](../modules.md#user) + +#### Defined in + +[src/chatgpt-api.ts:98](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L98) ## Methods @@ -55,7 +77,7 @@ is still valid. #### Defined in -[chatgpt-api.ts:221](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L221) +[src/chatgpt-api.ts:250](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L250) ___ @@ -82,7 +104,7 @@ The new conversation instance #### Defined in -[chatgpt-api.ts:285](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L285) +[src/chatgpt-api.ts:344](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L344) ___ @@ -99,7 +121,7 @@ the token fails. #### Defined in -[chatgpt-api.ts:208](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L208) +[src/chatgpt-api.ts:237](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L237) ___ @@ -125,7 +147,7 @@ A valid access token #### Defined in -[chatgpt-api.ts:235](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L235) +[src/chatgpt-api.ts:264](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L264) ___ @@ -156,4 +178,4 @@ The response from ChatGPT #### Defined in -[chatgpt-api.ts:94](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-api.ts#L94) +[src/chatgpt-api.ts:121](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-api.ts#L121) diff --git a/docs/classes/ChatGPTConversation.md b/docs/classes/ChatGPTConversation.md index 5d47d71..61b8fa7 100644 --- a/docs/classes/ChatGPTConversation.md +++ b/docs/classes/ChatGPTConversation.md @@ -41,7 +41,7 @@ Creates a new conversation wrapper around the ChatGPT API. #### Defined in -[chatgpt-conversation.ts:21](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-conversation.ts#L21) +[src/chatgpt-conversation.ts:21](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-conversation.ts#L21) ## Properties @@ -51,7 +51,7 @@ Creates a new conversation wrapper around the ChatGPT API. #### Defined in -[chatgpt-conversation.ts:10](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-conversation.ts#L10) +[src/chatgpt-conversation.ts:10](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-conversation.ts#L10) ___ @@ -61,7 +61,7 @@ ___ #### Defined in -[chatgpt-conversation.ts:11](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-conversation.ts#L11) +[src/chatgpt-conversation.ts:11](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-conversation.ts#L11) ___ @@ -71,7 +71,7 @@ ___ #### Defined in -[chatgpt-conversation.ts:12](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-conversation.ts#L12) +[src/chatgpt-conversation.ts:12](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-conversation.ts#L12) ## Methods @@ -104,4 +104,4 @@ The response from ChatGPT #### Defined in -[chatgpt-conversation.ts:48](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/chatgpt-conversation.ts#L48) +[src/chatgpt-conversation.ts:48](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/chatgpt-conversation.ts#L48) diff --git a/docs/classes/ChatGPTError.md b/docs/classes/ChatGPTError.md new file mode 100644 index 0000000..b80b8c8 --- /dev/null +++ b/docs/classes/ChatGPTError.md @@ -0,0 +1,99 @@ +[chatgpt](../readme.md) / [Exports](../modules.md) / ChatGPTError + +# Class: ChatGPTError + +## Hierarchy + +- `Error` + + ↳ **`ChatGPTError`** + +## Table of contents + +### Constructors + +- [constructor](ChatGPTError.md#constructor) + +### Properties + +- [originalError](ChatGPTError.md#originalerror) +- [response](ChatGPTError.md#response) +- [statusCode](ChatGPTError.md#statuscode) +- [statusText](ChatGPTError.md#statustext) + +## Constructors + +### constructor + +• **new ChatGPTError**(`message?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `message?` | `string` | + +#### Inherited from + +Error.constructor + +#### Defined in + +node_modules/.pnpm/typescript@4.9.3/node_modules/typescript/lib/lib.es5.d.ts:1059 + +• **new ChatGPTError**(`message?`, `options?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `message?` | `string` | +| `options?` | `ErrorOptions` | + +#### Inherited from + +Error.constructor + +#### Defined in + +node_modules/.pnpm/typescript@4.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:30 + +## Properties + +### originalError + +• `Optional` **originalError**: `Error` + +#### Defined in + +[src/types.ts:295](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L295) + +___ + +### response + +• `Optional` **response**: `Response` + +#### Defined in + +[src/types.ts:294](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L294) + +___ + +### statusCode + +• `Optional` **statusCode**: `number` + +#### Defined in + +[src/types.ts:292](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L292) + +___ + +### statusText + +• `Optional` **statusText**: `string` + +#### Defined in + +[src/types.ts:293](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L293) diff --git a/docs/modules.md b/docs/modules.md index f07f115..85ca365 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -8,6 +8,7 @@ - [ChatGPTAPI](classes/ChatGPTAPI.md) - [ChatGPTConversation](classes/ChatGPTConversation.md) +- [ChatGPTError](classes/ChatGPTError.md) ### Type Aliases @@ -46,7 +47,7 @@ #### Defined in -[types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L109) +[src/types.ts:109](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L109) ___ @@ -56,7 +57,7 @@ ___ #### Defined in -[types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L1) +[src/types.ts:1](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L1) ___ @@ -78,7 +79,7 @@ https://chat.openapi.com/backend-api/conversation #### Defined in -[types.ts:134](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L134) +[src/types.ts:134](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L134) ___ @@ -96,7 +97,7 @@ ___ #### Defined in -[types.ts:251](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L251) +[src/types.ts:251](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L251) ___ @@ -121,7 +122,7 @@ ___ #### Defined in -[types.ts:257](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L257) +[src/types.ts:257](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L257) ___ @@ -138,7 +139,7 @@ ___ #### Defined in -[types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L270) +[src/types.ts:270](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L270) ___ @@ -160,7 +161,7 @@ https://chat.openapi.com/backend-api/conversation/message_feedback #### Defined in -[types.ts:193](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L193) +[src/types.ts:193](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L193) ___ @@ -170,7 +171,7 @@ ___ #### Defined in -[types.ts:249](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L249) +[src/types.ts:249](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L249) ___ @@ -190,7 +191,7 @@ ___ #### Defined in -[types.ts:222](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L222) +[src/types.ts:222](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L222) ___ @@ -200,7 +201,7 @@ ___ #### Defined in -[types.ts:220](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L220) +[src/types.ts:220](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L220) ___ @@ -210,7 +211,7 @@ ___ #### Defined in -[types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L275) +[src/types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L275) ___ @@ -228,7 +229,7 @@ ___ #### Defined in -[types.ts:77](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L77) +[src/types.ts:77](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L77) ___ @@ -246,7 +247,7 @@ https://chat.openapi.com/backend-api/models #### Defined in -[types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L70) +[src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L70) ___ @@ -265,7 +266,7 @@ https://chat.openapi.com/backend-api/moderations #### Defined in -[types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L97) +[src/types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L97) ___ @@ -285,7 +286,7 @@ https://chat.openapi.com/backend-api/moderations #### Defined in -[types.ts:114](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L114) +[src/types.ts:114](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L114) ___ @@ -303,7 +304,7 @@ ___ #### Defined in -[types.ts:161](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L161) +[src/types.ts:161](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L161) ___ @@ -320,7 +321,7 @@ ___ #### Defined in -[types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L178) +[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L178) ___ @@ -330,7 +331,7 @@ ___ #### Defined in -[types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L3) +[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L3) ___ @@ -340,7 +341,7 @@ ___ #### Defined in -[types.ts:286](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L286) +[src/types.ts:286](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L286) ___ @@ -361,7 +362,7 @@ ___ #### Defined in -[types.ts:277](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L277) +[src/types.ts:277](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L277) ___ @@ -382,7 +383,7 @@ https://chat.openapi.com/api/auth/session #### Defined in -[types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L8) +[src/types.ts:8](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L8) ___ @@ -394,9 +395,9 @@ ___ | Name | Type | Description | | :------ | :------ | :------ | -| `email` | `string` | Email of the user | -| `features` | `string`[] \| [] | Features the user is in | -| `groups` | `string`[] \| [] | Groups the user is in | +| `email?` | `string` | Email of the user | +| `features` | `string`[] | Features the user is in | +| `groups` | `string`[] | Groups the user is in | | `id` | `string` | ID of the user | | `image` | `string` | Image of the user | | `name` | `string` | Name of the user | @@ -404,7 +405,7 @@ ___ #### Defined in -[types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/types.ts#L30) +[src/types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/types.ts#L30) ## Functions @@ -424,4 +425,4 @@ ___ #### Defined in -[utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/20c376e/src/utils.ts#L4) +[src/utils.ts:4](https://github.com/transitive-bullshit/chatgpt-api/blob/8e1cde4/src/utils.ts#L4) diff --git a/docs/readme.md b/docs/readme.md index 1be5668..3ef7fc6 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -1,5 +1,8 @@ chatgpt / [Exports](modules.md) +> **Note** +> As of December 11, 2022 ~2pm CST, OpenAI has enabled additional Cloudflare restrictions that are currently preventing us from refreshing access tokens. This is affecting _all_ ChatGPT API wrappers at the moment, including the Python ones. See [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96) for an ongoing discussion until I release a viable workaround. +