diff --git a/README.md b/README.md index 0d93d7c0..fbd21f2d 100644 --- a/README.md +++ b/README.md @@ -139,16 +139,16 @@ This section will elaborate the parameters that are specific to Bing Chat that a - `conversationSignature`: Empty for first request and used for subsequent requests - `conversationId`: Empty for first request and used for subsequent requests - `jailbreakConversationId`: Set to `true` for first request to enable jailbreak mode and used for subsequent requests -- `toneStyle`: The mode Bing should use. Valid values are `["creative", "fast", "precise"]` +- `toneStyle`: The mode Bing should use. Valid values are `["creative", "turbo", "balanced", "precise"]` - `invocationId`: The index of the message. Empty for first message and gets incremented by one for each ended user turn. - `imageBase64`: (optional) base64 string of an image bing should analyze - `imageURL`: (optional) URL of an image that Bing should analyze. Has precedence over imageBase64 if both parameters are passed. -- `modelVersion`: Used to toggle between models. Passing `gpt-4 turbo` will use GPT-4 Turbo (be aware that Turbo is Copilot Pro only at the present date). Any other string uses the default model defined by the optionSet -- `systemMessage`: Used when enabling jailbreak mode. Add another system message to the AI. +- `systemMessage`: Used when jailbreak mode is enabled. Adds another system message to the AI. - `showSuggestions`: Toggles the three suggestions by the suggestion AI to be returned - `useBase64`: Adds a section to the system message to tell the AI to use base64 -- `userUserSuffixMessage`: Adds a message by the user reading `Continue the message in the current Context` which will prevent the moderation filter to trigger for user messages, but may confuse the AI +- `useUserSuffixMessage`: Adds a message by the user reading `Continue the message in the current Context` which will prevent the moderation filter to trigger for user messages, but may confuse the AI - `plugins`: Enables the plugins in the array with the value `true`. See the `#resolvePlugins` method in the `BingAIClient.js` class for valid plugins +- `persona`: Enables a Microsoft custom GPT. See the `#resolvePersona` method in the `BingAIClient.js` class for valid personas # ChatGPT API diff --git a/bin/server.js b/bin/server.js index cd1dbdd0..de86693d 100755 --- a/bin/server.js +++ b/bin/server.js @@ -114,7 +114,6 @@ server.post('/conversation', async (request, reply) => { invocationId, jailbreakConversationId, toneStyle, - modelVersion, systemMessage, showSuggestions, useBase64, @@ -135,7 +134,6 @@ server.post('/conversation', async (request, reply) => { ...(clientToUseForMessage === 'bing' && { invocationId }), ...(clientToUseForMessage === 'bing' && { jailbreakConversationId }), ...(clientToUseForMessage === 'bing' && { toneStyle }), - ...(clientToUseForMessage === 'bing' && { modelVersion }), ...(clientToUseForMessage === 'bing' && { systemMessage }), ...(clientToUseForMessage === 'bing' && { showSuggestions }), ...(clientToUseForMessage === 'bing' && { useBase64 }), diff --git a/src/BingAIClient.js b/src/BingAIClient.js index 13d1abdf..d1ade86f 100644 --- a/src/BingAIClient.js +++ b/src/BingAIClient.js @@ -75,7 +75,6 @@ export default class BingAIClient { const { invocationId = 0, toneStyle, - modelVersion, persona, context = jailbreakConversationId ? process.env.CONTEXT : null, parentMessageId = jailbreakConversationId === true ? crypto.randomUUID() : null, @@ -183,7 +182,6 @@ export default class BingAIClient { clientId, conversationId, toneStyle, - modelVersion, ...imageUploadResult && { imageUploadResult }, plugins, useBase64: opts.useBase64, @@ -375,7 +373,6 @@ export default class BingAIClient { clientId, conversationId, toneStyle, - modelVersion, imageUploadResult = undefined, plugins, useBase64, @@ -383,23 +380,12 @@ export default class BingAIClient { noSearch, persona, } = webSocketParameters; - let toneOption; - if (toneStyle === 'creative') { - toneOption = 'h3imaginative'; - } else if (toneStyle === 'precise') { - toneOption = 'h3precise'; - } else if (toneStyle === 'fast') { - // new "Balanced" mode, allegedly GPT-3.5 turbo - toneOption = 'galileo'; - } else { - // old "Balanced" mode - toneOption = 'harmonyv3'; - } - const modelVersionString = this.#resolveModelVersion(modelVersion); + const imageBaseURL = 'https://www.bing.com/images/blob?bcid='; - const pluginIds = plugins.map(plugin => ({ id: plugin.id })).filter(Boolean); + const pluginIds = plugins.map(plugin => ({ id: plugin.id, category: 1 })).filter(Boolean); const pluginOptionSets = plugins.map(plugin => plugin.optionSet).filter(Boolean); const personaString = this.#resolvePersona(persona); + const tone = this.#resolveTone(toneStyle); let userMessageSuffix; if (useUserSuffixMessage === true) { @@ -415,29 +401,22 @@ export default class BingAIClient { const userWebsocketRequest = { arguments: [ { - source: 'cib', + source: 'cib-ccp', optionsSets: [ 'nojbfedge', // Not included in standard message, but won't work without. 'nlu_direct_response_filter', 'deepleo', 'disable_emoji_spoken_text', 'responsible_ai_policy_235', - // "enablemm", + // 'enablemm', 'dv3sugg', - // "autosave", - 'iyxapbing', - 'iycapbing', - toneOption, - 'spktxtibmoff', - 'enelecintl', - 'gndelec', - 'gndlogcf', - 'gptvmodel2', + // 'autosave', + 'uquopt', + 'bicfluxv2', + 'langdtwb', + 'fluxprod', 'eredirecturl', - 'clgalileo', - 'gencontentv3', ...(personaString !== '' ? [personaString] : []), - ...(modelVersionString !== '' ? [modelVersionString] : []), ...(noSearch !== undefined ? [noSearch] : []), ...pluginOptionSets, ], @@ -447,39 +426,17 @@ export default class BingAIClient { 'Context', 'InternalSearchQuery', 'InternalSearchResult', - // 'Disengage', unwanted 'InternalContentDescription', 'InternalLoaderMessage', 'Progress', - // 'RenderCardRequest', not useful - // 'AdsQuery', unwanted - // 'SemanticSerp',// usually not encountered, related to semantic web search 'GenerateContentQuery', 'SearchQuery', + 'GeneratedCode', ], - sliceIds: [ - 'cruiseenableux', - 'adssqovr', - 'cruiseenable', - 'e2eperf', - 'arankc_1_9_9', - 'rankcf', - 'multlingcf', - 'stibmoff', - 'caccnctat3', - 'styleoffwpt', - 'preall20', - '1117gndelec', - '1115rai289s0', - '117invocmaxs0', - '1025gptv_v2', - 'fluxnosearch', - '1115fluxv14l', - 'codecreatorcf', - 'cacmuidarb', - ], + sliceIds: [], plugins: pluginIds, traceId: genRanHex(32), + gptId: persona, isStartOfSession: invocationId === 0, message: { ...imageUploadResult @@ -488,8 +445,9 @@ export default class BingAIClient { && { originalImageUrl: `${imageBaseURL}${imageUploadResult.processBlobId}` }, author: 'user', text: useUserSuffixMessage ? userMessageSuffix : message, - messageType: jailbreakConversationId ? 'SearchQuery' : 'Chat', + messageType: 'Chat', }, + tone, conversationSignature, participant: { id: clientId, @@ -506,19 +464,6 @@ export default class BingAIClient { return userWebsocketRequest; } - static #resolveModelVersion(modelVersion) { - let optionSetString = ''; - switch (modelVersion) { - case 'gpt-4 turbo': - optionSetString = 'gpt4t'; - break; - default: - optionSetString = ''; - } - - return optionSetString; - } - /** * This method converts persona names from simple names to technical names. * @param {String | undefined} persona Simple name of the persona to use. @@ -530,13 +475,13 @@ export default class BingAIClient { case 'designer': personaString = 'ai_persona_designer_gpt'; break; - case 'vacation_planner': + case 'travel': personaString = 'flux_vacation_planning_helper_v14'; break; - case 'cooking_assistant': + case 'cooking': personaString = 'flux_cooking_helper_v14'; break; - case 'fitness_trainer': + case 'fitness': personaString = 'flux_fitness_helper_v14'; break; case 'copilot': @@ -604,6 +549,28 @@ export default class BingAIClient { return resolvedPlugins; } + /** + * This method converts toneStyles from simple names to technical names. + * @param {String | undefined} toneStyle Simple name of the tone to use. + * @returns {String} Technical name of the tone to use. + */ + static #resolveTone(toneStyle) { + let tone; + if (toneStyle === 'creative') { + tone = 'CreativeClassic'; + } else if (toneStyle === 'turbo') { + tone = 'Creative'; + } else if (toneStyle === 'precise') { + tone = 'Precise'; + } else if (toneStyle === 'balanced') { + tone = 'Balanced'; + } else { + tone = 'CreativeClassic'; + } + + return tone; + } + /** * Used for creating the reply from the AI. * @param {WebSocket} ws The websocket the listener for the "message" even should be declared for. @@ -677,7 +644,8 @@ export default class BingAIClient { || messages[0]?.messageType === 'InternalSearchQuery' || messages[0]?.messageType === 'InternalSearchResult' || (messages[0]?.messageType === 'Progress' && messages[0]?.contentOrigin !== 'CodeInterpreter') - || messages[0]?.messageType === 'RenderCardRequest') { + || messages[0]?.messageType === 'RenderCardRequest' + || messages[0]?.messageType === 'GeneratedCode') { return; } if (messages[0]?.contentOrigin === 'CodeInterpreter' && messages[0]?.invocation) {