Skip to content

Commit 89db9cd

Browse files
likevJoel
andauthored
feat(bing): support choosing a conversation style (#141)
* support choose a conversation style of BingAI * Apply suggestions from code review Co-authored-by: Joel <[email protected]> * quotes are fixed --------- Co-authored-by: Joel <[email protected]>
1 parent 596d18b commit 89db9cd

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

demos/use-bing-client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let response = await bingAIClient.sendMessage('Write a short poem about cats', {
2121
console.log(response);
2222

2323
response = await bingAIClient.sendMessage('Now write it in French', {
24+
toneStyle: 'balanced', //or creative, precise
2425
conversationSignature: response.conversationSignature,
2526
conversationId: response.conversationId,
2627
clientId: response.clientId,

src/BingAIClient.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export default class BingAIClient {
121121
opts = {},
122122
) {
123123
let {
124+
toneStyle = 'balanced', //or creative, precise
124125
conversationSignature,
125126
conversationId,
126127
clientId,
@@ -150,26 +151,35 @@ export default class BingAIClient {
150151

151152
const ws = await this.createWebSocketConnection();
152153

154+
let toneOption;
155+
if (toneStyle === 'creative') {
156+
toneOption = 'h3imaginative';
157+
} else if (toneStyle === 'precise') {
158+
toneOption = 'h3precise';
159+
} else {
160+
toneOption = 'harmonyv3';
161+
}
162+
153163
const obj = {
154164
arguments: [
155165
{
156166
source: 'cib',
157167
optionsSets: [
158168
'nlu_direct_response_filter',
159169
'deepleo',
160-
'enable_debug_commands',
161170
'disable_emoji_spoken_text',
162171
'responsible_ai_policy_235',
163172
'enablemm',
164-
'harmonyv3',
173+
toneOption,
165174
'dtappid',
166-
'dloffstream',
167-
'dv3sugg',
175+
'cricinfo',
176+
'cricinfov2',
177+
'dv3sugg'
168178
],
169179
sliceIds: [
170180
'222dtappid',
171-
'216dloffstream',
172-
'225cricinfos0',
181+
'225cricinfo',
182+
'224locals0'
173183
],
174184
traceId: genRanHex(32),
175185
isStartOfSession: invocationId === 0,

0 commit comments

Comments
 (0)