Skip to content

Commit

Permalink
Merge pull request #473 from SmileSmith/v3
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit authored Mar 15, 2023
2 parents 168ab1f + 4f03478 commit 4f6077d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/chatgpt-api-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
constructor(opts: {
email: string
password: string
model?: string

/** @defaultValue `false` **/
isProAccount?: boolean
Expand Down Expand Up @@ -88,6 +89,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
const {
email,
password,
model,
isProAccount = false,
markdown = true,
debug = false,
Expand Down Expand Up @@ -443,6 +445,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
opts: types.SendMessageOptions = {}
): Promise<types.ChatResponse> {
const {
model,
conversationId,
parentMessageId = uuidv4(),
messageId = uuidv4(),
Expand All @@ -464,9 +467,11 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
}
],
model: this._isProAccount
model: model
? model
: this._isProAccount
? 'text-davinci-002-render-paid'
: 'text-davinci-002-render',
: 'text-davinci-002-render-sha',
parent_message_id: parentMessageId
}

Expand Down
2 changes: 1 addition & 1 deletion src/chatgpt-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class ChatGPTAPI extends AChatGPTAPI {
}
}
],
model: 'text-davinci-002-render',
model: 'text-davinci-002-render-sha',
parent_message_id: parentMessageId
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export type SendMessageOptions = {
timeoutMs?: number
onProgress?: (partialResponse: ChatResponse) => void
abortSignal?: AbortSignal
model?: string
}

export type SendConversationMessageOptions = Omit<
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export async function browserPostEventStream(
error: {
message: `ChatGPTAPI error ${res.status || res.statusText}`,
statusCode: res.status,
statusText: res.statusText
statusText: res.statusText || (await res.text())

This comment has been minimized.

Copy link
@leadscloud

leadscloud Apr 8, 2023

这个地方如此修改有问题
会出现如下错误
TypeError: Failed to execute 'text' on 'Response': body stream already read

前面已经有res.json()了,这用再使用res.text()就会出现上面的提示错误,导致这个return raise exception

},
conversationId,
messageId
Expand Down

0 comments on commit 4f6077d

Please sign in to comment.