to:sync
This commit is contained in:
parent
d3ec570683
commit
07457c047c
@ -1,7 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta name="renderer" content="webkit"/>
|
||||||
|
<meta name="force-rendering" content="webkit"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0, viewport-fit=cover"/>
|
||||||
<title>AI 文本助手</title>
|
<title>AI 文本助手</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
@ -150,7 +155,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
|
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
|
/*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
|
||||||
|
|
||||||
|
@ -13,7 +13,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script src="https://g.alicdn.com/chatui/sdk-v2/0.3.8/sdk.js"></script>
|
<script src="https://g.alicdn.com/chatui/sdk-v2/0.3.8/sdk.js"></script>
|
||||||
<script src="https://g.alicdn.com/chatui/extensions/5.18.0/isv-parser.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
||||||
|
<!--<script src="https://g.alicdn.com/chatui/extensions/5.18.0/isv-parser.js"></script>-->
|
||||||
<script>
|
<script>
|
||||||
const messages = [];
|
const messages = [];
|
||||||
|
|
||||||
@ -42,8 +44,8 @@
|
|||||||
send: function (msg) {
|
send: function (msg) {
|
||||||
// alert(msg.content.text)
|
// alert(msg.content.text)
|
||||||
messages.push({role: "user", content: msg.content.text});
|
messages.push({role: "user", content: msg.content.text});
|
||||||
const body = JSON.stringify({model: "google/gemma-7b-it:free", messages: messages});
|
const body = JSON.stringify({model: "google/gemma-7b-it:free", "stream": false, messages: messages});
|
||||||
// alert(body)
|
// console.log(body);
|
||||||
if (msg.type === 'text') {
|
if (msg.type === 'text') {
|
||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -58,11 +60,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlers: {
|
handlers: {
|
||||||
|
onToolbarClick: function (item, ctx) {
|
||||||
|
// item 即为上面 toolbar 中被点击的那一项,可通过 item.type 区分
|
||||||
|
// ctx 为上下文,可用 ctx.appendMessage 渲染消息等
|
||||||
|
// alert(123);
|
||||||
|
},
|
||||||
|
|
||||||
parseResponse: function (res, requestType) {
|
parseResponse: function (res, requestType) {
|
||||||
// alert(requestType);
|
// alert(requestType);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (requestType === 'send' && res?.choices?.length > 0) {
|
if (requestType === 'send' && res?.choices?.length > 0) {
|
||||||
let res1=res?.choices[0]?.message?.content;
|
let res1 = res?.choices[0]?.message?.content;
|
||||||
|
|
||||||
|
res1 = DOMPurify.sanitize(res1)
|
||||||
|
|
||||||
return {type: 'text', content: {text: res1}};
|
return {type: 'text', content: {text: res1}};
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user