Merge pull request #505 from 189/feat/conversationId

remotes/origin/main
Travis Fischer 2023-04-02 11:32:17 -05:00 zatwierdzone przez GitHub
commit 8ad7ba9a1d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -124,6 +124,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)
@ -143,7 +144,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
@ -158,7 +160,8 @@ export class ChatGPTAPI {
role: 'user', role: 'user',
id: messageId, id: messageId,
parentMessageId, parentMessageId,
text text,
conversationId
} }
const latestQuestion = message const latestQuestion = message
@ -172,7 +175,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>(

Wyświetl plik

@ -38,6 +38,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