|
1 | 1 | // https://github.com/waylaidwanderer/node-chatgpt-api |
2 | 2 |
|
| 3 | +import { v4 as uuidv4 } from 'uuid' |
| 4 | + |
3 | 5 | /** |
4 | 6 | * https://stackoverflow.com/a/58326357 |
5 | 7 | * @param {number} size |
@@ -52,7 +54,7 @@ export default class BingAIClient { |
52 | 54 | 'sec-fetch-dest': 'empty', |
53 | 55 | 'sec-fetch-mode': 'cors', |
54 | 56 | 'sec-fetch-site': 'same-origin', |
55 | | - 'x-ms-client-request-id': crypto.randomUUID(), |
| 57 | + 'x-ms-client-request-id': uuidv4(), |
56 | 58 | 'x-ms-useragent': |
57 | 59 | 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32', |
58 | 60 | cookie: this.options.cookies || `_U=${this.options.userToken}`, |
@@ -164,7 +166,7 @@ export default class BingAIClient { |
164 | 166 | invocationId = 0, |
165 | 167 | systemMessage, |
166 | 168 | context, |
167 | | - parentMessageId = jailbreakConversationId === true ? crypto.randomUUID() : null, |
| 169 | + parentMessageId = jailbreakConversationId === true ? uuidv4() : null, |
168 | 170 | abortController = new AbortController(), |
169 | 171 | } = opts |
170 | 172 |
|
@@ -201,7 +203,7 @@ export default class BingAIClient { |
201 | 203 | const stopToken = '\n\n[user](#message)' |
202 | 204 |
|
203 | 205 | if (jailbreakConversationId === true) { |
204 | | - jailbreakConversationId = crypto.randomUUID() |
| 206 | + jailbreakConversationId = uuidv4() |
205 | 207 | } |
206 | 208 |
|
207 | 209 | const conversationKey = jailbreakConversationId |
@@ -266,7 +268,7 @@ export default class BingAIClient { |
266 | 268 | } |
267 | 269 |
|
268 | 270 | const userMessage = { |
269 | | - id: crypto.randomUUID(), |
| 271 | + id: uuidv4(), |
270 | 272 | parentMessageId, |
271 | 273 | role: 'User', |
272 | 274 | message, |
@@ -503,7 +505,7 @@ export default class BingAIClient { |
503 | 505 | const { message: reply, conversationExpiryTime } = await messagePromise |
504 | 506 |
|
505 | 507 | const replyMessage = { |
506 | | - id: crypto.randomUUID(), |
| 508 | + id: uuidv4(), |
507 | 509 | parentMessageId: userMessage.id, |
508 | 510 | role: 'Bing', |
509 | 511 | message: reply.text, |
|
0 commit comments