-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
111 lines (107 loc) · 4.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Medical Chat</title>
</head>
<body id="chat-body">
<div id="webchat"></div>
<h2>changelog: 2020.05.20</h2>
<h2>
<p>我在右下角。</p>
<p>I'm in the lower right corner.</p>
</h2>
<h2>
<p>如果不能输入消息,请看浏览器控制台是否报错。</p>
<p>If you cannot input a message, check the browser console.</p>
</h2>
<!-- <h1>If not, it means connection error.</h1> -->
<!-- <h1>You can check out the browser console.</h1> -->
<!-- <input id="user-send" type="text" value="头痛怎么治">-->
<!-- <button onclick="sendMsg($('#user-send').val());">发送</button>-->
</body>
<script src="./js/webchat-latest.js"></script>
<script src="./js/jquery-1.10.2.js"></script>
<script>
WebChat.default.init({
selector: '#webchat',
initPayload: '/first',
interval: 1000, // 1000 ms between each message
customData: { from_user_id: 1 }, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: 'http://localhost:5000',
socketPath: '/mysocket.io/',
title: '自助医疗问答',
subtitle: 'Doctor Friende',
inputTextFieldHint: '输入一条消息...',
connectingText: '等待服务器...',
hideWhenNotConnected: false,
fullScreenMode: false,
profileAvatar: './assets/img_avatar.png',
// openLauncherImage: 'myCustomOpenImage.png',
// closeLauncherImage: 'myCustomCloseImage.png',
params: {
images: {
dims: {
width: 300,
height: 200
}
},
storage: 'session'
}
})
</script>
<!--<script>-->
<!-- // '{"q":"我朋友头痛怎么治", "project": "medical", "model": "model_20190723-153130"}'-->
<!-- $(document).ready(function () {-->
<!-- sendMsg('/first');-->
<!-- });-->
<!-- function sendMsg(message) {-->
<!-- // let project = "medical";-->
<!-- // let model = "model_20190723-153130";-->
<!-- let text = message;-->
<!-- let data = JSON.stringify({-->
<!-- // project,-->
<!-- // model,-->
<!-- "message": text-->
<!-- });-->
<!-- console.log(data);-->
<!-- let p = '<span><p>You >>> ' + message + '</p></span>';-->
<!-- document.getElementById('chat-body').innerHTML += p;-->
<!-- $.ajax({-->
<!-- url: "c",-->
<!-- // url: "http://localhost:5000/model/parse",-->
<!-- // url: "http://localhost:5055/webhook",-->
<!-- type: "post",-->
<!-- data: data,-->
<!-- dataType: "json",-->
<!-- contentType: "application/json",-->
<!-- success: function (modelParseData) {-->
<!-- console.log(modelParseData);-->
<!-- // let p = '<span><p>' + JSON.stringify(data.intent) + '</p><p>' + JSON.stringify(data.entities) + '</p></span>';-->
<!-- // $.ajax({-->
<!-- // url: "http://localhost:5055/webhook",-->
<!-- // type: "post",-->
<!-- // data: modelParseData,-->
<!-- // dataType: "json",-->
<!-- // contentType: "application/json",-->
<!-- // success: function (botMsg) {-->
<!-- // let p = '<span><p>' + JSON.stringify(botMsg) + '</p></span>';-->
<!-- // document.getElementById('chat-body').innerHTML += p;-->
<!-- // },-->
<!-- // error: function (result) {-->
<!-- // console.log("webhook error:\n" + result);-->
<!-- // }-->
<!-- // });-->
<!-- p = '';-->
<!-- for (let i = 0; i < modelParseData.length; i++) {-->
<!-- p += '<span><p>Bot >>> ' + modelParseData[i]["text"] + '</p></span>';-->
<!-- }-->
<!-- document.getElementById('chat-body').innerHTML += p;-->
<!-- },-->
<!-- error: function (result) {-->
<!-- console.log(result);-->
<!-- }-->
<!-- })-->
<!-- }-->
<!--</script>-->
</html>