Porównaj commity

...

78 Commity
v5.1.2 ... main

Autor SHA1 Wiadomość Data
Travis Fischer 73fb30bc11 😦 2023-06-29 00:07:02 -07:00
Travis Fischer 8acfaa6ebd 5.2.5 2023-05-30 19:42:15 -07:00
Travis Fischer 729b5a415c
Merge pull request #571 from masterkain/js-tiktoken 2023-05-30 19:39:36 -07:00
Claudio Poli 3ec62b89b2 switch tokenizer implementation with pure js and more compatible js-tiktoken 2023-05-17 04:52:37 +02:00
Travis Fischer f39279cef9 5.2.4 2023-05-01 21:55:03 -05:00
Travis Fischer 996d28999d 🎛 2023-05-01 21:54:46 -05:00
Travis Fischer 09499613f0 fix: unofficial api proxy be less strict with json parsing 2023-05-01 21:54:15 -05:00
Travis Fischer 92c02719c2
Merge pull request #533 from chenweiyi/main 2023-05-01 21:43:57 -05:00
Travis Fischer a508d2720f
Merge pull request #534 from Micuks/Add-QQ-Bot-with-Bull-to-Readme 2023-05-01 21:43:40 -05:00
Travis Fischer eb2c19748e 5.2.3 2023-05-01 21:43:00 -05:00
Travis Fischer a020bcc9c5 chore: update ts docs 2023-05-01 21:42:44 -05:00
Travis Fischer fb06bebc9c chore: update deps 2023-05-01 21:42:22 -05:00
Travis Fischer 431e6f1989
Merge pull request #540 from acheong08/patch-4 2023-04-18 22:26:48 -07:00
Antonio Cheong 09963d5ccb
Unofficial Proxy update
Cloudflare added new fingerprints and made my proxy impractical at scale.

