kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: support conversationID for ChatGPTAPI
rodzic
9932fca55c
commit
fa53d8606d
|
@ -120,6 +120,7 @@ export class ChatGPTAPI {
|
||||||
*
|
*
|
||||||
* @param message - The prompt message to send
|
* @param message - The prompt message to send
|
||||||
* @param opts.parentMessageId - Optional ID of the previous message in the conversation (defaults to `undefined`)
|
* @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.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.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)
|
* @param opts.timeoutMs - Optional timeout in milliseconds (defaults to no timeout)
|
||||||
|
@ -139,7 +140,8 @@ export class ChatGPTAPI {
|
||||||
timeoutMs,
|
timeoutMs,
|
||||||
onProgress,
|
onProgress,
|
||||||
stream = onProgress ? true : false,
|
stream = onProgress ? true : false,
|
||||||
completionParams
|
completionParams,
|
||||||
|
conversationId = ''
|
||||||
} = opts
|
} = opts
|
||||||
|
|
||||||
let { abortSignal } = opts
|
let { abortSignal } = opts
|
||||||
|
@ -154,7 +156,8 @@ export class ChatGPTAPI {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
id: messageId,
|
id: messageId,
|
||||||
parentMessageId,
|
parentMessageId,
|
||||||
text
|
text,
|
||||||
|
conversationId
|
||||||
}
|
}
|
||||||
await this._upsertMessage(message)
|
await this._upsertMessage(message)
|
||||||
|
|
||||||
|
@ -167,7 +170,8 @@ export class ChatGPTAPI {
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
parentMessageId: messageId,
|
parentMessageId: messageId,
|
||||||
text: ''
|
text: '',
|
||||||
|
conversationId
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseP = new Promise<types.ChatMessage>(
|
const responseP = new Promise<types.ChatMessage>(
|
||||||
|
|
|
@ -36,6 +36,7 @@ export type SendMessageOptions = {
|
||||||
/** The name of a user in a multi-user chat. */
|
/** The name of a user in a multi-user chat. */
|
||||||
name?: string
|
name?: string
|
||||||
parentMessageId?: string
|
parentMessageId?: string
|
||||||
|
conversationId?: string
|
||||||
messageId?: string
|
messageId?: string
|
||||||
stream?: boolean
|
stream?: boolean
|
||||||
systemMessage?: string
|
systemMessage?: string
|
||||||
|
|
Ładowanie…
Reference in New Issue