Skip to content

Commit

Permalink
Merge pull request #505 from 189/feat/conversationId
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 2, 2023
2 parents 3f5d8e6 + fa53d86 commit 8ad7ba9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/chatgpt-api.ts
Expand Up @@ -124,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)
Expand All @@ -143,7 +144,8 @@ export class ChatGPTAPI {
timeoutMs,
onProgress,
stream = onProgress ? true : false,
completionParams
completionParams,
conversationId = ''
} = opts

let { abortSignal } = opts
Expand All @@ -158,7 +160,8 @@ export class ChatGPTAPI {
role: 'user',
id: messageId,
parentMessageId,
text
text,
conversationId
}

const latestQuestion = message
Expand All @@ -172,7 +175,8 @@ export class ChatGPTAPI {
role: 'assistant',
id: uuidv4(),
parentMessageId: messageId,
text: ''
text: '',
conversationId
}

const responseP = new Promise<types.ChatMessage>(
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Expand Up @@ -38,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
Expand Down

0 comments on commit 8ad7ba9

Please sign in to comment.