Users can run https://github.com/linweiyuan/go-chatgpt-api locally instead or use public proxy by @pengzhile
2023-04-18 20:42:40 +08:00
Micuks 6a3c15f436
Add QQ Bot with Bull to Readme 2023-04-11 10:46:17 +08:00
Travis Fischer c8da448055 🚾 2023-04-10 14:29:25 -05:00
Travis Fischer fcd7dd4116 🔇 2023-04-10 14:28:44 -05:00
Travis Fischer e529c4e218 docs: update latest developments 2023-04-10 14:27:59 -05:00
chenweiyi01 8782763c32 add my project, a similar to chatgpt website 2023-04-10 19:08:11 +08:00
Travis Fischer 66e68837be
Merge pull request #532 from ZirionNeft/patch-1 2023-04-09 01:26:52 -05:00
Nikita Kryukov fedb25c37f
Update readme.md
Add my fun-project Discord Bot Daily News in the list:
https://github.com/ZirionNeft/chatgpt-discord-daily-news-bot
2023-04-07 22:05:52 +03:00
Travis Fischer 600b35eaec chore: update ts docs 2023-04-02 14:54:23 -05:00
Travis Fischer bf66500730 5.2.2 2023-04-02 14:37:34 -05:00
Travis Fischer 8388017963 fix: apiOrg 2023-04-02 14:37:19 -05:00
Travis Fischer 3f5ddc7939 5.2.1 2023-04-02 12:19:52 -05:00
Travis Fischer a720b81699 chore: update deps 2023-04-02 12:19:39 -05:00
Travis Fischer a1749d0d0c 5.2.0 2023-04-02 12:16:01 -05:00
Travis Fischer 07dcc5df31 2023-04-02 11:51:21 -05:00
Travis Fischer c0c2e716ea
Merge pull request #431 from sighingnow/fix-error-handling 2023-04-02 11:47:40 -05:00
Travis Fischer 6c309ce365 🐁 2023-04-02 11:33:54 -05:00
Travis Fischer 8ad7ba9a1d
Merge pull request #505 from 189/feat/conversationId 2023-04-02 11:32:17 -05:00
Travis Fischer 3f5d8e6595 🏎 2023-04-02 11:30:44 -05:00
Travis Fischer 9bb7da32e4
Merge pull request #504 from 189/fix/defer-save 2023-04-02 11:29:49 -05:00
Travis Fischer 81caf0ba11
Merge branch 'main' into fix/defer-save 2023-04-02 11:29:43 -05:00
Travis Fischer 0f966dc402 chore: minor fixes 2023-04-02 11:27:20 -05:00
Travis Fischer db6e5941ab
Merge pull request #507 from alxmiron/tokenize-response 2023-04-02 11:23:00 -05:00
Travis Fischer 599e197c09
Merge pull request #511 from zhengxs2018/main 2023-04-02 11:16:46 -05:00
Travis Fischer c0d79e3819
Merge branch 'main' into main 2023-04-02 11:16:26 -05:00
Travis Fischer a3b165f7e4
Merge pull request #509 from gfl94/patch-1 2023-04-02 11:15:32 -05:00
Travis Fischer c5abff264e
Merge pull request #510 from benjiJanssens/main 2023-04-02 11:15:18 -05:00
Travis Fischer bc94ed116a
Merge pull request #518 from Jarvan-via/jarvan 2023-04-02 11:15:05 -05:00
Travis Fischer 59b20771a9
Update readme.md 2023-04-02 11:14:57 -05:00
Travis Fischer 828510c1a0 5.1.4 2023-04-01 14:40:06 -05:00
Travis Fischer e1d536e62f feat: add cli support for model 2023-04-01 14:39:47 -05:00
袁勇 afa5aea5df feat: add OpenAI-API-Service for readme 2023-04-01 18:44:39 +08:00
阿森 de78787bc9 style: prettier code 2023-03-31 16:31:20 +08:00
阿森 79a9d50ec0
Update chatgpt-api.ts 2023-03-31 15:32:37 +08:00
阿森 52d3918255
feat: support multiple organizations 2023-03-31 15:29:07 +08:00
Benjamin Janssens 507a296249 Added SlackGPT to the README 2023-03-30 22:47:13 +02:00
Gefei Li 4da3ea6e1f
add a wechat bot with wechaty+chatgpt api 2023-03-30 19:53:50 +08:00
Oleksii Myronenko 7cd6e06bdd #477 Mark tokens as estimated 2023-03-29 23:48:50 +03:00
Oleksii Myronenko dd6b457932 #477 Estimate tokens usage with streaming completions 2023-03-29 23:34:06 +03:00
Travis Fischer 0984504154
Merge pull request #506 from T-Damer/patch-1 2023-03-29 14:49:42 -05:00
Daniil Pankov cf29a97c0b
Update how to use with commonJS
Add another workaround for commonJS libraries
2023-03-29 20:42:49 +03:00
wangshangwen fa53d8606d feat: support conversationID for ChatGPTAPI 2023-03-28 14:19:20 +08:00
wangshangwen 44a4a9121e fix: defer saving new message util got response from openAI 2023-03-28 12:00:12 +08:00
Travis Fischer 4613b95cc3 5.1.3 2023-03-27 22:13:51 -05:00
Travis Fischer 5f239e53bb chore: update ts docs 2023-03-27 22:13:37 -05:00
Travis Fischer 9eac18fac0 feat: update deps 2023-03-27 22:13:12 -05:00
Travis Fischer 0655b632e2
Merge pull request #500 from christophebe/main 2023-03-27 22:12:25 -05:00
Travis Fischer b4f59cb51d
Merge branch 'main' into main 2023-03-27 22:12:20 -05:00
Travis Fischer 912ca2432d
Merge pull request #498 from Elitezen/main 2023-03-27 22:11:32 -05:00
Travis Fischer c8b7351889
Update readme.md 2023-03-27 22:11:15 -05:00
Travis Fischer 020c21b173
Merge pull request #496 from zhengxs2018/patch-1 2023-03-27 22:10:08 -05:00
Travis Fischer 172c9ffd1b
Merge pull request #494 from formulahendry/patch-1 2023-03-27 22:08:59 -05:00
Christophe 052238fb62
Add new project : Julius GPT 2023-03-26 21:50:06 +02:00
Elitezen 34ac22408e Added discordjs-chatgpt under Projects 2023-03-25 17:12:20 -04:00
阿森 15058598fb
docs: add one WeChat Bot to readme
Thanks 🙏
2023-03-25 09:34:28 +08:00
Jun Han c869d1fc0b
docs: add one WeChat Bot to readme 2023-03-24 21:53:02 +08:00
Travis Fischer 9932fca55c
Merge pull request #493 from acheong08/patch-3 2023-03-24 01:29:28 -05:00
Antonio Cheong d61ab51d64
Update endpoint
My domain name expires in 5 days. Need to swap. Everything is exactly the same.
2023-03-24 14:19:10 +08:00
Travis Fischer 7d9d092dcb
Merge pull request #491 from PawanOsman/main 2023-03-23 10:02:07 -05:00
Pawan Osman ff40424d9b Update reverse proxy url and details 2023-03-23 10:18:00 +03:00
Travis Fischer 753c61c7b6
Merge pull request #485 from shixin-guo/main 2023-03-20 17:31:34 -05:00
士心 68cbd04aaa
doc: add a zoom chat based on chatgpt 2023-03-21 00:00:37 +08:00
Travis Fischer 523d076ba9
Merge pull request #479 from azoway/main 2023-03-18 08:57:29 -05:00
azoway b574020a74
Update readme.md 2023-03-18 21:43:45 +08:00
Tao He 452a61eb1b Handle possible token expired errors
Signed-off-by: Tao He <sighingnow@gmail.com>
2023-03-04 21:27:37 +08:00
26 zmienionych plików z 1505 dodań i 788 usunięć

Wyświetl plik

