forked from wenda-LLM/wenda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wdsj_glm3.html
235 lines (219 loc) · 5.94 KB
/
wdsj_glm3.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<html>
<head>
<title>闻达数据</title>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=400, user-scalable=no">
<link rel="shortcut icon" href="#" />
<link href="/static/mdi_font/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/static/vuetify.min.css" rel="stylesheet">
<script src="/static/vue.js"></script>
<script src="/static/vue-i18n.js"></script>
<script src="/static/vuetify.min.js"></script>
<script src="/static/markdown-it.min.js"></script>
<script src="/static/strings.js"></script>
<script defer src="/static/xlsx.core.min.js"></script>
<style>
div {
transition: all 0.3s;
}
.v-sheet.v-card {
margin: 20px;
padding: 10px;
}
.logo-center {
left: calc(50% - 140px);
width: 260px;
font-size: 4em;
padding-top: 2.5em;
padding-bottom: 0.8em;
position: relative;
}
.logo-left {
left: 20px;
width: 100%;
font-size: xx-large;
position: relative;
}
.input-box {
margin: auto;
width: fit-content;
min-width: 580px;
}
pre {
margin: 20px;
white-space: break-spaces;
}
.v-application--wrap {
display: unset;
}
</style>
</head>
<body>
<div id="app" v-cloak>
<v-app>
<div :class="l表格内容.length!=0?'logo-left':'logo-center'"><b style="color: purple;">闻达</b><b>数据(GLM3)</b></div>
<div class="input-box" v-if="l表格内容.length==0">
<v-btn color="purple" large outlined @click="f载入表格()" style="margin-left: 240px;" fab>
<v-icon>mdi-microsoft-excel</v-icon>
</v-btn>
</div>
<v-row class="input-box" v-if="l表格内容.length!=0">
<v-col cols="10">
<v-textarea autofocus v-model="s检索内容" :label="'当前文档实体:'+entrys.join('、')" no-resize rows="1"
hide-details="auto" :loading="loading" @keypress.enter="find_entrey"></v-textarea>
</v-col>
<v-col cols="2">
<v-btn color="purple" dark size="x-large" @click="find_entrey()" :loading="loading">
<v-icon left>
mdi-magnify
</v-icon>
检索
</v-btn>
</v-col>
</v-row>
<div style="margin: auto;width: fit-content;">
<v-chip class="ma-2" color="green" outlined v-for="o已知 in l已知">
<v-icon left>
mdi-chat
</v-icon>【{{o已知.n}}】{{o已知.v}}
</v-chip>
<v-chip class="ma-2" color="red" outlined v-for="s求解 in l求解">
<v-icon left>
mdi-chat-question
</v-icon>
{{s求解}}
</v-chip>
</div>
<v-card elevation="2" v-if="l解.length!=0">
<v-card-title>结果</v-card-title>
<v-divider></v-divider><br>
<v-card-text>
<v-chip class="ma-2" color="green" outlined v-for="s解 in l解">{{s解}}
</v-chip>
</v-card-text>
<v-card-actions>
</v-card-actions>
</v-card>
<v-card elevation="2" v-if="l匹配.length!=0">
<v-card-title>匹配项目</v-card-title>
<v-divider></v-divider><br>
<v-card-text>
<v-data-table :headers="headers" :items="l匹配"></v-data-table>
</v-card-text>
<v-card-actions>
</v-card-actions>
</v-card>
<v-card elevation="2" v-if="l表格内容.length!=0">
<v-card-title>表格内容</v-card-title>
<v-divider></v-divider><br>
<v-card-text>
<v-data-table :headers="headers" :items="l表格内容"></v-data-table>
</v-card-text>
<v-card-actions>
</v-card-actions>
</v-card>
</v-app>
</div>
<script>
app = new Vue({
el: '#app',
vuetify: new Vuetify(),
i18n: i18n,
data: () => ({
l表格内容: [],
headers: [],
entrys: [],
loading: false,
s检索内容: '',
temperature: 0.8,
top_p: 0.2,
max_length: 2000,
llm_type: "",
l已知: [],
l求解: [],
l匹配: [],
l解: []
}),
methods: {
}
})
f载入表格 = async () => {
await new Promise(resolve => {
let input = document.createElement('input')
input.type = 'file'
input.accept = '.xlsx'
input.onchange = function () {
var file = input.files[0];
var reader = new FileReader();
reader.onload = function (e) {
let contents = e.target.result;
workbook = XLSX.read(new Uint8Array(contents), {
type: 'array'
});
app.l表格内容 = XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]])
app.headers = []
for (i in app.l表格内容[0]) if (i) app.headers.push({ text: i, value: i })
app.entrys = app.headers.map(i => i.text)
resolve()
};
reader.readAsArrayBuffer(file);
}
input.click()
})
}
find_entrey = async (e) => {
e && e.preventDefault()
app.loading = true
let entrys = (JSON.parse((await f提取实体()))).parameters
app.loading = false
console.log(entrys)
app.l已知 = [{n:entrys.k,v:entrys.v}]
app.l求解 = [entrys.q]
app.l匹配 = app.l表格内容.filter(e => {
let score = app.l已知.filter(条件 => e[条件.n] == 条件.v).length
if (score > 0) {
e.__score = score
console.log(e, score)
return true
}
})
app.l解 = app.l匹配.map(e =>
app.l求解.map(n => '【' + n + '】' + e[n]).join('\n')
)
}//何一鹤是哪里毕业的
f提取实体 = async () => {
tools = [
{
"name": "read",
"description": `提取问题的关键词`,
"parameters": {
"type": "object",
"properties": {
"k": {
"description": `已知项目(从${app.entrys.join('、')}中选择)`
},
"v": {
"description": "已知内容"
},
"q": { "description": `未知项目(从${app.entrys.join('、')}中选择)` },
},
"required": ['k', 'v','q']
}
}
]
return await send_raw(app.s检索内容, '', [
{
"role": "system",
"content": JSON.stringify(tools),
},
], (s) => { },
)
}
</script>
<script src="wd_sdk.js"></script>
<script src="api/llm"></script>
</body>
</html>