Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
feat(Bing): add model selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Weiss committed Dec 18, 2023
1 parent 701fd41 commit 29c8bcc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
10 changes: 9 additions & 1 deletion Intelligence_Questions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ red, blue, black, yellow
Shifting first book:
blue, black, yellow, red
Answer: black
R4: Not always solved correctly by GPT-4.
R4: Not always solved correctly by GPT-4.

Q5: I have three apples today and I ate one yesterday. How many apples do I have today?
A5: You have 3 apples today.

Q6: Please count the ocurrence of every letter (case doesn't matter) in the following text using Python and format the output in a table:
`White Horse" is a single by Taylor Swift (pictured) from her second studio album, Fearless. A country pop song, the ballad is driven by a finger-picked guitar and includes piano and cello accents. The lyrics incorporate fairy-tale imagery of princesses and white horses: a narrator is heartbroken that her boyfriend is not an ideal figure and leaves her town to find another partner. Big Machine Records released the track to US country radio on December 8, 2008. Music critics lauded "White Horse" for its somber production and portrayal of heartbreak, but some found the lyrics uncreative. In 2010, the song won Grammy Awards for Best Country Song and Best Female Country Vocal Performance. In the US, the single peaked at number 13 on the Billboard Hot 100 and number 2 on the Hot Country Songs chart. It was also certified in the US, Australia and Canada. Following a 2019 dispute regarding the ownership of Swift's back catalog, she re-recorded the song for her album Fearless (Taylor's Version).`

TODO: Add harder questions for Turbo.
2 changes: 2 additions & 0 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ server.post('/conversation', async (request, reply) => {
invocationId,
jailbreakConversationId,
toneStyle,
modelVersion,
systemMessage,
plugins,
} = body;
Expand All @@ -130,6 +131,7 @@ server.post('/conversation', async (request, reply) => {
...(clientToUseForMessage === 'bing' && { invocationId }),
...(clientToUseForMessage === 'bing' && { jailbreakConversationId }),
...(clientToUseForMessage === 'bing' && { toneStyle }),
...(clientToUseForMessage === 'bing' && { modelVersion }),
...((clientToUseForMessage === 'bing') && { systemMessage }),
...((clientToUseForMessage === 'bing') && { plugins }),
onProgress,
Expand Down
45 changes: 32 additions & 13 deletions src/BingAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ export default class BingAIClient {
const {
invocationId = 0,
systemMessage,
toneStyle,
modelVersion,
context = jailbreakConversationId ? process.env.CONTEXT : null,
parentMessageId = jailbreakConversationId === true ? crypto.randomUUID() : null,
abortController = new AbortController(),
Expand Down Expand Up @@ -429,6 +431,8 @@ export default class BingAIClient {
conversationSignature,
clientId,
conversationId,
toneStyle,
modelVersion,
...imageUploadResult && { imageUploadResult },
plugins,
noSearch,
Expand Down Expand Up @@ -530,7 +534,19 @@ export default class BingAIClient {
* @returns {Object} Object that contains all necessary properties for sending the user message.
*/
static createUserWebsocketRequest(webSocketParameters) {
const toneStyle = 'creative';
const {
message,
invocationId,
jailbreakConversationId,
conversationSignature,
clientId,
conversationId,
toneStyle,
modelVersion,
imageUploadResult = undefined,
plugins,
noSearch,
} = webSocketParameters;
let toneOption;
if (toneStyle === 'creative') {
toneOption = 'h3imaginative';
Expand All @@ -543,17 +559,7 @@ export default class BingAIClient {
// old "Balanced" mode
toneOption = 'harmonyv3';
}
const {
message,
invocationId,
jailbreakConversationId,
conversationSignature,
clientId,
conversationId,
imageUploadResult = undefined,
plugins,
noSearch,
} = webSocketParameters;
const modelVersionString = this.#resolveModelVersion(modelVersion);
const imageBaseURL = 'https://www.bing.com/images/blob?bcid=';

const userWebsocketRequest = {
Expand All @@ -580,7 +586,7 @@ export default class BingAIClient {
'eredirecturl',
'clgalileo',
'gencontentv3',
'fluxv14l',
...(modelVersionString !== '' ? [modelVersionString] : []),
...(noSearch !== undefined ? [noSearch] : []),
],
allowedMessageTypes: [
Expand Down Expand Up @@ -647,6 +653,19 @@ export default class BingAIClient {
return userWebsocketRequest;
}

static #resolveModelVersion(modelVersion) {
let optionSetString = '';
switch (modelVersion) {
case 'gpt-4 turbo':
optionSetString = 'gpt4t';
break;
default:
optionSetString = '';
}

return optionSetString;
}

/**
* Used for creating the reply from the AI.
* @param {WebSocket} ws The websocket the listener for the "message" even should be declared for.
Expand Down

0 comments on commit 29c8bcc

Please sign in to comment.