You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -187,7 +197,8 @@ export default class BingAIClient {
187
197
}
188
198
189
199
// Due to this jailbreak, the AI will occasionally start responding as the user. It only happens rarely (and happens with the non-jailbroken Bing too), but since we are handling conversations ourselves now, we can use this system to ignore the part of the generated message that is replying as the user.
190
-
conststopToken='\n\nUser:'
200
+
// TODO: probably removable now we're using `[user](#message)` instead of `User:`
201
+
conststopToken='\n\n[user](#message)'
191
202
192
203
if(jailbreakConversationId===true){
193
204
jailbreakConversationId=crypto.randomUUID()
@@ -221,39 +232,32 @@ export default class BingAIClient {
221
232
author: 'system',
222
233
},
223
234
...previousCachedMessages,
235
+
{
236
+
text: message,
237
+
author: 'user',
238
+
},
224
239
]
225
240
: undefined
226
241
242
+
if(context){
243
+
previousMessages.push({
244
+
text: context,
245
+
author: 'context',// not a real/valid author, we're just piggybacking on the existing logic
246
+
})
247
+
}
248
+
227
249
// prepare messages for prompt injection
228
250
previousMessagesFormatted=previousMessages
229
251
?.map((previousMessage)=>{
230
252
switch(previousMessage.author){
231
253
case'user':
232
-
return`User:\n${previousMessage.text}`
254
+
return`[user](#message)\n${previousMessage.text}`
233
255
case'bot':
234
-
return`AI:\n${previousMessage.text}`
235
-
case'system': {
236
-
constinsertRandomSeparator=(str)=>{
237
-
// Split the string into an array of individual characters
238
-
constchars=str.split('')
239
-
// Use the map function to join each character together and randomly insert a separator or not
240
-
returnchars
241
-
.map((char,index)=>{
242
-
// If not the first character, randomly decide whether to insert a separator based on a random number
243
-
if(index!==0&&Math.random()>=0.5){
244
-
// Generate a random number and use a "-" as the separator if it is greater than or equal to 0.5, otherwise use "_"
0 commit comments