@ -29,13 +29,18 @@ async function main() {
.option('-s, --store', 'Enables the local message cache', {
default: true
})
.option('-t, --timeout', 'Timeout in milliseconds')
.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'
})
.option(
'-n, --conversationName <conversationName>',
'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')
@ -50,6 +55,7 @@ async function main() {
options.continue && options.store
? config.get(conversationKey, {}) || {}
: {}
const model = options.model
let conversationId = undefined
let parentMessageId = undefined
@ -67,7 +73,11 @@ async function main() {
const api = new ChatGPTAPI({
apiKey,
apiOrg,
debug: options.debug,
completionParams: {
model
},
getMessageById: async (id) => {
if (options.store) {
return conversation[id]

Wyświetl plik

@ -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/c4ffe53/src/chatgpt-api.ts#L49)
[src/chatgpt-api.ts:51](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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:308](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/chatgpt-api.ts#L308)
[src/chatgpt-api.ts:345](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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:312](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/chatgpt-api.ts#L312)
[src/chatgpt-api.ts:349](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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/fb06beb/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/fb06beb/src/chatgpt-api.ts#L357)
## Methods
@ -94,4 +125,4 @@ The response from ChatGPT
#### Defined in
[src/chatgpt-api.ts:131](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/chatgpt-api.ts#L131)
[src/chatgpt-api.ts:137](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/chatgpt-api.ts#L137)

Wyświetl plik

@ -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.4/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.4/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:77](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L77)
[src/types.ts:86](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L86)
___
@ -76,7 +76,7 @@ ___
#### Defined in
[src/types.ts:76](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L76)
[src/types.ts:85](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L85)
___
@ -86,7 +86,7 @@ ___
#### Defined in
[src/types.ts:74](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L74)
[src/types.ts:83](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L83)
___
@ -96,4 +96,4 @@ ___
#### Defined in
[src/types.ts:75](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L75)
[src/types.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L84)

Wyświetl plik

@ -36,7 +36,7 @@
#### Defined in
[src/chatgpt-unofficial-proxy-api.ts:20](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/chatgpt-unofficial-proxy-api.ts#L20)
[src/chatgpt-unofficial-proxy-api.ts:20](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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/c4ffe53/src/chatgpt-unofficial-proxy-api.ts#L66)
[src/chatgpt-unofficial-proxy-api.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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/c4ffe53/src/chatgpt-unofficial-proxy-api.ts#L70)
[src/chatgpt-unofficial-proxy-api.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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/c4ffe53/src/chatgpt-unofficial-proxy-api.ts#L97)
[src/chatgpt-unofficial-proxy-api.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/chatgpt-unofficial-proxy-api.ts#L97)

Wyświetl plik

@ -23,7 +23,7 @@
#### Defined in
[src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L70)
[src/types.ts:79](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L79)
___
@ -33,17 +33,17 @@ ___
#### Defined in
[src/types.ts:64](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L64)
[src/types.ts:70](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L70)
___
### detail
`Optional` **detail**: `any`
`Optional` **detail**: [`CreateChatCompletionResponse`](openai.CreateChatCompletionResponse.md) \| [`CreateChatCompletionStreamResponse`](CreateChatCompletionStreamResponse.md)
#### Defined in
[src/types.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L65)
[src/types.ts:71](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L71)
___
@ -53,7 +53,7 @@ ___
#### Defined in
[src/types.ts:60](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L60)
[src/types.ts:66](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L66)
___
@ -63,7 +63,7 @@ ___
#### Defined in
[src/types.ts:63](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L63)
[src/types.ts:69](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L69)
___
@ -73,7 +73,7 @@ ___
#### Defined in
[src/types.ts:68](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L68)
[src/types.ts:76](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L76)
___
@ -83,7 +83,7 @@ ___
#### Defined in
[src/types.ts:62](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L62)
[src/types.ts:68](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L68)
___
@ -93,4 +93,4 @@ ___
#### Defined in
[src/types.ts:61](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L61)
[src/types.ts:67](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L67)

Wyświetl plik

@ -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/fb06beb/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/fb06beb/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/fb06beb/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/fb06beb/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/fb06beb/src/types.ts#L195)
___
### usage
**usage**: [`CreateCompletionStreamResponseUsage`](CreateCompletionStreamResponseUsage.md)
#### Defined in
[src/types.ts:97](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L97)

Wyświetl plik

@ -0,0 +1,86 @@
[chatgpt](../readme.md) / [Exports](../modules.md) / CreateCompletionStreamResponseUsage
# Interface: CreateCompletionStreamResponseUsage
**`Export`**
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/fb06beb/src/types.ts#L438)
___
### estimated
**estimated**: ``true``
#### Defined in
[src/types.ts:102](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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/fb06beb/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/fb06beb/src/types.ts#L444)

Wyświetl plik

@ -6,8 +6,6 @@
**`Export`**
**`Interface`**
ChatCompletionRequestMessage
## Table of contents
@ -32,7 +30,7 @@ ChatCompletionRequestMessage
#### Defined in
[src/types.ts:208](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L208)
[src/types.ts:227](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L227)
___
@ -48,7 +46,7 @@ ChatCompletionRequestMessage
#### Defined in
[src/types.ts:214](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L214)
[src/types.ts:233](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L233)
___
@ -64,4 +62,4 @@ ChatCompletionRequestMessage
#### Defined in
[src/types.ts:202](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L202)
[src/types.ts:221](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L221)

Wyświetl plik

@ -6,8 +6,6 @@
**`Export`**
**`Interface`**
ChatCompletionResponseMessage
## Table of contents
@ -31,7 +29,7 @@ ChatCompletionResponseMessage
#### Defined in
[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L240)
[src/types.ts:259](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L259)
___
@ -47,4 +45,4 @@ ChatCompletionResponseMessage
#### Defined in
[src/types.ts:234](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L234)
[src/types.ts:253](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L253)

Wyświetl plik

@ -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:179](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L179)
[src/types.ts:198](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L198)
___
@ -32,7 +38,7 @@ ___
#### Defined in
[src/types.ts:177](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L177)
[src/types.ts:196](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L196)
___
@ -42,7 +48,7 @@ ___
#### Defined in
[src/types.ts:175](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L175)
[src/types.ts:194](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L194)
___
@ -52,7 +58,7 @@ ___
#### Defined in
[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L178)
[src/types.ts:197](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L197)
___
@ -62,4 +68,4 @@ ___
#### Defined in
[src/types.ts:176](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L176)
[src/types.ts:195](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L195)

Wyświetl plik

@ -6,8 +6,6 @@
**`Export`**
**`Interface`**
CreateChatCompletionRequest
## Table of contents
@ -41,7 +39,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:314](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L314)
[src/types.ts:333](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L333)
___
@ -57,7 +55,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:320](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L320)
[src/types.ts:339](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L339)
___
@ -73,7 +71,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:302](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L302)
[src/types.ts:321](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L321)
___
@ -89,7 +87,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L266)
[src/types.ts:285](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L285)
___
@ -105,7 +103,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:260](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L260)
[src/types.ts:279](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L279)
___
@ -121,7 +119,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:284](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L284)
[src/types.ts:303](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L303)
___
@ -137,7 +135,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:308](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L308)
[src/types.ts:327](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L327)
___
@ -151,7 +149,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:296](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L296)
[src/types.ts:315](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L315)
___
@ -167,7 +165,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:290](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L290)
[src/types.ts:309](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L309)
___
@ -183,7 +181,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:272](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L272)
[src/types.ts:291](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L291)
___
@ -199,7 +197,7 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:278](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L278)
[src/types.ts:297](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L297)
___
@ -215,4 +213,4 @@ CreateChatCompletionRequest
#### Defined in
[src/types.ts:326](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L326)
[src/types.ts:345](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L345)

Wyświetl plik

@ -6,8 +6,6 @@
**`Export`**
**`Interface`**
CreateChatCompletionResponse
## Table of contents
@ -33,7 +31,7 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:369](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L369)
[src/types.ts:388](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L388)
___
@ -47,7 +45,7 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:357](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L357)
[src/types.ts:376](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L376)
___
@ -61,7 +59,7 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:345](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L345)
[src/types.ts:364](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L364)
___
@ -75,7 +73,7 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:363](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L363)
[src/types.ts:382](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L382)
___
@ -89,7 +87,7 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:351](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L351)
[src/types.ts:370](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L370)
___
@ -103,4 +101,4 @@ CreateChatCompletionResponse
#### Defined in
[src/types.ts:375](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L375)
[src/types.ts:394](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L394)

