Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Mar 2, 2023
1 parent 1e4ddd6 commit 5c49e20
Show file tree
Hide file tree
Showing 14 changed files with 823 additions and 214 deletions.
26 changes: 10 additions & 16 deletions docs/classes/ChatGPTAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

**new ChatGPTAPI**(`opts`)

Creates a new client wrapper around OpenAI's completion API using the
unofficial ChatGPT model.
Creates a new client wrapper around OpenAI's chat completion API, mimicing the official ChatGPT webapp's functionality as closely as possible.

#### Parameters

Expand All @@ -32,21 +31,19 @@ unofficial ChatGPT model.
| `opts` | `Object` | - |
| `opts.apiBaseUrl?` | `string` | **`Default Value`** `'https://api.openai.com'` * |
| `opts.apiKey` | `string` | - |
| `opts.apiReverseProxyUrl?` | `string` | **`Default Value`** `undefined` * |
| `opts.assistantLabel?` | `string` | **`Default Value`** `'ChatGPT'` * |
| `opts.completionParams?` | `Partial`<[`CompletionParams`](../modules/openai.md#completionparams)\> | - |
| `opts.completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](../interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"``\>\> | - |
| `opts.debug?` | `boolean` | **`Default Value`** `false` * |
| `opts.fetch?` | (`input`: `RequestInfo` \| `URL`, `init?`: `RequestInit`) => `Promise`<`Response`\> | - |
| `opts.getMessageById?` | [`GetMessageByIdFunction`](../modules.md#getmessagebyidfunction) | - |
| `opts.maxModelTokens?` | `number` | **`Default Value`** `4096` * |
| `opts.maxResponseTokens?` | `number` | **`Default Value`** `1000` * |
| `opts.messageStore?` | `Keyv`<`any`, `Record`<`string`, `unknown`\>\> | - |
| `opts.systemMessage?` | `string` | - |
| `opts.upsertMessage?` | [`UpsertMessageFunction`](../modules.md#upsertmessagefunction) | - |
| `opts.userLabel?` | `string` | **`Default Value`** `'User'` * |

#### Defined in

[src/chatgpt-api.ts:53](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-api.ts#L53)
[src/chatgpt-api.ts:49](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-api.ts#L49)

## Accessors

Expand All @@ -60,7 +57,7 @@ unofficial ChatGPT model.

#### Defined in

[src/chatgpt-api.ts:353](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-api.ts#L353)
[src/chatgpt-api.ts:336](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-api.ts#L336)

`set` **apiKey**(`apiKey`): `void`

Expand All @@ -76,25 +73,22 @@ unofficial ChatGPT model.

#### Defined in

[src/chatgpt-api.ts:357](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-api.ts#L357)
[src/chatgpt-api.ts:340](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-api.ts#L340)

## Methods

### sendMessage

**sendMessage**(`text`, `opts?`): `Promise`<[`ChatMessage`](../interfaces/ChatMessage.md)\>

Sends a message to ChatGPT, waits for the response to resolve, and returns
the response.
Sends a message to the OpenAI chat completions endpoint, waits for the response
to resolve, and returns the response.

If you want your response to have historical context, you must provide a valid `parentMessageId`.

If you want to receive a stream of partial responses, use `opts.onProgress`.
If you want to receive the full response, including message and conversation IDs,
you can use `opts.onConversationResponse` or use the `ChatGPTAPI.getConversation`
helper.

Set `debug: true` in the `ChatGPTAPI` constructor to log more info on the full prompt sent to the OpenAI completions API. You can override the `promptPrefix` and `promptSuffix` in `opts` to customize the prompt.
Set `debug: true` in the `ChatGPTAPI` constructor to log more info on the full prompt sent to the OpenAI chat completions API. You can override the `systemMessage` in `opts` to customize the assistant's instructions.

#### Parameters

Expand All @@ -111,4 +105,4 @@ The response from ChatGPT

#### Defined in

[src/chatgpt-api.ts:185](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-api.ts#L185)
[src/chatgpt-api.ts:157](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-api.ts#L157)
19 changes: 4 additions & 15 deletions docs/classes/ChatGPTError.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
- [isFinal](ChatGPTError.md#isfinal)
- [statusCode](ChatGPTError.md#statuscode)
- [statusText](ChatGPTError.md#statustext)
- [type](ChatGPTError.md#type)

## Constructors

Expand Down Expand Up @@ -67,7 +66,7 @@ node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es2022.error

#### Defined in

[src/types.ts:51](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L51)
[src/types.ts:47](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L47)

___

Expand All @@ -77,7 +76,7 @@ ___

#### Defined in

[src/types.ts:50](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L50)
[src/types.ts:46](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L46)

___

Expand All @@ -87,7 +86,7 @@ ___

#### Defined in

[src/types.ts:48](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L48)
[src/types.ts:44](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L44)

___

Expand All @@ -97,14 +96,4 @@ ___

#### Defined in

[src/types.ts:49](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L49)

___

### type

`Optional` **type**: [`ChatGPTErrorType`](../modules.md#chatgpterrortype)

#### Defined in

[src/types.ts:52](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L52)
[src/types.ts:45](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L45)
8 changes: 4 additions & 4 deletions docs/classes/ChatGPTUnofficialProxyAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts:19](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-unofficial-proxy-api.ts#L19)
[src/chatgpt-unofficial-proxy-api.ts:20](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-unofficial-proxy-api.ts#L20)

## Accessors

Expand All @@ -50,7 +50,7 @@

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-unofficial-proxy-api.ts#L65)
[src/chatgpt-unofficial-proxy-api.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-unofficial-proxy-api.ts#L66)

`set` **accessToken**(`value`): `void`

Expand All @@ -66,7 +66,7 @@

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts:69](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-unofficial-proxy-api.ts#L69)
[src/chatgpt-unofficial-proxy-api.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-unofficial-proxy-api.ts#L70)

## Methods

Expand Down Expand Up @@ -101,4 +101,4 @@ The response from ChatGPT

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts:96](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/chatgpt-unofficial-proxy-api.ts#L96)
[src/chatgpt-unofficial-proxy-api.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/chatgpt-unofficial-proxy-api.ts#L97)
34 changes: 28 additions & 6 deletions docs/interfaces/ChatMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
### Properties

- [conversationId](ChatMessage.md#conversationid)
- [delta](ChatMessage.md#delta)
- [detail](ChatMessage.md#detail)
- [id](ChatMessage.md#id)
- [name](ChatMessage.md#name)
- [parentMessageId](ChatMessage.md#parentmessageid)
- [role](ChatMessage.md#role)
- [text](ChatMessage.md#text)
Expand All @@ -21,7 +23,17 @@

#### Defined in

[src/types.ts:34](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L34)
[src/types.ts:40](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L40)

___

### delta

`Optional` **delta**: `string`

#### Defined in

[src/types.ts:34](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L34)

___

Expand All @@ -31,7 +43,7 @@ ___

#### Defined in

[src/types.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L35)
[src/types.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L35)

___

Expand All @@ -41,7 +53,17 @@ ___

#### Defined in

[src/types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L30)
[src/types.ts:30](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L30)

___

### name

`Optional` **name**: `string`

#### Defined in

[src/types.ts:33](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L33)

___

Expand All @@ -51,7 +73,7 @@ ___

#### Defined in

[src/types.ts:33](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L33)
[src/types.ts:38](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L38)

___

Expand All @@ -61,7 +83,7 @@ ___

#### Defined in

[src/types.ts:32](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L32)
[src/types.ts:32](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L32)

___

Expand All @@ -71,4 +93,4 @@ ___

#### Defined in

[src/types.ts:31](https://github.com/transitive-bullshit/chatgpt-api/blob/607fccf/src/types.ts#L31)
[src/types.ts:31](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L31)
67 changes: 67 additions & 0 deletions docs/interfaces/openai.ChatCompletionRequestMessage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[chatgpt](../readme.md) / [Exports](../modules.md) / [openai](../modules/openai.md) / ChatCompletionRequestMessage

# Interface: ChatCompletionRequestMessage

[openai](../modules/openai.md).ChatCompletionRequestMessage

**`Export`**

**`Interface`**

ChatCompletionRequestMessage

## Table of contents

### Properties

- [content](openai.ChatCompletionRequestMessage.md#content)
- [name](openai.ChatCompletionRequestMessage.md#name)
- [role](openai.ChatCompletionRequestMessage.md#role)

## Properties

### content

**content**: `string`

The contents of the message

**`Memberof`**

ChatCompletionRequestMessage

#### Defined in

[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L178)

___

### name

`Optional` **name**: `string`

The name of the user in a multi-user chat

**`Memberof`**

ChatCompletionRequestMessage

#### Defined in

[src/types.ts:184](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L184)

___

### role

**role**: [`ChatCompletionRequestMessageRoleEnum`](../modules/openai.md#chatcompletionrequestmessageroleenum-1)

The role of the author of this message.

**`Memberof`**

ChatCompletionRequestMessage

#### Defined in

[src/types.ts:172](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L172)
50 changes: 50 additions & 0 deletions docs/interfaces/openai.ChatCompletionResponseMessage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[chatgpt](../readme.md) / [Exports](../modules.md) / [openai](../modules/openai.md) / ChatCompletionResponseMessage

# Interface: ChatCompletionResponseMessage

[openai](../modules/openai.md).ChatCompletionResponseMessage

**`Export`**

**`Interface`**

ChatCompletionResponseMessage

## Table of contents

### Properties

- [content](openai.ChatCompletionResponseMessage.md#content)
- [role](openai.ChatCompletionResponseMessage.md#role)

## Properties

### content

**content**: `string`

The contents of the message

**`Memberof`**

ChatCompletionResponseMessage

#### Defined in

[src/types.ts:210](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L210)

___

### role

**role**: [`ChatCompletionResponseMessageRoleEnum`](../modules/openai.md#chatcompletionresponsemessageroleenum-1)

The role of the author of this message.

**`Memberof`**

ChatCompletionResponseMessage

#### Defined in

[src/types.ts:204](https://github.com/transitive-bullshit/chatgpt-api/blob/1e4ddd6/src/types.ts#L204)
Loading

0 comments on commit 5c49e20

Please sign in to comment.