kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Porównaj commity
32 Commity
828510c1a0
...
600b35eaec
Autor | SHA1 | Data |
---|---|---|
Travis Fischer | 600b35eaec | |
Travis Fischer | bf66500730 | |
Travis Fischer | 8388017963 | |
Travis Fischer | 3f5ddc7939 | |
Travis Fischer | a720b81699 | |
Travis Fischer | a1749d0d0c | |
Travis Fischer | 07dcc5df31 | |
Travis Fischer | c0c2e716ea | |
Travis Fischer | 6c309ce365 | |
Travis Fischer | 8ad7ba9a1d | |
Travis Fischer | 3f5d8e6595 | |
Travis Fischer | 9bb7da32e4 | |
Travis Fischer | 81caf0ba11 | |
Travis Fischer | 0f966dc402 | |
Travis Fischer | db6e5941ab | |
Travis Fischer | 599e197c09 | |
Travis Fischer | c0d79e3819 | |
Travis Fischer | a3b165f7e4 | |
Travis Fischer | c5abff264e | |
Travis Fischer | bc94ed116a | |
Travis Fischer | 59b20771a9 | |
袁勇 | afa5aea5df | |
阿森 | de78787bc9 | |
阿森 | 79a9d50ec0 | |
阿森 | 52d3918255 | |
Benjamin Janssens | 507a296249 | |
Gefei Li | 4da3ea6e1f | |
Oleksii Myronenko | 7cd6e06bdd | |
Oleksii Myronenko | dd6b457932 | |
wangshangwen | fa53d8606d | |
wangshangwen | 44a4a9121e | |
Tao He | 452a61eb1b |
|
@ -31,6 +31,7 @@ async function main() {
|
|||
})
|
||||
.option('-t, --timeout <timeout>', 'Timeout in milliseconds')
|
||||
.option('-k, --apiKey <apiKey>', 'OpenAI API key')
|
||||
.option('-o, --apiOrg <apiOrg>', 'OpenAI API key')
|
||||
.option('-m, --model <model>', 'Model (gpt-3.5-turbo, gpt-4)', {
|
||||
default: 'gpt-3.5-turbo'
|
||||
})
|
||||
|
@ -39,6 +40,7 @@ async function main() {
|
|||
'Unique name for the conversation'
|
||||
)
|
||||
.action(async (prompt, options) => {
|
||||
const apiOrg = options.apiOrg || process.env.OPENAI_API_ORG
|
||||
const apiKey = options.apiKey || process.env.OPENAI_API_KEY
|
||||
if (!apiKey) {
|
||||
console.error('error: either set OPENAI_API_KEY or use --apiKey\n')
|
||||
|
@ -71,6 +73,7 @@ async function main() {
|
|||
|
||||
const api = new ChatGPTAPI({
|
||||
apiKey,
|
||||
apiOrg,
|
||||
debug: options.debug,
|
||||
completionParams: {
|
||||
model
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
### Accessors
|
||||
|
||||
- [apiKey](ChatGPTAPI.md#apikey)
|
||||
- [apiOrg](ChatGPTAPI.md#apiorg)
|
||||
|
||||
### Methods
|
||||
|
||||
|
@ -32,7 +33,7 @@ Creates a new client wrapper around OpenAI's chat completion API, mimicing the o
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:49](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L49)
|
||||
[src/chatgpt-api.ts:51](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L51)
|
||||
|
||||
## Accessors
|
||||
|
||||
|
@ -46,7 +47,7 @@ Creates a new client wrapper around OpenAI's chat completion API, mimicing the o
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:311](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L311)
|
||||
[src/chatgpt-api.ts:345](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L345)
|
||||
|
||||
• `set` **apiKey**(`apiKey`): `void`
|
||||
|
||||
|
@ -62,7 +63,37 @@ Creates a new client wrapper around OpenAI's chat completion API, mimicing the o
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:315](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L315)
|
||||
[src/chatgpt-api.ts:349](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L349)
|
||||
|
||||
___
|
||||
|
||||
### apiOrg
|
||||
|
||||
• `get` **apiOrg**(): `string`
|
||||
|
||||
#### Returns
|
||||
|
||||
`string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:353](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L353)
|
||||
|
||||
• `set` **apiOrg**(`apiOrg`): `void`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `apiOrg` | `string` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`void`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:357](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L357)
|
||||
|
||||
## Methods
|
||||
|
||||
|
@ -94,4 +125,4 @@ The response from ChatGPT
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-api.ts:132](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L132)
|
||||
[src/chatgpt-api.ts:137](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-api.ts#L137)
|
||||
|
|
|
@ -39,7 +39,7 @@ Error.constructor
|
|||
|
||||
#### Defined in
|
||||
|
||||
node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/lib.es5.d.ts:1059
|
||||
node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es5.d.ts:1060
|
||||
|
||||
• **new ChatGPTError**(`message?`, `options?`)
|
||||
|
||||
|
@ -56,7 +56,7 @@ Error.constructor
|
|||
|
||||
#### Defined in
|
||||
|
||||
node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/lib.es2022.error.d.ts:30
|
||||
node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:28
|
||||
|
||||
## Properties
|
||||
|
||||
|
@ -66,7 +66,7 @@ node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib/lib.es2022.error
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:80](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L80)
|
||||
[src/types.ts:86](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L86)
|
||||
|
||||
___
|
||||
|
||||
|
@ -76,7 +76,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:79](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L79)
|
||||
[src/types.ts:85](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L85)
|
||||
|
||||
___
|
||||
|
||||
|
@ -86,7 +86,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:77](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L77)
|
||||
[src/types.ts:83](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L83)
|
||||
|
||||
___
|
||||
|
||||
|
@ -96,4 +96,4 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:78](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L78)
|
||||
[src/types.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L84)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-unofficial-proxy-api.ts:20](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L20)
|
||||
[src/chatgpt-unofficial-proxy-api.ts:20](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-unofficial-proxy-api.ts#L20)
|
||||
|
||||
## Accessors
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-unofficial-proxy-api.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L66)
|
||||
[src/chatgpt-unofficial-proxy-api.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-unofficial-proxy-api.ts#L66)
|
||||
|
||||
• `set` **accessToken**(`value`): `void`
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-unofficial-proxy-api.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L70)
|
||||
[src/chatgpt-unofficial-proxy-api.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-unofficial-proxy-api.ts#L70)
|
||||
|
||||
## Methods
|
||||
|
||||
|
@ -101,4 +101,4 @@ The response from ChatGPT
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/chatgpt-unofficial-proxy-api.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L97)
|
||||
[src/chatgpt-unofficial-proxy-api.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/chatgpt-unofficial-proxy-api.ts#L97)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:73](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L73)
|
||||
[src/types.ts:79](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L79)
|
||||
|
||||
___
|
||||
|
||||
|
@ -33,17 +33,17 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:67](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L67)
|
||||
[src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L70)
|
||||
|
||||
___
|
||||
|
||||
### detail
|
||||
|
||||
• `Optional` **detail**: `any`
|
||||
• `Optional` **detail**: [`CreateChatCompletionResponse`](openai.CreateChatCompletionResponse.md) \| [`CreateChatCompletionStreamResponse`](CreateChatCompletionStreamResponse.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:68](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L68)
|
||||
[src/types.ts:71](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L71)
|
||||
|
||||
___
|
||||
|
||||
|
@ -53,7 +53,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:63](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L63)
|
||||
[src/types.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
|
@ -63,7 +63,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L66)
|
||||
[src/types.ts:69](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L69)
|
||||
|
||||
___
|
||||
|
||||
|
@ -73,7 +73,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:71](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L71)
|
||||
[src/types.ts:76](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L76)
|
||||
|
||||
___
|
||||
|
||||
|
@ -83,7 +83,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L65)
|
||||
[src/types.ts:68](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
|
@ -93,4 +93,4 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:64](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L64)
|
||||
[src/types.ts:67](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L67)
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
[chatgpt](../readme.md) / [Exports](../modules.md) / CreateChatCompletionStreamResponse
|
||||
|
||||
# Interface: CreateChatCompletionStreamResponse
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- [`CreateChatCompletionDeltaResponse`](openai.CreateChatCompletionDeltaResponse.md)
|
||||
|
||||
↳ **`CreateChatCompletionStreamResponse`**
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [choices](CreateChatCompletionStreamResponse.md#choices)
|
||||
- [created](CreateChatCompletionStreamResponse.md#created)
|
||||
- [id](CreateChatCompletionStreamResponse.md#id)
|
||||
- [model](CreateChatCompletionStreamResponse.md#model)
|
||||
- [object](CreateChatCompletionStreamResponse.md#object)
|
||||
- [usage](CreateChatCompletionStreamResponse.md#usage)
|
||||
|
||||
## Properties
|
||||
|
||||
### choices
|
||||
|
||||
• **choices**: [{ `delta`: { `content?`: `string` ; `role`: [`Role`](../modules.md#role) } ; `finish_reason`: `string` ; `index`: `number` }]
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateChatCompletionDeltaResponse](openai.CreateChatCompletionDeltaResponse.md).[choices](openai.CreateChatCompletionDeltaResponse.md#choices)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:198](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L198)
|
||||
|
||||
___
|
||||
|
||||
### created
|
||||
|
||||
• **created**: `number`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateChatCompletionDeltaResponse](openai.CreateChatCompletionDeltaResponse.md).[created](openai.CreateChatCompletionDeltaResponse.md#created)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:196](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L196)
|
||||
|
||||
___
|
||||
|
||||
### id
|
||||
|
||||
• **id**: `string`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateChatCompletionDeltaResponse](openai.CreateChatCompletionDeltaResponse.md).[id](openai.CreateChatCompletionDeltaResponse.md#id)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:194](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L194)
|
||||
|
||||
___
|
||||
|
||||
### model
|
||||
|
||||
• **model**: `string`
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateChatCompletionDeltaResponse](openai.CreateChatCompletionDeltaResponse.md).[model](openai.CreateChatCompletionDeltaResponse.md#model)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:197](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L197)
|
||||
|
||||
___
|
||||
|
||||
### object
|
||||
|
||||
• **object**: ``"chat.completion.chunk"``
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateChatCompletionDeltaResponse](openai.CreateChatCompletionDeltaResponse.md).[object](openai.CreateChatCompletionDeltaResponse.md#object)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:195](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L195)
|
||||
|
||||
___
|
||||
|
||||
### usage
|
||||
|
||||
• **usage**: [`CreateCompletionStreamResponseUsage`](CreateCompletionStreamResponseUsage.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L97)
|
|
@ -0,0 +1,88 @@
|
|||
[chatgpt](../readme.md) / [Exports](../modules.md) / CreateCompletionStreamResponseUsage
|
||||
|
||||
# Interface: CreateCompletionStreamResponseUsage
|
||||
|
||||
**`Export`**
|
||||
|
||||
**`Interface`**
|
||||
|
||||
CreateCompletionResponseUsage
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- [`CreateCompletionResponseUsage`](openai.CreateCompletionResponseUsage.md)
|
||||
|
||||
↳ **`CreateCompletionStreamResponseUsage`**
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
||||
- [completion\_tokens](CreateCompletionStreamResponseUsage.md#completion_tokens)
|
||||
- [estimated](CreateCompletionStreamResponseUsage.md#estimated)
|
||||
- [prompt\_tokens](CreateCompletionStreamResponseUsage.md#prompt_tokens)
|
||||
- [total\_tokens](CreateCompletionStreamResponseUsage.md#total_tokens)
|
||||
|
||||
## Properties
|
||||
|
||||
### completion\_tokens
|
||||
|
||||
• **completion\_tokens**: `number`
|
||||
|
||||
**`Memberof`**
|
||||
|
||||
CreateCompletionResponseUsage
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateCompletionResponseUsage](openai.CreateCompletionResponseUsage.md).[completion_tokens](openai.CreateCompletionResponseUsage.md#completion_tokens)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:438](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L438)
|
||||
|
||||
___
|
||||
|
||||
### estimated
|
||||
|
||||
• **estimated**: ``true``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:102](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L102)
|
||||
|
||||
___
|
||||
|
||||
### prompt\_tokens
|
||||
|
||||
• **prompt\_tokens**: `number`
|
||||
|
||||
**`Memberof`**
|
||||
|
||||
CreateCompletionResponseUsage
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateCompletionResponseUsage](openai.CreateCompletionResponseUsage.md).[prompt_tokens](openai.CreateCompletionResponseUsage.md#prompt_tokens)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:432](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L432)
|
||||
|
||||
___
|
||||
|
||||
### total\_tokens
|
||||
|
||||
• **total\_tokens**: `number`
|
||||
|
||||
**`Memberof`**
|
||||
|
||||
CreateCompletionResponseUsage
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[CreateCompletionResponseUsage](openai.CreateCompletionResponseUsage.md).[total_tokens](openai.CreateCompletionResponseUsage.md#total_tokens)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:444](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L444)
|
|
@ -32,7 +32,7 @@ ChatCompletionRequestMessage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:211](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L211)
|
||||
[src/types.ts:227](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L227)
|
||||
|
||||
___
|
||||
|
||||
|
@ -48,7 +48,7 @@ ChatCompletionRequestMessage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:217](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L217)
|
||||
[src/types.ts:233](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L233)
|
||||
|
||||
___
|
||||
|
||||
|
@ -64,4 +64,4 @@ ChatCompletionRequestMessage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:205](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L205)
|
||||
[src/types.ts:221](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L221)
|
||||
|
|
|
@ -31,7 +31,7 @@ ChatCompletionResponseMessage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:243](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L243)
|
||||
[src/types.ts:259](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L259)
|
||||
|
||||
___
|
||||
|
||||
|
@ -47,4 +47,4 @@ ChatCompletionResponseMessage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:237](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L237)
|
||||
[src/types.ts:253](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L253)
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
[openai](../modules/openai.md).CreateChatCompletionDeltaResponse
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- **`CreateChatCompletionDeltaResponse`**
|
||||
|
||||
↳ [`CreateChatCompletionStreamResponse`](CreateChatCompletionStreamResponse.md)
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
@ -22,7 +28,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:182](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L182)
|
||||
[src/types.ts:198](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L198)
|
||||
|
||||
___
|
||||
|
||||
|
@ -32,7 +38,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:180](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L180)
|
||||
[src/types.ts:196](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L196)
|
||||
|
||||
___
|
||||
|
||||
|
@ -42,7 +48,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L178)
|
||||
[src/types.ts:194](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L194)
|
||||
|
||||
___
|
||||
|
||||
|
@ -52,7 +58,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:181](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L181)
|
||||
[src/types.ts:197](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L197)
|
||||
|
||||
___
|
||||
|
||||
|
@ -62,4 +68,4 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:179](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L179)
|
||||
[src/types.ts:195](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L195)
|
||||
|
|
|
@ -41,7 +41,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:317](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L317)
|
||||
[src/types.ts:333](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L333)
|
||||
|
||||
___
|
||||
|
||||
|
@ -57,7 +57,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:323](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L323)
|
||||
[src/types.ts:339](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L339)
|
||||
|
||||
___
|
||||
|
||||
|
@ -73,7 +73,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:305](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L305)
|
||||
[src/types.ts:321](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L321)
|
||||
|
||||
___
|
||||
|
||||
|
@ -89,7 +89,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:269](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L269)
|
||||
[src/types.ts:285](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L285)
|
||||
|
||||
___
|
||||
|
||||
|
@ -105,7 +105,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:263](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L263)
|
||||
[src/types.ts:279](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L279)
|
||||
|
||||
___
|
||||
|
||||
|
@ -121,7 +121,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:287](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L287)
|
||||
[src/types.ts:303](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L303)
|
||||
|
||||
___
|
||||
|
||||
|
@ -137,7 +137,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:311](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L311)
|
||||
[src/types.ts:327](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L327)
|
||||
|
||||
___
|
||||
|
||||
|
@ -151,7 +151,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:299](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L299)
|
||||
[src/types.ts:315](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L315)
|
||||
|
||||
___
|
||||
|
||||
|
@ -167,7 +167,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:293](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L293)
|
||||
[src/types.ts:309](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L309)
|
||||
|
||||
___
|
||||
|
||||
|
@ -183,7 +183,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L275)
|
||||
[src/types.ts:291](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L291)
|
||||
|
||||
___
|
||||
|
||||
|
@ -199,7 +199,7 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:281](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L281)
|
||||
[src/types.ts:297](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L297)
|
||||
|
||||
___
|
||||
|
||||
|
@ -215,4 +215,4 @@ CreateChatCompletionRequest
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:329](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L329)
|
||||
[src/types.ts:345](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L345)
|
||||
|
|
|
@ -33,7 +33,7 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:372](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L372)
|
||||
[src/types.ts:388](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L388)
|
||||
|
||||
___
|
||||
|
||||
|
@ -47,7 +47,7 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:360](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L360)
|
||||
[src/types.ts:376](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L376)
|
||||
|
||||
___
|
||||
|
||||
|
@ -61,7 +61,7 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:348](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L348)
|
||||
[src/types.ts:364](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L364)
|
||||
|
||||
___
|
||||
|
||||
|
@ -75,7 +75,7 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:366](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L366)
|
||||
[src/types.ts:382](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L382)
|
||||
|
||||
___
|
||||
|
||||
|
@ -89,7 +89,7 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:354](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L354)
|
||||
[src/types.ts:370](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L370)
|
||||
|
||||
___
|
||||
|
||||
|
@ -103,4 +103,4 @@ CreateChatCompletionResponse
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:378](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L378)
|
||||
[src/types.ts:394](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L394)
|
||||
|
|
|
@ -30,7 +30,7 @@ CreateChatCompletionResponseChoicesInner
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:403](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L403)
|
||||
[src/types.ts:419](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L419)
|
||||
|
||||
___
|
||||
|
||||
|
@ -44,7 +44,7 @@ CreateChatCompletionResponseChoicesInner
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:391](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L391)
|
||||
[src/types.ts:407](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L407)
|
||||
|
||||
___
|
||||
|
||||
|
@ -58,4 +58,4 @@ CreateChatCompletionResponseChoicesInner
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:397](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L397)
|
||||
[src/types.ts:413](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L413)
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
|
||||
CreateCompletionResponseUsage
|
||||
|
||||
## Hierarchy
|
||||
|
||||
- **`CreateCompletionResponseUsage`**
|
||||
|
||||
↳ [`CreateCompletionStreamResponseUsage`](CreateCompletionStreamResponseUsage.md)
|
||||
|
||||
## Table of contents
|
||||
|
||||
### Properties
|
||||
|
@ -30,7 +36,7 @@ CreateCompletionResponseUsage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:422](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L422)
|
||||
[src/types.ts:438](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L438)
|
||||
|
||||
___
|
||||
|
||||
|
@ -44,7 +50,7 @@ CreateCompletionResponseUsage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:416](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L416)
|
||||
[src/types.ts:432](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L432)
|
||||
|
||||
___
|
||||
|
||||
|
@ -58,4 +64,4 @@ CreateCompletionResponseUsage
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:428](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L428)
|
||||
[src/types.ts:444](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L444)
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
### Interfaces
|
||||
|
||||
- [ChatMessage](interfaces/ChatMessage.md)
|
||||
- [CreateChatCompletionStreamResponse](interfaces/CreateChatCompletionStreamResponse.md)
|
||||
- [CreateCompletionStreamResponseUsage](interfaces/CreateCompletionStreamResponseUsage.md)
|
||||
|
||||
### Type Aliases
|
||||
|
||||
|
@ -49,6 +51,7 @@
|
|||
| :------ | :------ | :------ |
|
||||
| `apiBaseUrl?` | `string` | **`Default Value`** `'https://api.openai.com'` * |
|
||||
| `apiKey` | `string` | - |
|
||||
| `apiOrg?` | `string` | - |
|
||||
| `completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"`` \| ``"stream"``\>\> | - |
|
||||
| `debug?` | `boolean` | **`Default Value`** `false` * |
|
||||
| `fetch?` | [`FetchFn`](modules.md#fetchfn) | - |
|
||||
|
@ -61,7 +64,7 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:7](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L7)
|
||||
[src/types.ts:7](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L7)
|
||||
|
||||
___
|
||||
|
||||
|
@ -71,7 +74,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:136](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L136)
|
||||
[src/types.ts:152](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L152)
|
||||
|
||||
___
|
||||
|
||||
|
@ -93,7 +96,7 @@ https://chat.openapi.com/backend-api/conversation
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:92](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L92)
|
||||
[src/types.ts:108](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
|
@ -111,7 +114,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:150](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L150)
|
||||
[src/types.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L166)
|
||||
|
||||
___
|
||||
|
||||
|
@ -121,7 +124,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:5](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L5)
|
||||
[src/types.ts:5](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L5)
|
||||
|
||||
___
|
||||
|
||||
|
@ -147,7 +150,7 @@ Returns a chat message from a store by it's ID (or null if not found).
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L84)
|
||||
[src/types.ts:90](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L90)
|
||||
|
||||
___
|
||||
|
||||
|
@ -172,7 +175,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:156](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L156)
|
||||
[src/types.ts:172](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L172)
|
||||
|
||||
___
|
||||
|
||||
|
@ -182,7 +185,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:50](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L50)
|
||||
[src/types.ts:53](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
|
@ -199,7 +202,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:169](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L169)
|
||||
[src/types.ts:185](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L185)
|
||||
|
||||
___
|
||||
|
||||
|
@ -209,7 +212,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:174](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L174)
|
||||
[src/types.ts:190](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L190)
|
||||
|
||||
___
|
||||
|
||||
|
@ -227,7 +230,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:119](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L119)
|
||||
[src/types.ts:135](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L135)
|
||||
|
||||
___
|
||||
|
||||
|
@ -244,7 +247,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:138](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L138)
|
||||
[src/types.ts:154](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L154)
|
||||
|
||||
___
|
||||
|
||||
|
@ -254,7 +257,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L3)
|
||||
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L3)
|
||||
|
||||
___
|
||||
|
||||
|
@ -276,7 +279,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:52](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L52)
|
||||
[src/types.ts:55](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
|
@ -290,6 +293,7 @@ ___
|
|||
| :------ | :------ | :------ |
|
||||
| `abortSignal?` | `AbortSignal` | - |
|
||||
| `completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"`` \| ``"stream"``\>\> | - |
|
||||
| `conversationId?` | `string` | - |
|
||||
| `messageId?` | `string` | - |
|
||||
| `name?` | `string` | The name of a user in a multi-user chat. |
|
||||
| `onProgress?` | (`partialResponse`: [`ChatMessage`](interfaces/ChatMessage.md)) => `void` | - |
|
||||
|
@ -300,7 +304,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L35)
|
||||
[src/types.ts:37](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
|
@ -326,4 +330,4 @@ Upserts a chat message to a store.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:87](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L87)
|
||||
[src/types.ts:93](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L93)
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:219](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L219)
|
||||
[src/types.ts:235](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L235)
|
||||
|
||||
[src/types.ts:224](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L224)
|
||||
[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L240)
|
||||
|
||||
___
|
||||
|
||||
|
@ -45,9 +45,9 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:245](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L245)
|
||||
[src/types.ts:261](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L261)
|
||||
|
||||
[src/types.ts:250](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L250)
|
||||
[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L266)
|
||||
|
||||
___
|
||||
|
||||
|
@ -59,7 +59,7 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:336](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L336)
|
||||
[src/types.ts:352](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L352)
|
||||
|
||||
## Variables
|
||||
|
||||
|
@ -77,9 +77,9 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:219](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L219)
|
||||
[src/types.ts:235](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L235)
|
||||
|
||||
[src/types.ts:224](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L224)
|
||||
[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L240)
|
||||
|
||||
___
|
||||
|
||||
|
@ -97,6 +97,6 @@ ___
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/types.ts:245](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L245)
|
||||
[src/types.ts:261](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L261)
|
||||
|
||||
[src/types.ts:250](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L250)
|
||||
[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/bf66500/src/types.ts#L266)
|
||||
|
|
|
@ -152,6 +152,7 @@ Options:
|
|||
-s, --store Enables the local message cache (default: true)
|
||||
-t, --timeout Timeout in milliseconds
|
||||
-k, --apiKey OpenAI API key
|
||||
-o, --apiOrg OpenAI API organization
|
||||
-n, --conversationName Unique name for the conversation
|
||||
-h, --help Display this message
|
||||
-v, --version Display version number
|
||||
|
@ -282,8 +283,11 @@ Note that we automatically handle appending the previous messages to the prompt
|
|||
|
||||
```js
|
||||
async function example() {
|
||||
// To use ESM in CommonJS, you can use a dynamic import
|
||||
// To use ESM in CommonJS, you can use a dynamic import like this:
|
||||
const { ChatGPTAPI } = await import('chatgpt')
|
||||
// You can also try dynamic importing like this:
|
||||
// const importDynamic = new Function('modulePath', 'return import(modulePath)')
|
||||
// const { ChatGPTAPI } = await importDynamic('chatgpt')
|
||||
|
||||
const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })
|
||||
|
||||
|
@ -443,6 +447,7 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [WeChat Bot #4](https://github.com/darknightlab/wechat-bot)
|
||||
- [WeChat Bot #5](https://github.com/sunshanpeng/wechaty-chatgpt)
|
||||
- [WeChat Bot #6](https://github.com/formulahendry/chatgpt-wechat-bot)
|
||||
- [WeChat Bot #7](https://github.com/gfl94/Chatbot004)
|
||||
- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)
|
||||
- [QQ Bot (plugin for KiviBot)](https://github.com/KiviBotLab/kivibot-plugin-chatgpt)
|
||||
- [QQ Bot (oicq)](https://github.com/easydu2002/chat_gpt_oicq)
|
||||
|
@ -470,6 +475,8 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [Slack Bot #2](https://github.com/lokwkin/chatgpt-slackbot-node/) (with queueing mechanism)
|
||||
- [Slack Bot #3](https://github.com/NessunKim/slack-chatgpt/)
|
||||
- [Slack Bot #4](https://github.com/MarkusGalant/chatgpt-slackbot-serverless/) ( Serverless AWS Lambda )
|
||||
- [Slack Bot #5](https://github.com/benjiJanssens/SlackGPT) (Hosted)
|
||||
- [Add to Slack](https://slackgpt.benji.sh/slack/install)
|
||||
- [Electron Bot](https://github.com/ShiranAbir/chaty)
|
||||
- [Kodyfire CLI](https://github.com/nooqta/chatgpt-kodyfire)
|
||||
- [Twitch Bot](https://github.com/BennyDeeDev/chatgpt-twitch-bot)
|
||||
|
@ -489,7 +496,8 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [ai-commit – GPT-3 Commit Message Generator](https://github.com/insulineru/ai-commit)
|
||||
- [AItinerary – ChatGPT itinerary Generator](https://aitinerary.ai)
|
||||
- [wechaty-chatgpt - A chatbot based on Wechaty & ChatGPT](https://github.com/zhengxs2018/wechaty-chatgpt)
|
||||
- [Julius GPT](https://github.com/christophebe/julius-gpt) : Generate and publish your content from the command line with the help of AI (GPT).
|
||||
- [Julius GPT](https://github.com/christophebe/julius-gpt) - Generate and publish your content from the CLI
|
||||
- [OpenAI-API-Service](https://github.com/Jarvan-via/api-service) - Provides OpenAI related APIs for businesses
|
||||
|
||||
If you create a cool integration, feel free to open a PR and add it to the list.
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "chatgpt",
|
||||
"version": "5.1.4",
|
||||
"version": "5.2.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "chatgpt",
|
||||
"version": "5.1.4",
|
||||
"version": "5.2.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^0.4.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "chatgpt",
|
||||
"version": "5.1.4",
|
||||
"version": "5.2.2",
|
||||
"description": "Node.js client for the official ChatGPT API.",
|
||||
"author": "Travis Fischer <travis@transitivebullsh.it>",
|
||||
"repository": "transitive-bullshit/chatgpt-api",
|
||||
|
@ -40,7 +40,7 @@
|
|||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"cac": "^6.7.14",
|
||||
"conf": "^11.0.1",
|
||||
"eventsource-parser": "^0.0.5",
|
||||
"eventsource-parser": "^1.0.0",
|
||||
"keyv": "^4.5.2",
|
||||
"p-timeout": "^6.1.1",
|
||||
"quick-lru": "^6.1.1",
|
||||
|
@ -50,7 +50,7 @@
|
|||
"devDependencies": {
|
||||
"@keyv/redis": "^2.5.6",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
||||
"@types/node": "^18.15.10",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/uuid": "^9.0.1",
|
||||
"del-cli": "^5.0.0",
|
||||
"dotenv-safe": "^8.2.0",
|
||||
|
@ -63,7 +63,7 @@
|
|||
"tsx": "^3.12.6",
|
||||
"typedoc": "^0.23.28",
|
||||
"typedoc-plugin-markdown": "^3.14.0",
|
||||
"typescript": "^4.9.5"
|
||||
"typescript": "^5.0.3"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx}": [
|
||||
|
|
1129
pnpm-lock.yaml
1129
pnpm-lock.yaml
Plik diff jest za duży
Load Diff
|
@ -150,6 +150,7 @@ Options:
|
|||
-s, --store Enables the local message cache (default: true)
|
||||
-t, --timeout Timeout in milliseconds
|
||||
-k, --apiKey OpenAI API key
|
||||
-o, --apiOrg OpenAI API organization
|
||||
-n, --conversationName Unique name for the conversation
|
||||
-h, --help Display this message
|
||||
-v, --version Display version number
|
||||
|
@ -444,6 +445,7 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [WeChat Bot #4](https://github.com/darknightlab/wechat-bot)
|
||||
- [WeChat Bot #5](https://github.com/sunshanpeng/wechaty-chatgpt)
|
||||
- [WeChat Bot #6](https://github.com/formulahendry/chatgpt-wechat-bot)
|
||||
- [WeChat Bot #7](https://github.com/gfl94/Chatbot004)
|
||||
- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)
|
||||
- [QQ Bot (plugin for KiviBot)](https://github.com/KiviBotLab/kivibot-plugin-chatgpt)
|
||||
- [QQ Bot (oicq)](https://github.com/easydu2002/chat_gpt_oicq)
|
||||
|
@ -471,6 +473,8 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [Slack Bot #2](https://github.com/lokwkin/chatgpt-slackbot-node/) (with queueing mechanism)
|
||||
- [Slack Bot #3](https://github.com/NessunKim/slack-chatgpt/)
|
||||
- [Slack Bot #4](https://github.com/MarkusGalant/chatgpt-slackbot-serverless/) ( Serverless AWS Lambda )
|
||||
- [Slack Bot #5](https://github.com/benjiJanssens/SlackGPT) (Hosted)
|
||||
- [Add to Slack](https://slackgpt.benji.sh/slack/install)
|
||||
- [Electron Bot](https://github.com/ShiranAbir/chaty)
|
||||
- [Kodyfire CLI](https://github.com/nooqta/chatgpt-kodyfire)
|
||||
- [Twitch Bot](https://github.com/BennyDeeDev/chatgpt-twitch-bot)
|
||||
|
@ -490,7 +494,8 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
|
|||
- [ai-commit – GPT-3 Commit Message Generator](https://github.com/insulineru/ai-commit)
|
||||
- [AItinerary – ChatGPT itinerary Generator](https://aitinerary.ai)
|
||||
- [wechaty-chatgpt - A chatbot based on Wechaty & ChatGPT](https://github.com/zhengxs2018/wechaty-chatgpt)
|
||||
- [Julius GPT](https://github.com/christophebe/julius-gpt) : Generate and publish your content from the command line with the help of AI (GPT).
|
||||
- [Julius GPT](https://github.com/christophebe/julius-gpt) - Generate and publish your content from the CLI
|
||||
- [OpenAI-API-Service](https://github.com/Jarvan-via/api-service) - Provides OpenAI related APIs for businesses
|
||||
|
||||
If you create a cool integration, feel free to open a PR and add it to the list.
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ const ASSISTANT_LABEL_DEFAULT = 'ChatGPT'
|
|||
export class ChatGPTAPI {
|
||||
protected _apiKey: string
|
||||
protected _apiBaseUrl: string
|
||||
protected _apiOrg?: string
|
||||
protected _debug: boolean
|
||||
|
||||
protected _systemMessage: string
|
||||
|
@ -36,6 +37,7 @@ export class ChatGPTAPI {
|
|||
* Creates a new client wrapper around OpenAI's chat completion API, mimicing the official ChatGPT webapp's functionality as closely as possible.
|
||||
*
|
||||
* @param apiKey - OpenAI API key (required).
|
||||
* @param apiOrg - Optional OpenAI API organization (optional).
|
||||
* @param apiBaseUrl - Optional override for the OpenAI API base URL.
|
||||
* @param debug - Optional enables logging debugging info to stdout.
|
||||
* @param completionParams - Param overrides to send to the [OpenAI chat completion API](https://platform.openai.com/docs/api-reference/chat/create). Options like `temperature` and `presence_penalty` can be tweaked to change the personality of the assistant.
|
||||
|
@ -49,6 +51,7 @@ export class ChatGPTAPI {
|
|||
constructor(opts: types.ChatGPTAPIOptions) {
|
||||
const {
|
||||
apiKey,
|
||||
apiOrg,
|
||||
apiBaseUrl = 'https://api.openai.com/v1',
|
||||
debug = false,
|
||||
messageStore,
|
||||
|
@ -62,6 +65,7 @@ export class ChatGPTAPI {
|
|||
} = opts
|
||||
|
||||
this._apiKey = apiKey
|
||||
this._apiOrg = apiOrg
|
||||
this._apiBaseUrl = apiBaseUrl
|
||||
this._debug = !!debug
|
||||
this._fetch = fetch
|
||||
|
@ -120,6 +124,7 @@ export class ChatGPTAPI {
|
|||
*
|
||||
* @param message - The prompt message to send
|
||||
* @param opts.parentMessageId - Optional ID of the previous message in the conversation (defaults to `undefined`)
|
||||
* @param opts.conversationId - Optional ID of the conversation (defaults to `undefined`)
|
||||
* @param opts.messageId - Optional ID of the message to send (defaults to a random UUID)
|
||||
* @param opts.systemMessage - Optional override for the chat "system message" which acts as instructions to the model (defaults to the ChatGPT system message)
|
||||
* @param opts.timeoutMs - Optional timeout in milliseconds (defaults to no timeout)
|
||||
|
@ -139,7 +144,8 @@ export class ChatGPTAPI {
|
|||
timeoutMs,
|
||||
onProgress,
|
||||
stream = onProgress ? true : false,
|
||||
completionParams
|
||||
completionParams,
|
||||
conversationId
|
||||
} = opts
|
||||
|
||||
let { abortSignal } = opts
|
||||
|
@ -153,10 +159,12 @@ export class ChatGPTAPI {
|
|||
const message: types.ChatMessage = {
|
||||
role: 'user',
|
||||
id: messageId,
|
||||
conversationId,
|
||||
parentMessageId,
|
||||
text
|
||||
}
|
||||
await this._upsertMessage(message)
|
||||
|
||||
const latestQuestion = message
|
||||
|
||||
const { messages, maxTokens, numTokens } = await this._buildMessages(
|
||||
text,
|
||||
|
@ -166,6 +174,7 @@ export class ChatGPTAPI {
|
|||
const result: types.ChatMessage = {
|
||||
role: 'assistant',
|
||||
id: uuidv4(),
|
||||
conversationId,
|
||||
parentMessageId: messageId,
|
||||
text: ''
|
||||
}
|
||||
|
@ -185,6 +194,12 @@ export class ChatGPTAPI {
|
|||
stream
|
||||
}
|
||||
|
||||
// Support multiple organizations
|
||||
// See https://platform.openai.com/docs/api-reference/authentication
|
||||
if (this._apiOrg) {
|
||||
headers['OpenAI-Organization'] = this._apiOrg
|
||||
}
|
||||
|
||||
if (this._debug) {
|
||||
console.log(`sendMessage (${numTokens} tokens)`, body)
|
||||
}
|
||||
|
@ -211,16 +226,16 @@ export class ChatGPTAPI {
|
|||
result.id = response.id
|
||||
}
|
||||
|
||||
if (response?.choices?.length) {
|
||||
if (response.choices?.length) {
|
||||
const delta = response.choices[0].delta
|
||||
result.delta = delta.content
|
||||
if (delta?.content) result.text += delta.content
|
||||
result.detail = response
|
||||
|
||||
if (delta.role) {
|
||||
result.role = delta.role
|
||||
}
|
||||
|
||||
result.detail = response
|
||||
onProgress?.(result)
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -286,8 +301,27 @@ export class ChatGPTAPI {
|
|||
}
|
||||
}
|
||||
}
|
||||
).then((message) => {
|
||||
return this._upsertMessage(message).then(() => message)
|
||||
).then(async (message) => {
|
||||
if (message.detail && !message.detail.usage) {
|
||||
try {
|
||||
const promptTokens = numTokens
|
||||
const completionTokens = await this._getTokenCount(message.text)
|
||||
message.detail.usage = {
|
||||
prompt_tokens: promptTokens,
|
||||
completion_tokens: completionTokens,
|
||||
total_tokens: promptTokens + completionTokens,
|
||||
estimated: true
|
||||
}
|
||||
} catch (err) {
|
||||
// TODO: this should really never happen, but if it does,
|
||||
// we should handle notify the user gracefully
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
this._upsertMessage(latestQuestion),
|
||||
this._upsertMessage(message)
|
||||
]).then(() => message)
|
||||
})
|
||||
|
||||
if (timeoutMs) {
|
||||
|
@ -316,6 +350,14 @@ export class ChatGPTAPI {
|
|||
this._apiKey = apiKey
|
||||
}
|
||||
|
||||
get apiOrg(): string {
|
||||
return this._apiOrg
|
||||
}
|
||||
|
||||
set apiOrg(apiOrg: string) {
|
||||
this._apiOrg = apiOrg
|
||||
}
|
||||
|
||||
protected async _buildMessages(text: string, opts: types.SendMessageOptions) {
|
||||
const { systemMessage = this._systemMessage } = opts
|
||||
let { parentMessageId } = opts
|
||||
|
|
|
@ -218,9 +218,11 @@ export class ChatGPTUnofficialProxyAPI {
|
|||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore for now; there seem to be some non-json messages
|
||||
// console.warn('fetchSSE onMessage unexpected error', err)
|
||||
reject(err)
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
reject(err)
|
||||
}
|
||||
},
|
||||
this._fetch
|
||||
|
|
|
@ -6,10 +6,13 @@ import { streamAsyncIterable } from './stream-async-iterable'
|
|||
|
||||
export async function fetchSSE(
|
||||
url: string,
|
||||
options: Parameters<typeof fetch>[1] & { onMessage: (data: string) => void },
|
||||
options: Parameters<typeof fetch>[1] & {
|
||||
onMessage: (data: string) => void
|
||||
onError?: (error: any) => void
|
||||
},
|
||||
fetch: types.FetchFn = globalFetch
|
||||
) {
|
||||
const { onMessage, ...fetchOptions } = options
|
||||
const { onMessage, onError, ...fetchOptions } = options
|
||||
const res = await fetch(url, fetchOptions)
|
||||
if (!res.ok) {
|
||||
let reason: string
|
||||
|
@ -33,6 +36,35 @@ export async function fetchSSE(
|
|||
}
|
||||
})
|
||||
|
||||
// handle special response errors
|
||||
const feed = (chunk: string) => {
|
||||
let response = null
|
||||
|
||||
try {
|
||||
response = JSON.parse(chunk)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (response?.detail?.type === 'invalid_request_error') {
|
||||
const msg = `ChatGPT error ${response.detail.message}: ${response.detail.code} (${response.detail.type})`
|
||||
const error = new types.ChatGPTError(msg, { cause: response })
|
||||
error.statusCode = response.detail.code
|
||||
error.statusText = response.detail.message
|
||||
|
||||
if (onError) {
|
||||
onError(error)
|
||||
} else {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
// don't feed to the event parser
|
||||
return
|
||||
}
|
||||
|
||||
parser.feed(chunk)
|
||||
}
|
||||
|
||||
if (!res.body.getReader) {
|
||||
// Vercel polyfills `fetch` with `node-fetch`, which doesn't conform to
|
||||
// web standards, so this is a workaround...
|
||||
|
@ -45,13 +77,13 @@ export async function fetchSSE(
|
|||
body.on('readable', () => {
|
||||
let chunk: string | Buffer
|
||||
while (null !== (chunk = body.read())) {
|
||||
parser.feed(chunk.toString())
|
||||
feed(chunk.toString())
|
||||
}
|
||||
})
|
||||
} else {
|
||||
for await (const chunk of streamAsyncIterable(res.body)) {
|
||||
const str = new TextDecoder().decode(chunk)
|
||||
parser.feed(str)
|
||||
feed(str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
20
src/types.ts
20
src/types.ts
|
@ -10,6 +10,8 @@ export type ChatGPTAPIOptions = {
|
|||
/** @defaultValue `'https://api.openai.com'` **/
|
||||
apiBaseUrl?: string
|
||||
|
||||
apiOrg?: string
|
||||
|
||||
/** @defaultValue `false` **/
|
||||
debug?: boolean
|
||||
|
||||
|
@ -36,6 +38,7 @@ export type SendMessageOptions = {
|
|||
/** The name of a user in a multi-user chat. */
|
||||
name?: string
|
||||
parentMessageId?: string
|
||||
conversationId?: string
|
||||
messageId?: string
|
||||
stream?: boolean
|
||||
systemMessage?: string
|
||||
|
@ -65,11 +68,14 @@ export interface ChatMessage {
|
|||
role: Role
|
||||
name?: string
|
||||
delta?: string
|
||||
detail?: any
|
||||
detail?:
|
||||
| openai.CreateChatCompletionResponse
|
||||
| CreateChatCompletionStreamResponse
|
||||
|
||||
// relevant for both ChatGPTAPI and ChatGPTUnofficialProxyAPI
|
||||
parentMessageId?: string
|
||||
// only relevant for ChatGPTUnofficialProxyAPI
|
||||
|
||||
// only relevant for ChatGPTUnofficialProxyAPI (optional for ChatGPTAPI)
|
||||
conversationId?: string
|
||||
}
|
||||
|
||||
|
@ -86,6 +92,16 @@ export type GetMessageByIdFunction = (id: string) => Promise<ChatMessage>
|
|||
/** Upserts a chat message to a store. */
|
||||
export type UpsertMessageFunction = (message: ChatMessage) => Promise<void>
|
||||
|
||||
export interface CreateChatCompletionStreamResponse
|
||||
extends openai.CreateChatCompletionDeltaResponse {
|
||||
usage: CreateCompletionStreamResponseUsage
|
||||
}
|
||||
|
||||
export interface CreateCompletionStreamResponseUsage
|
||||
extends openai.CreateCompletionResponseUsage {
|
||||
estimated: true
|
||||
}
|
||||
|
||||
/**
|
||||
* https://chat.openapi.com/backend-api/conversation
|
||||
*/
|
||||
|
|
Ładowanie…
Reference in New Issue