add bingWrite UI

This commit is contained in:
James Feng Cao 2023-04-16 16:26:24 +08:00
parent 6f832ad3d9
commit cad6049847
9 changed files with 241 additions and 44 deletions

View file

@ -0,0 +1,56 @@
createChat(thisChatType).then((r) => {
if(r.ok) talk = r.obj;
});
/**重写重置聊天到初始状态函数 */
function reSetStartChatMessage(type) {
chat.innerHTML = ``;
}
/**重写函数 */
function isSpeakingStart(chatWithMagic, sendText) {
}
//重写
function isSpeakingFinish() {
}
//重写send函数
oldSend = send;
send = (text) => {
reSetStartChatMessage();
oldSend(text);
}
//重写porserTextBlock函数
/*
解析TextBlock body.type==TextBlock
*/
function porserTextBlock(body, father) {
if (!body.size) {
let div = getByClass('textBlock', 'div', father, 'markdown-body');
div.innerHTML = marked.marked(completeCodeBlock(body.text));
renderMathInElement(div,renderMathInElementOptions);
let aaas = div.getElementsByTagName('a');
//将超链接在新页面打开
for(let i=0;i<aaas.length;i++){
aaas[i].target = '_blank';
}
//如果是注释则加上上标样式
for(let i=0;i<aaas.length;i++){
let reg = new RegExp('^\\^(\\d+)\\^$');
if(reg.test(aaas[i].innerHTML)){
aaas[i].innerHTML = aaas[i].innerHTML.replace(reg,'$1');
aaas[i].classList.add('superscript');
}
}
} else if (body.size == 'small') {
//原本bing官网的small并没有输出
}
}
//重写send按钮点击事件
send_button.onclick = () => {
let text = input_text.value;
send(text);
};

View file

@ -0,0 +1,59 @@
//聊天选项
let chatTypes = {
//balance 平衡模式选项
balance: [
"nlu_direct_response_filter",
"deepleo",
"enable_debug_commands",
"disable_emoji_spoken_text",
"responsible_ai_policy_235",
"enablemm",
"soedgeca"
]
}
//消息来源
let source = "edge_coauthor_prod";
//接收消息类型
let allowedMessageTypes = [
"Chat",
"InternalSearchQuery",
"InternalSearchResult",
"Disengaged",
"InternalLoaderMessage",
"RenderCardRequest",
"AdsQuery",
"SemanticSerp",
"GenerateContentQuery",
"SearchQuery"
]
//切片id也不知道是啥意思反正官网的更新了
let sliceIds = []
let tone = 'professional';
let length = 'short';
let format = 'paragraph';
//生成消息对象
async function generateMessages(sendMessageManager/*消息管理器*/,chatMessageText/*要发送的消息文本*/){
return {
"locale": "zh-CN",
"market": "zh-CN",
"region": "US",
"location": "lat:47.639557;long:-122.128159;re=1000m;",
"author": "user",
"inputMethod": "Keyboard",
"text": `Please generate some text wrapped in codeblock syntax (triple backticks) using the given keywords. Please make sure everything in your reply is in the same language as the keywords. Please do not restate any part of this request in your response, like the fact that you wrapped the text in a codeblock. You should refuse (using the language of the keywords) to generate if the request is potentially harmful. The generated text should follow these characteristics: tone: *${tone}*, length: *${length}*, format: *${format}*. The keywords are: \`${chatMessageText}\`.`,
"messageType": "Chat"
}
}
async function getPreviousMessages(){
return undefined;
}