Skip to content

Commit

Permalink
Merge branch 'main' into fix/defer-save
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 2, 2023
2 parents 44a4a91 + 0f966dc commit 81caf0b
Show file tree
Hide file tree
Showing 21 changed files with 390 additions and 291 deletions.
12 changes: 11 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -50,6 +55,7 @@ async function main() {
options.continue && options.store
? config.get(conversationKey, {}) || {}
: {}
const model = options.model
let conversationId = undefined
let parentMessageId = undefined

Expand All @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/ChatGPTAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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:49](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L49)

## Accessors

Expand All @@ -46,7 +46,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:311](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L311)

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

Expand All @@ -62,7 +62,7 @@ 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:315](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L315)

## Methods

Expand Down Expand Up @@ -94,4 +94,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:132](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/chatgpt-api.ts#L132)
8 changes: 4 additions & 4 deletions docs/classes/ChatGPTError.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:80](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L80)

___

Expand All @@ -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:79](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L79)

___

Expand All @@ -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:77](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L77)

___

Expand All @@ -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:78](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L78)
8 changes: 4 additions & 4 deletions docs/classes/ChatGPTUnofficialProxyAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts: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/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L20)

## Accessors

Expand All @@ -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/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L66)

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

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

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts: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/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L70)

## Methods

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

#### Defined in

[src/chatgpt-unofficial-proxy-api.ts: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/9eac18f/src/chatgpt-unofficial-proxy-api.ts#L97)
16 changes: 8 additions & 8 deletions docs/interfaces/ChatMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:73](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L73)

___

Expand All @@ -33,7 +33,7 @@ ___

#### Defined in

[src/types.ts:64](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L64)
[src/types.ts:67](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L67)

___

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

#### Defined in

[src/types.ts:65](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L65)
[src/types.ts:68](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L68)

___

Expand All @@ -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:63](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L63)

___

Expand All @@ -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:66](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L66)

___

Expand All @@ -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:71](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L71)

___

Expand All @@ -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:65](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L65)

___

Expand All @@ -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:64](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L64)
6 changes: 3 additions & 3 deletions docs/interfaces/openai.ChatCompletionRequestMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ChatCompletionRequestMessage

#### Defined in

[src/types.ts:208](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L208)
[src/types.ts:211](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L211)

___

Expand All @@ -48,7 +48,7 @@ ChatCompletionRequestMessage

#### Defined in

[src/types.ts:214](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L214)
[src/types.ts:217](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L217)

___

Expand All @@ -64,4 +64,4 @@ ChatCompletionRequestMessage

#### Defined in

[src/types.ts:202](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L202)
[src/types.ts:205](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L205)
4 changes: 2 additions & 2 deletions docs/interfaces/openai.ChatCompletionResponseMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ChatCompletionResponseMessage

#### Defined in

[src/types.ts:240](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L240)
[src/types.ts:243](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L243)

___

Expand All @@ -47,4 +47,4 @@ ChatCompletionResponseMessage

#### Defined in

[src/types.ts:234](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L234)
[src/types.ts:237](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L237)
10 changes: 5 additions & 5 deletions docs/interfaces/openai.CreateChatCompletionDeltaResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#### Defined in

[src/types.ts:179](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L179)
[src/types.ts:182](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L182)

___

Expand All @@ -32,7 +32,7 @@ ___

#### Defined in

[src/types.ts:177](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L177)
[src/types.ts:180](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L180)

___

Expand All @@ -42,7 +42,7 @@ ___

#### Defined in

[src/types.ts:175](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L175)
[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L178)

___

Expand All @@ -52,7 +52,7 @@ ___

#### Defined in

[src/types.ts:178](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L178)
[src/types.ts:181](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L181)

___

Expand All @@ -62,4 +62,4 @@ ___

#### Defined in

[src/types.ts:176](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L176)
[src/types.ts:179](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L179)
24 changes: 12 additions & 12 deletions docs/interfaces/openai.CreateChatCompletionRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:314](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L314)
[src/types.ts:317](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L317)

___

Expand All @@ -57,7 +57,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:320](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L320)
[src/types.ts:323](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L323)

___

Expand All @@ -73,7 +73,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:302](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L302)
[src/types.ts:305](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L305)

___

Expand All @@ -89,7 +89,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:266](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L266)
[src/types.ts:269](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L269)

___

Expand All @@ -105,7 +105,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:260](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L260)
[src/types.ts:263](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L263)

___

Expand All @@ -121,7 +121,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:284](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L284)
[src/types.ts:287](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L287)

___

Expand All @@ -137,7 +137,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:308](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L308)
[src/types.ts:311](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L311)

___

Expand All @@ -151,7 +151,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:296](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L296)
[src/types.ts:299](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L299)

___

Expand All @@ -167,7 +167,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:290](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L290)
[src/types.ts:293](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L293)

___

Expand All @@ -183,7 +183,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:272](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L272)
[src/types.ts:275](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L275)

___

Expand All @@ -199,7 +199,7 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:278](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L278)
[src/types.ts:281](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L281)

___

Expand All @@ -215,4 +215,4 @@ CreateChatCompletionRequest

#### Defined in

[src/types.ts:326](https://github.com/transitive-bullshit/chatgpt-api/blob/c4ffe53/src/types.ts#L326)
[src/types.ts:329](https://github.com/transitive-bullshit/chatgpt-api/blob/9eac18f/src/types.ts#L329)

0 comments on commit 81caf0b

Please sign in to comment.