Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ if (settings.storageFilePath && !settings.cacheOptions.store) {
settings.cacheOptions.store = new KeyvFile({ filename: settings.storageFilePath });
}

// Disable the image generation in cli mode always.
settings.bingAiClient.features = settings.bingAiClient.features || {};
settings.bingAiClient.features.genImage = false;
// Kick bing's the image generation options for cli.
const enableBicImage = {
enable: settings.bingAiClient?.features?.genImage?.cli?.enable
|| (settings.bingAiClient?.features ? false : (settings.bingAiClient.features = {}, false)),
type: settings.bingAiClient?.features?.genImage?.cli?.type || 'markdown_list',
};
if (enableBicImage.type === 'iframe' || !BingAIClient.isValidBicType(enableBicImage.type)) {
enableBicImage.type = 'markdown_list';
}
settings.bingAiClient.features.genImage = enableBicImage;

let conversationData = {};

Expand Down
12 changes: 12 additions & 0 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ if (settings.storageFilePath && !settings.cacheOptions.store) {
settings.cacheOptions.store = new KeyvFile({ filename: settings.storageFilePath });
}

// Kick bing's the image generation options for server.
const enableBicImage = {
enable: settings.bingAiClient?.features?.genImage?.server?.enable
|| (settings.bingAiClient?.features ? false : (settings.bingAiClient.features = {}, false))
|| (typeof settings.bingAiClient.features?.genImage === 'boolean' ? settings.bingAiClient.features.genImage : false),
type: settings.bingAiClient?.features?.genImage?.server?.type || 'iframe',
};
if (!BingAIClient.isValidBicType(enableBicImage.type)) {
enableBicImage.type = 'markdown_list';
}
settings.bingAiClient.features.genImage = enableBicImage;

const clientToUse = settings.apiOptions?.clientToUse || settings.clientToUse || 'chatgpt';
const perMessageClientOptionsWhitelist = settings.apiOptions?.perMessageClientOptionsWhitelist || null;

Expand Down
25 changes: 25 additions & 0 deletions demos/use-bing-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ response = await bingAIClient.sendMessage('Could you provide short and precise t
});
console.log(JSON.stringify(response, null, 2)); // {"jailbreakConversationId":false,"conversationId":"...","conversationSignature":"...","clientId":"...","invocationId":2,"messageId":"...","conversationExpiryTime":"2023-03-08T03:20:23.463914Z","response":"Some possible takeaways from the document are... Some early users of ChatGPT and Whisper APIs include Snap Inc., Quizlet, Instacart, Shopify and Speak.","details":{ /* raw response... */ }}

/*
Let bing draw a picture for us with bing image creator.
This will return a `bic` object that you can use to obtain an image url array if bing draws them.

Note: this requires creative tone style.
*/
bingAIClient = new BingAIClient(options);

response = await bingAIClient.sendMessage('Tell me a story of a cool little fox and a group of github friends, and draw some images for it', {
// (Required) Set a conversation style to 'creative'
toneStyle: 'creative',
clientOptions: {
features: {
genImage: {
enable: true,
type: 'markdown_list',
},
},
},
onProgress: (token) => {
process.stdout.write(token);
},
});
console.log(JSON.stringify(response, null, 2)); // {..., "details":{ ..., "bic": {"type": "markdown_list", "prompt": "Octocat", "images": [...]}}}

/*
Activate jailbreak mode by setting `jailbreakConversationId` to `true`.
This will return a `jailbreakConversationId` that you can use to continue the conversation.
Expand Down
Loading