Wyświetl plik

@ -6,8 +6,6 @@
**`Export`**
**`Interface`**
CreateChatCompletionResponseChoicesInner
## Table of contents
@ -30,7 +28,7 @@ CreateChatCompletionResponseChoicesInner
#### Defined in
[src/types.ts:400](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L400)
[src/types.ts:419](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L419)
___
@ -44,7 +42,7 @@ CreateChatCompletionResponseChoicesInner
#### Defined in
[src/types.ts:388](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L388)
[src/types.ts:407](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L407)
___
@ -58,4 +56,4 @@ CreateChatCompletionResponseChoicesInner
#### Defined in
[src/types.ts:394](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L394)
[src/types.ts:413](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L413)

Wyświetl plik

@ -6,10 +6,14 @@
**`Export`**
**`Interface`**
CreateCompletionResponseUsage
## Hierarchy
- **`CreateCompletionResponseUsage`**
↳ [`CreateCompletionStreamResponseUsage`](CreateCompletionStreamResponseUsage.md)
## Table of contents
### Properties
@ -30,7 +34,7 @@ CreateCompletionResponseUsage
#### Defined in
[src/types.ts:419](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L419)
[src/types.ts:438](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L438)
___
@ -44,7 +48,7 @@ CreateCompletionResponseUsage
#### Defined in
[src/types.ts:413](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L413)
[src/types.ts:432](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L432)
___
@ -58,4 +62,4 @@ CreateCompletionResponseUsage
#### Defined in
[src/types.ts:425](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L425)
[src/types.ts:444](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L444)

Wyświetl plik

