Skip to content
Open
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
50 changes: 50 additions & 0 deletions src/chat/BingChatSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,44 @@ class BingChatSession extends ChatSession {
local_icon: "bingchat.png",
href: "https://www.bing.com/search?form=MY0291&OCID=MY0291&q=Bing+AI&showconv=1",
}
async showConversationStyleDialog() {
const conversationStyles = [
{ name: 'Creative', value: 'creative' },
{ name: 'Precise', value: 'precise' },
{ name: 'Balanced', value: 'balanced' }
];

const selectedStyle = await this.showSelectDialog('Choose Conversation Style', conversationStyles);

if (selectedStyle) {
Context.save['bingConvStyle'] = selectedStyle;
Context.save();
this.refresh();
}
}
async showSelectDialog(title, options) {
return new Promise((resolve) => {
const dialogContainer = document.createElement('div');
dialogContainer.className = 'select-dialog-container';

const dialogTitle = document.createElement('h3');
dialogTitle.innerText = title;
dialogContainer.appendChild(dialogTitle);

options.forEach((option) => {
const optionButton = document.createElement('button');
optionButton.innerText = option.name;
optionButton.onclick = () => {
dialogContainer.remove();
resolve(option.value);
};
dialogContainer.appendChild(optionButton);
});

document.body.appendChild(dialogContainer);
});
}

static errors = {
session: {
code: 'BING_CHAT_SESSION',
Expand All @@ -28,7 +66,11 @@ class BingChatSession extends ChatSession {
super('bingchat');
this.socketID = null;
this.uuid = generateUUID(); // for conversation continuation
if (!Context.save['bingConvStyle']) {
Context.save['bingConvStyle'] = 'creative'; // Default conversation style
Context.save();
}
}

async init() {
if (ChatSession.debug) return;
Expand Down Expand Up @@ -113,7 +155,15 @@ class BingChatSession extends ChatSession {
const iconEl = $('img', titleEl);
iconEl.title = `Bing Chat: ${Settings['AI Assitant']['bingConvStyle'].options[Context.save['bingConvStyle']].name} conversation style`;
iconEl.style.filter = `hue-rotate(${hueAngle}deg)`;

continueChat.style.filter = iconEl.style.filter;
const styleButton = el('button', {
className: 'conversation-style-button',
innerHTML: 'Conversation Style',
onclick: () => this.showConversationStyleDialog()
});

insertAfter(styleButton, continueChat);

return this.panel;
}
Expand Down