2022-12-03 00:04:53 +00:00
|
|
|
[chatgpt](readme.md) / Exports
|
|
|
|
|
|
|
|
# chatgpt
|
|
|
|
|
|
|
|
## Table of contents
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
### Namespaces
|
|
|
|
|
|
|
|
- [openai](modules/openai.md)
|
|
|
|
|
2022-12-03 00:04:53 +00:00
|
|
|
### Classes
|
|
|
|
|
|
|
|
- [ChatGPTAPI](classes/ChatGPTAPI.md)
|
2022-12-12 00:04:20 +00:00
|
|
|
- [ChatGPTError](classes/ChatGPTError.md)
|
2023-02-19 08:51:53 +00:00
|
|
|
- [ChatGPTUnofficialProxyAPI](classes/ChatGPTUnofficialProxyAPI.md)
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
### Interfaces
|
|
|
|
|
|
|
|
- [ChatMessage](interfaces/ChatMessage.md)
|
|
|
|
|
2022-12-05 05:13:36 +00:00
|
|
|
### Type Aliases
|
|
|
|
|
2023-03-02 23:25:26 +00:00
|
|
|
- [ChatGPTAPIOptions](modules.md#chatgptapioptions)
|
2023-02-19 08:51:53 +00:00
|
|
|
- [ContentType](modules.md#contenttype)
|
|
|
|
- [ConversationJSONBody](modules.md#conversationjsonbody)
|
|
|
|
- [ConversationResponseEvent](modules.md#conversationresponseevent)
|
2023-02-14 06:31:49 +00:00
|
|
|
- [FetchFn](modules.md#fetchfn)
|
2023-02-01 10:58:25 +00:00
|
|
|
- [GetMessageByIdFunction](modules.md#getmessagebyidfunction)
|
2023-02-19 08:51:53 +00:00
|
|
|
- [Message](modules.md#message)
|
|
|
|
- [MessageActionType](modules.md#messageactiontype)
|
|
|
|
- [MessageContent](modules.md#messagecontent)
|
|
|
|
- [MessageMetadata](modules.md#messagemetadata)
|
|
|
|
- [Prompt](modules.md#prompt)
|
|
|
|
- [PromptContent](modules.md#promptcontent)
|
2022-12-05 05:13:36 +00:00
|
|
|
- [Role](modules.md#role)
|
2023-02-19 08:51:53 +00:00
|
|
|
- [SendMessageBrowserOptions](modules.md#sendmessagebrowseroptions)
|
2022-12-07 00:19:50 +00:00
|
|
|
- [SendMessageOptions](modules.md#sendmessageoptions)
|
2023-02-01 10:58:25 +00:00
|
|
|
- [UpsertMessageFunction](modules.md#upsertmessagefunction)
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
## Type Aliases
|
|
|
|
|
2023-03-02 23:25:26 +00:00
|
|
|
### ChatGPTAPIOptions
|
|
|
|
|
|
|
|
Ƭ **ChatGPTAPIOptions**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type | Description |
|
|
|
|
| :------ | :------ | :------ |
|
|
|
|
| `apiBaseUrl?` | `string` | **`Default Value`** `'https://api.openai.com'` * |
|
|
|
|
| `apiKey` | `string` | - |
|
|
|
|
| `completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"``\>\> | - |
|
|
|
|
| `debug?` | `boolean` | **`Default Value`** `false` * |
|
|
|
|
| `fetch?` | [`FetchFn`](modules.md#fetchfn) | - |
|
|
|
|
| `getMessageById?` | [`GetMessageByIdFunction`](modules.md#getmessagebyidfunction) | - |
|
|
|
|
| `maxModelTokens?` | `number` | **`Default Value`** `4096` * |
|
|
|
|
| `maxResponseTokens?` | `number` | **`Default Value`** `1000` * |
|
|
|
|
| `messageStore?` | `Keyv` | - |
|
|
|
|
| `systemMessage?` | `string` | - |
|
|
|
|
| `upsertMessage?` | [`UpsertMessageFunction`](modules.md#upsertmessagefunction) | - |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:7](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L7)
|
2023-03-02 23:25:26 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
2023-02-19 08:51:53 +00:00
|
|
|
### ContentType
|
|
|
|
|
|
|
|
Ƭ **ContentType**: ``"text"``
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:133](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L133)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### ConversationJSONBody
|
|
|
|
|
|
|
|
Ƭ **ConversationJSONBody**: `Object`
|
|
|
|
|
|
|
|
https://chat.openapi.com/backend-api/conversation
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type | Description |
|
|
|
|
| :------ | :------ | :------ |
|
|
|
|
| `action` | `string` | The action to take |
|
|
|
|
| `conversation_id?` | `string` | The ID of the conversation |
|
|
|
|
| `messages` | [`Prompt`](modules.md#prompt)[] | Prompts to provide |
|
|
|
|
| `model` | `string` | The model to use |
|
|
|
|
| `parent_message_id` | `string` | The parent message ID |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:89](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L89)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### ConversationResponseEvent
|
|
|
|
|
|
|
|
Ƭ **ConversationResponseEvent**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
|
|
|
| `conversation_id?` | `string` |
|
|
|
|
| `error?` | `string` \| ``null`` |
|
|
|
|
| `message?` | [`Message`](modules.md#message) |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:147](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L147)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
2023-02-14 06:31:49 +00:00
|
|
|
### FetchFn
|
|
|
|
|
|
|
|
Ƭ **FetchFn**: typeof `fetch`
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:5](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L5)
|
2023-02-14 06:31:49 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
### GetMessageByIdFunction
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
Ƭ **GetMessageByIdFunction**: (`id`: `string`) => `Promise`<[`ChatMessage`](interfaces/ChatMessage.md)\>
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
▸ (`id`): `Promise`<[`ChatMessage`](interfaces/ChatMessage.md)\>
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
Returns a chat message from a store by it's ID (or null if not found).
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
##### Parameters
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
|
|
|
| `id` | `string` |
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
##### Returns
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
`Promise`<[`ChatMessage`](interfaces/ChatMessage.md)\>
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:81](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L81)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### Message
|
|
|
|
|
|
|
|
Ƭ **Message**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
|
|
|
| `content` | [`MessageContent`](modules.md#messagecontent) |
|
|
|
|
| `create_time` | `string` \| ``null`` |
|
|
|
|
| `end_turn` | ``null`` |
|
|
|
|
| `id` | `string` |
|
|
|
|
| `metadata` | [`MessageMetadata`](modules.md#messagemetadata) |
|
|
|
|
| `recipient` | `string` |
|
|
|
|
| `role` | [`Role`](modules.md#role) |
|
|
|
|
| `update_time` | `string` \| ``null`` |
|
|
|
|
| `user` | `string` \| ``null`` |
|
|
|
|
| `weight` | `number` |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:153](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L153)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### MessageActionType
|
|
|
|
|
|
|
|
Ƭ **MessageActionType**: ``"next"`` \| ``"variant"``
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:47](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L47)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### MessageContent
|
|
|
|
|
|
|
|
Ƭ **MessageContent**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
|
|
|
| `content_type` | `string` |
|
|
|
|
| `parts` | `string`[] |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L166)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### MessageMetadata
|
|
|
|
|
|
|
|
Ƭ **MessageMetadata**: `any`
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:171](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L171)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### Prompt
|
|
|
|
|
|
|
|
Ƭ **Prompt**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type | Description |
|
|
|
|
| :------ | :------ | :------ |
|
|
|
|
| `content` | [`PromptContent`](modules.md#promptcontent) | The content of the prompt |
|
|
|
|
| `id` | `string` | The ID of the prompt |
|
|
|
|
| `role` | [`Role`](modules.md#role) | The role played in the prompt |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:116](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L116)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### PromptContent
|
|
|
|
|
|
|
|
Ƭ **PromptContent**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type | Description |
|
|
|
|
| :------ | :------ | :------ |
|
|
|
|
| `content_type` | [`ContentType`](modules.md#contenttype) | The content type of the prompt |
|
|
|
|
| `parts` | `string`[] | The parts to the prompt |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:135](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L135)
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### Role
|
|
|
|
|
2023-03-02 05:32:33 +00:00
|
|
|
Ƭ **Role**: ``"user"`` \| ``"assistant"`` \| ``"system"``
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L3)
|
2023-02-19 08:51:53 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### SendMessageBrowserOptions
|
|
|
|
|
|
|
|
Ƭ **SendMessageBrowserOptions**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
|
|
|
| `abortSignal?` | `AbortSignal` |
|
|
|
|
| `action?` | [`MessageActionType`](modules.md#messageactiontype) |
|
|
|
|
| `conversationId?` | `string` |
|
|
|
|
| `messageId?` | `string` |
|
|
|
|
| `onProgress?` | (`partialResponse`: [`ChatMessage`](interfaces/ChatMessage.md)) => `void` |
|
|
|
|
| `parentMessageId?` | `string` |
|
|
|
|
| `timeoutMs?` | `number` |
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:49](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L49)
|
2022-12-07 00:19:50 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
### SendMessageOptions
|
|
|
|
|
|
|
|
Ƭ **SendMessageOptions**: `Object`
|
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
2023-03-02 05:32:33 +00:00
|
|
|
| Name | Type | Description |
|
|
|
|
| :------ | :------ | :------ |
|
|
|
|
| `abortSignal?` | `AbortSignal` | - |
|
|
|
|
| `messageId?` | `string` | - |
|
|
|
|
| `name?` | `string` | The name of a user in a multi-user chat. |
|
|
|
|
| `onProgress?` | (`partialResponse`: [`ChatMessage`](interfaces/ChatMessage.md)) => `void` | - |
|
|
|
|
| `parentMessageId?` | `string` | - |
|
|
|
|
| `stream?` | `boolean` | - |
|
|
|
|
| `systemMessage?` | `string` | - |
|
|
|
|
| `timeoutMs?` | `number` | - |
|
2022-12-07 00:19:50 +00:00
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L35)
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
___
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
### UpsertMessageFunction
|
2022-12-05 05:13:36 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
Ƭ **UpsertMessageFunction**: (`message`: [`ChatMessage`](interfaces/ChatMessage.md)) => `Promise`<`void`\>
|
2022-12-05 05:13:36 +00:00
|
|
|
|
|
|
|
#### Type declaration
|
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
▸ (`message`): `Promise`<`void`\>
|
2022-12-15 23:15:38 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
Upserts a chat message to a store.
|
2022-12-15 23:15:38 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
##### Parameters
|
2022-12-15 23:15:38 +00:00
|
|
|
|
|
|
|
| Name | Type |
|
|
|
|
| :------ | :------ |
|
2023-02-01 10:58:25 +00:00
|
|
|
| `message` | [`ChatMessage`](interfaces/ChatMessage.md) |
|
2022-12-15 23:15:38 +00:00
|
|
|
|
2023-02-01 10:58:25 +00:00
|
|
|
##### Returns
|
2022-12-15 23:15:38 +00:00
|
|
|
|
|
|
|
`Promise`<`void`\>
|
|
|
|
|
|
|
|
#### Defined in
|
|
|
|
|
2023-03-11 11:08:14 +00:00
|
|
|
[src/types.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L84)
|