@ -17,6 +17,8 @@
### Interfaces
- [ChatMessage](interfaces/ChatMessage.md)
- [CreateChatCompletionStreamResponse](interfaces/CreateChatCompletionStreamResponse.md)
- [CreateCompletionStreamResponseUsage](interfaces/CreateCompletionStreamResponseUsage.md)
### Type Aliases
@ -49,7 +51,8 @@
| :------ | :------ | :------ |
| `apiBaseUrl?` | `string` | **`Default Value`** `'https://api.openai.com'` * |
| `apiKey` | `string` | - |
| `completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"``\>\> | - |
| `apiOrg?` | `string` | - |
| `completionParams?` | `Partial`<`Omit`<[`CreateChatCompletionRequest`](interfaces/openai.CreateChatCompletionRequest.md), ``"messages"`` \| ``"n"`` \| ``"stream"``\>\> | - |
| `debug?` | `boolean` | **`Default Value`** `false` * |
| `fetch?` | [`FetchFn`](modules.md#fetchfn) | - |
| `getMessageById?` | [`GetMessageByIdFunction`](modules.md#getmessagebyidfunction) | - |
@ -61,7 +64,7 @@
#### Defined in
[src/types.ts:7](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L7)
[src/types.ts:7](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L7)
___
@ -71,7 +74,7 @@ ___
#### Defined in
[src/types.ts:133](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L133)
[src/types.ts:152](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L152)
___
@ -93,7 +96,7 @@ https://chat.openapi.com/backend-api/conversation
#### Defined in
[src/types.ts:89](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L89)
[src/types.ts:108](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L108)
___
@ -111,7 +114,7 @@ ___
#### Defined in
[src/types.ts:147](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L147)
[src/types.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L166)
___
@ -121,7 +124,7 @@ ___
#### Defined in
[src/types.ts:5](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L5)
[src/types.ts:5](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/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:81](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L81)
[src/types.ts:90](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L90)
___
@ -172,7 +175,7 @@ ___
#### Defined in
[src/types.ts:153](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L153)
[src/types.ts:172](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L172)
___
@ -182,7 +185,7 @@ ___
#### Defined in
[src/types.ts:47](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L47)
[src/types.ts:53](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L53)
___
@ -199,7 +202,7 @@ ___
#### Defined in
[src/types.ts:166](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L166)
[src/types.ts:185](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L185)
___
@ -209,7 +212,7 @@ ___
#### Defined in
[src/types.ts:171](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L171)
[src/types.ts:190](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L190)
___
@ -227,7 +230,7 @@ ___
#### Defined in
[src/types.ts:116](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L116)
[src/types.ts:135](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L135)
___
@ -244,7 +247,7 @@ ___
#### Defined in
[src/types.ts:135](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L135)
[src/types.ts:154](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L154)
___
@ -254,7 +257,7 @@ ___
#### Defined in
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L3)
[src/types.ts:3](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L3)
___
@ -276,7 +279,7 @@ ___
#### Defined in
[src/types.ts:49](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L49)
[src/types.ts:55](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L55)
___
@ -289,6 +292,8 @@ ___
| Name | Type | Description |
| :------ | :------ | :------ |
| `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` | - |
@ -299,7 +304,7 @@ ___
#### Defined in
[src/types.ts:35](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L35)
[src/types.ts:37](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L37)
___
@ -325,4 +330,4 @@ Upserts a chat message to a store.
#### Defined in
[src/types.ts:84](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L84)
[src/types.ts:93](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L93)

Wyświetl plik

@ -33,9 +33,9 @@
#### Defined in
[src/types.ts:216](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L216)
[src/types.ts:235](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L235)
[src/types.ts:221](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L221)
[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L240)
___
@ -45,9 +45,9 @@ ___
#### Defined in
[src/types.ts:242](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L242)
[src/types.ts:261](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L261)
[src/types.ts:247](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L247)
[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L266)
___
@ -59,7 +59,7 @@ ___
#### Defined in
[src/types.ts:333](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L333)
[src/types.ts:352](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L352)
## Variables
@ -77,9 +77,9 @@ ___
#### Defined in
[src/types.ts:216](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L216)
[src/types.ts:235](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L235)
[src/types.ts:221](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L221)
[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L240)
___
@ -97,6 +97,6 @@ ___
#### Defined in
[src/types.ts:242](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L242)
[src/types.ts:261](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L261)
[src/types.ts:247](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L247)
[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/fb06beb/src/types.ts#L266)

Wyświetl plik

@ -33,6 +33,44 @@ This package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatg
## Updates
<details open>
<summary><strong>April 10, 2023</strong></summary>
<br/>
This package now **fully supports GPT-4**! 🔥
We also just released a [TypeScript chatgpt-plugin package](https://github.com/transitive-bullshit/chatgpt-plugin-ts) which contains helpers and examples to make it as easy as possible to start building your own ChatGPT Plugins in JS/TS. Even if you don't have developer access to ChatGPT Plugins yet, you can still use the [chatgpt-plugin](https://github.com/transitive-bullshit/chatgpt-plugin-ts) repo to get a head start on building your own plugins locally.
If you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:
```bash
npx chatgpt@latest --model gpt-4 "Hello world"
```
<p align="center">
<img src="https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png" width="600px" alt="Using the chatgpt CLI with gpt-4">
</p>
We still support both the official ChatGPT API and the unofficial proxy API, but we now recommend using the official API since it's significantly more robust and supports **GPT-4**.
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | ------- | ------------------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models + GPT-4 |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No | ✅ ChatGPT webapp |
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
</details>
<details>
<summary><strong>Previous Updates</strong></summary>
<br/>
<details>
<summary><strong>March 1, 2023</strong></summary>
<br/>
@ -46,16 +84,11 @@ The [official OpenAI chat completions API](https://platform.openai.com/docs/guid
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
</details>
<details>
<summary><strong>Previous Updates</strong></summary>
<br/>
<details>
<summary><strong>Feb 19, 2023</strong></summary>
@ -113,7 +146,7 @@ Huge shoutout to [@waylaidwanderer](https://github.com/waylaidwanderer) for disc
</details>
</details>
If you run into any issues, we do have a pretty active [Discord](https://discord.gg/v9gERj825w) with a bunch of ChatGPT hackers from the Node.js & Python communities.
If you run into any issues, we do have a pretty active [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers from the Node.js & Python communities.
Lastly, please consider starring this repo and <a href="https://twitter.com/transitive_bs">following me on twitter <img src="https://storage.googleapis.com/saasify-assets/twitter-logo.svg" alt="twitter" height="24px" align="center"></a> to help support the project.
@ -152,11 +185,18 @@ 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
```
If you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:
<p align="center">
<img src="https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png" width="600px" alt="Using the chatgpt CLI with gpt-4">
</p>
## Install
```bash
@ -169,18 +209,18 @@ Make sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if
To use this module from Node.js, you need to pick between two methods:
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | -------- | ----------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT |
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | ------- | ------------------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models + GPT-4 |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No | ✅ Real ChatGPT webapp |
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
Both approaches have very similar APIs, so it should be simple to swap between them.
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI and it also supports `gpt-4`. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.
### Usage - ChatGPTAPI
@ -199,12 +239,13 @@ async function example() {
}
```
You can override the default `model` (`gpt-3.5-turbo-0301`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:
You can override the default `model` (`gpt-3.5-turbo`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:
```ts
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
completionParams: {
model: 'gpt-4',
temperature: 0.5,
top_p: 0.8
}
@ -282,8 +323,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 })
@ -332,10 +376,10 @@ const api = new ChatGPTUnofficialProxyAPI({
Known reverse proxies run by community members include:
| Reverse Proxy URL | Author | Rate Limits | Last Checked |
| ------------------------------------------------ | -------------------------------------------- | ----------------- | ------------ |
| `https://bypass.duti.tech/api/conversation` | [@acheong08](https://github.com/acheong08) | 5 req / 10 seconds by IP | 3/11/2023 |
| `https://gpt.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | ? | 2/19/2023 |
| Reverse Proxy URL | Author | Rate Limits | Last Checked |
| ------------------------------------------------- | -------------------------------------------- | ---------------------------- | ------------ |
| `https://ai.fakeopen.com/api/conversation` | [@pengzhile](https://github.com/pengzhile) | 5 req / 10 seconds by IP | 4/18/2023 |
| `https://api.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | 50 req / 15 seconds (~3 r/s) | 3/23/2023 |
Note: info on how the reverse proxies work is not being published at this time in order to prevent OpenAI from disabling access.
@ -424,6 +468,7 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Telegram Bot #2](https://github.com/dawangraoming/chatgpt-telegram-bot)
- [Telegram Bot #3](https://github.com/RainEggplant/chatgpt-telegram-bot) (group privacy mode, ID-based auth)
- [Telegram Bot #4](https://github.com/ArdaGnsrn/chatgpt-telegram) (queue system, ID-based chat thread)
- [Telegram Bot #5](https://github.com/azoway/chatgpt-telegram-bot) (group privacy mode, ID-based chat thread)
- [Deno Telegram Bot](https://github.com/Ciyou/chatbot-telegram)
- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)
- [Telegram Bot for YouTube Summaries](https://github.com/codextde/youtube-summary)
@ -434,11 +479,15 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Discord Bot #4 (selfbot)](https://github.com/0x7030676e31/cumsocket)
- [Discord Bot #5](https://github.com/itskdhere/ChatGPT-Discord-BOT)
- [Discord Bot #6 (Shakespeare bot)](https://gist.github.com/TheBrokenRail/4b37e7c44e8f721d8bd845050d034c16)
- [Discord Bot #7](https://github.com/Elitezen/discordjs-chatgpt)
- [Zoom Chat](https://github.com/shixin-guo/my-bot)
- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)
- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)
- [WeChat Bot #3](https://github.com/wangrongding/wechat-bot) (
- [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)
@ -466,6 +515,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)
@ -484,6 +535,10 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Next.js ChatGPT With Firebase](https://github.com/youngle316/chatgpt)
- [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 CLI
- [OpenAI-API-Service](https://github.com/Jarvan-via/api-service) - Provides OpenAI related APIs for businesses
- [Discord Daily News Bot](https://github.com/ZirionNeft/chatgpt-discord-daily-news-bot) - Discord bot that generate funny daily news
If you create a cool integration, feel free to open a PR and add it to the list.
@ -499,8 +554,8 @@ If you create a cool integration, feel free to open a PR and add it to the list.
## Credits
- Huge thanks to [@waylaidwanderer](https://github.com/waylaidwanderer), [@abacaj](https://github.com/abacaj), [@wong2](https://github.com/wong2), [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪
- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)
- [OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥
- I run the [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers – come join us!
## License

4
package-lock.json wygenerowano
Wyświetl plik

@ -1,12 +1,12 @@
{
"name": "chatgpt",
"version": "5.1.2",
"version": "5.2.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "chatgpt",
"version": "5.1.2",
"version": "5.2.5",
"license": "MIT",
"dependencies": {
"@dqbd/tiktoken": "^0.4.0",

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "chatgpt",
"version": "5.1.2",
"version": "5.2.5",
"description": "Node.js client for the official ChatGPT API.",
"author": "Travis Fischer <travis@transitivebullsh.it>",
"repository": "transitive-bullshit/chatgpt-api",
@ -10,8 +10,8 @@
"types": "./build/index.d.ts",
"exports": {
".": {
"import": "./build/index.js",
"types": "./build/index.d.ts",
"import": "./build/index.js",
"default": "./build/index.js"
}
},
@ -37,10 +37,10 @@
"test:prettier": "prettier '**/*.{js,jsx,ts,tsx}' --check"
},
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
"cac": "^6.7.14",
"conf": "^11.0.1",
"eventsource-parser": "^0.0.5",
"eventsource-parser": "^1.0.0",
"js-tiktoken": "^1.0.5",
"keyv": "^4.5.2",
"p-timeout": "^6.1.1",
"quick-lru": "^6.1.1",
@ -48,22 +48,22 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@keyv/redis": "^2.5.6",
"@keyv/redis": "^2.5.7",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/node": "^18.15.3",
"@types/node": "^18.16.3",
"@types/uuid": "^9.0.1",
"del-cli": "^5.0.0",
"dotenv-safe": "^8.2.0",
"husky": "^8.0.2",
"lint-staged": "^13.2.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"npm-run-all": "^4.1.5",
"ora": "^6.1.2",
"prettier": "^2.8.4",
"tsup": "^6.6.3",
"tsx": "^3.12.5",
"typedoc": "^0.23.27",
"typedoc-plugin-markdown": "^3.13.6",
"typescript": "^4.9.5"
"ora": "^6.3.0",
"prettier": "^2.8.8",
"tsup": "^6.7.0",
"tsx": "^3.12.7",
"typedoc": "^0.24.6",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "^5.0.4"
},
"lint-staged": {
"*.{ts,tsx}": [

Plik diff jest za duży Load Diff

Wyświetl plik

@ -31,6 +31,44 @@ This package is a Node.js wrapper around [ChatGPT](https://openai.com/blog/chatg
## Updates
<details open>
<summary><strong>April 10, 2023</strong></summary>
<br/>
This package now **fully supports GPT-4**! 🔥
We also just released a [TypeScript chatgpt-plugin package](https://github.com/transitive-bullshit/chatgpt-plugin-ts) which contains helpers and examples to make it as easy as possible to start building your own ChatGPT Plugins in JS/TS. Even if you don't have developer access to ChatGPT Plugins yet, you can still use the [chatgpt-plugin](https://github.com/transitive-bullshit/chatgpt-plugin-ts) repo to get a head start on building your own plugins locally.
If you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:
```bash
npx chatgpt@latest --model gpt-4 "Hello world"
```
<p align="center">
<img src="https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png" width="600px" alt="Using the chatgpt CLI with gpt-4">
</p>
We still support both the official ChatGPT API and the unofficial proxy API, but we now recommend using the official API since it's significantly more robust and supports **GPT-4**.
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | ------- | ------------------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models + GPT-4 |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No | ✅ ChatGPT webapp |
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
</details>
<details>
<summary><strong>Previous Updates</strong></summary>
<br/>
<details>
<summary><strong>March 1, 2023</strong></summary>
<br/>
@ -44,16 +82,11 @@ The [official OpenAI chat completions API](https://platform.openai.com/docs/guid
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free)
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
</details>
<details>
<summary><strong>Previous Updates</strong></summary>
<br/>
<details>
<summary><strong>Feb 19, 2023</strong></summary>
@ -111,7 +144,7 @@ Huge shoutout to [@waylaidwanderer](https://github.com/waylaidwanderer) for disc
</details>
</details>
If you run into any issues, we do have a pretty active [Discord](https://discord.gg/v9gERj825w) with a bunch of ChatGPT hackers from the Node.js & Python communities.
If you run into any issues, we do have a pretty active [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers from the Node.js & Python communities.
Lastly, please consider starring this repo and <a href="https://twitter.com/transitive_bs">following me on twitter <img src="https://storage.googleapis.com/saasify-assets/twitter-logo.svg" alt="twitter" height="24px" align="center"></a> to help support the project.
@ -150,11 +183,18 @@ 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
```
If you have access to the `gpt-4` model, you can run the following to test out the CLI with GPT-4:
<p align="center">
<img src="https://user-images.githubusercontent.com/552829/229368245-d22fbac7-4b56-4a5e-810b-5ac5793b6ac3.png" width="600px" alt="Using the chatgpt CLI with gpt-4">
</p>
## Install
```bash
@ -167,18 +207,18 @@ Make sure you're using `node >= 18` so `fetch` is available (or `node >= 14` if
To use this module from Node.js, you need to pick between two methods:
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | -------- | ----------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ☑️ Maybe | ✅ Real ChatGPT |
| Method | Free? | Robust? | Quality? |
| --------------------------- | ------ | ------- | ------------------------------- |
| `ChatGPTAPI` | ❌ No | ✅ Yes | ✅️ Real ChatGPT models + GPT-4 |
| `ChatGPTUnofficialProxyAPI` | ✅ Yes | ❌ No | ✅ Real ChatGPT webapp |
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo-0301` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.
1. `ChatGPTAPI` - Uses the `gpt-3.5-turbo` model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.
2. `ChatGPTUnofficialProxyAPI` - Uses an unofficial proxy server to access ChatGPT's backend API in a way that circumvents Cloudflare (uses the real ChatGPT and is pretty lightweight, but relies on a third-party server and is rate-limited)
Both approaches have very similar APIs, so it should be simple to swap between them.
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI. We may remove support for `ChatGPTUnofficialProxyAPI` in a future release.
**Note**: We strongly recommend using `ChatGPTAPI` since it uses the officially supported API from OpenAI and it also supports `gpt-4`. We will likely remove support for `ChatGPTUnofficialProxyAPI` in a future release.
### Usage - ChatGPTAPI
@ -197,12 +237,13 @@ async function example() {
}
```
You can override the default `model` (`gpt-3.5-turbo-0301`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:
You can override the default `model` (`gpt-3.5-turbo`) and any [OpenAI chat completion params](https://platform.openai.com/docs/api-reference/chat/create) using `completionParams`:
```ts
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
completionParams: {
model: 'gpt-4',
temperature: 0.5,
top_p: 0.8
}
@ -280,8 +321,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 })
@ -330,10 +374,10 @@ const api = new ChatGPTUnofficialProxyAPI({
Known reverse proxies run by community members include:
| Reverse Proxy URL | Author | Rate Limits | Last Checked |
| ------------------------------------------------ | -------------------------------------------- | ----------------- | ------------ |
| `https://bypass.duti.tech/api/conversation` | [@acheong08](https://github.com/acheong08) | 5 req / 10 seconds by IP | 3/11/2023 |
| `https://gpt.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | ? | 2/19/2023 |
| Reverse Proxy URL | Author | Rate Limits | Last Checked |
| ------------------------------------------------- | -------------------------------------------- | ---------------------------- | ------------ |
| `https://ai.fakeopen.com/api/conversation` | [@pengzhile](https://github.com/pengzhile) | 5 req / 10 seconds by IP | 4/18/2023 |
| `https://api.pawan.krd/backend-api/conversation` | [@PawanOsman](https://github.com/PawanOsman) | 50 req / 15 seconds (~3 r/s) | 3/23/2023 |
Note: info on how the reverse proxies work is not being published at this time in order to prevent OpenAI from disabling access.
@ -422,6 +466,7 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Telegram Bot #2](https://github.com/dawangraoming/chatgpt-telegram-bot)
- [Telegram Bot #3](https://github.com/RainEggplant/chatgpt-telegram-bot) (group privacy mode, ID-based auth)
- [Telegram Bot #4](https://github.com/ArdaGnsrn/chatgpt-telegram) (queue system, ID-based chat thread)
- [Telegram Bot #5](https://github.com/azoway/chatgpt-telegram-bot) (group privacy mode, ID-based chat thread)
- [Deno Telegram Bot](https://github.com/Ciyou/chatbot-telegram)
- [Go Telegram Bot](https://github.com/m1guelpf/chatgpt-telegram)
- [Telegram Bot for YouTube Summaries](https://github.com/codextde/youtube-summary)
@ -432,16 +477,21 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Discord Bot #4 (selfbot)](https://github.com/0x7030676e31/cumsocket)
- [Discord Bot #5](https://github.com/itskdhere/ChatGPT-Discord-BOT)
- [Discord Bot #6 (Shakespeare bot)](https://gist.github.com/TheBrokenRail/4b37e7c44e8f721d8bd845050d034c16)
- [Discord Bot #7](https://github.com/Elitezen/discordjs-chatgpt)
- [Zoom Chat](https://github.com/shixin-guo/my-bot)
- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)
- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)
- [WeChat Bot #3](https://github.com/wangrongding/wechat-bot) (
- [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)
- [QQ Bot (oicq + RabbitMQ)](https://github.com/linsyking/ChatGPT-QQBot)
- [QQ Bot (go-cqhttp)](https://github.com/PairZhu/ChatGPT-QQRobot)
- [QQ Bot (plugin for Yunzai-Bot + Bull)](https://github.com/Micuks/chatGPT-yunzai) (Lightweight, Google Bard support 💪)
- [EXM smart contracts](https://github.com/decentldotland/molecule)
- [Flutter ChatGPT API](https://github.com/coskuncay/flutter_chatgpt_api)
- [Carik Bot](https://github.com/luridarmawan/Carik)
@ -464,6 +514,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)
@ -482,6 +534,11 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Next.js ChatGPT With Firebase](https://github.com/youngle316/chatgpt)
- [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 CLI
- [OpenAI-API-Service](https://github.com/Jarvan-via/api-service) - Provides OpenAI related APIs for businesses
- [Discord Daily News Bot](https://github.com/ZirionNeft/chatgpt-discord-daily-news-bot) - Discord bot that generate funny daily news
- [ai-assistant](https://github.com/chenweiyi/ai-assistant) - Create a chat website similar to ChatGPT
If you create a cool integration, feel free to open a PR and add it to the list.
@ -497,8 +554,8 @@ If you create a cool integration, feel free to open a PR and add it to the list.
## Credits
- Huge thanks to [@waylaidwanderer](https://github.com/waylaidwanderer), [@abacaj](https://github.com/abacaj), [@wong2](https://github.com/wong2), [@simon300000](https://github.com/simon300000), [@RomanHotsiy](https://github.com/RomanHotsiy), [@ElijahPepe](https://github.com/ElijahPepe), and all the other contributors 💪
- The original browser version was inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)
- [OpenAI](https://openai.com) for creating [ChatGPT](https://openai.com/blog/chatgpt/) 🔥
- I run the [ChatGPT Hackers Discord](https://www.chatgpthackers.dev/) with over 8k developers – come join us!
## License

Wyświetl plik

@ -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

Wyświetl plik

@ -218,9 +218,14 @@ export class ChatGPTUnofficialProxyAPI {
}
}
} catch (err) {
// ignore for now; there seem to be some non-json messages
// console.warn('fetchSSE onMessage unexpected error', err)
if (this._debug) {
console.warn('chatgpt unexpected JSON error', err)
}
// reject(err)
}
},
onError: (err) => {
reject(err)
}
},
this._fetch

Wyświetl plik

@ -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)
}
}
}

Wyświetl plik

@ -1,8 +1,8 @@
import { get_encoding } from '@dqbd/tiktoken'
import { getEncoding } from 'js-tiktoken'
// TODO: make this configurable
const tokenizer = get_encoding('cl100k_base')
const tokenizer = getEncoding('cl100k_base')
export function encode(input: string): Uint32Array {
return tokenizer.encode(input)
return new Uint32Array(tokenizer.encode(input))
}

Wyświetl plik

@ -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
*/