wdsj_glm3.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <html>
  2. <head>
  3. <title>闻达数据</title>
  4. <meta charset="utf-8">
  5. <meta name="apple-mobile-web-app-capable" content="yes" />
  6. <meta name="mobile-web-app-capable" content="yes" />
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="viewport" content="width=400, user-scalable=no">
  9. <link rel="shortcut icon" href="#" />
  10. <link href="/static/mdi_font/css/materialdesignicons.min.css" rel="stylesheet">
  11. <link href="/static/vuetify.min.css" rel="stylesheet">
  12. <script src="/static/vue.js"></script>
  13. <script src="/static/vue-i18n.js"></script>
  14. <script src="/static/vuetify.min.js"></script>
  15. <script src="/static/markdown-it.min.js"></script>
  16. <script src="/static/strings.js"></script>
  17. <script defer src="/static/xlsx.core.min.js"></script>
  18. <style>
  19. div {
  20. transition: all 0.3s;
  21. }
  22. .v-sheet.v-card {
  23. margin: 20px;
  24. padding: 10px;
  25. }
  26. .logo-center {
  27. left: calc(50% - 140px);
  28. width: 260px;
  29. font-size: 4em;
  30. padding-top: 2.5em;
  31. padding-bottom: 0.8em;
  32. position: relative;
  33. }
  34. .logo-left {
  35. left: 20px;
  36. width: 100%;
  37. font-size: xx-large;
  38. position: relative;
  39. }
  40. .input-box {
  41. margin: auto;
  42. width: fit-content;
  43. min-width: 580px;
  44. }
  45. pre {
  46. margin: 20px;
  47. white-space: break-spaces;
  48. }
  49. .v-application--wrap {
  50. display: unset;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <div id="app" v-cloak>
  56. <v-app>
  57. <div :class="l表格内容.length!=0?'logo-left':'logo-center'"><b style="color: purple;">闻达</b><b>数据(GLM3)</b></div>
  58. <div class="input-box" v-if="l表格内容.length==0">
  59. <v-btn color="purple" large outlined @click="f载入表格()" style="margin-left: 240px;" fab>
  60. <v-icon>mdi-microsoft-excel</v-icon>
  61. </v-btn>
  62. </div>
  63. <v-row class="input-box" v-if="l表格内容.length!=0">
  64. <v-col cols="10">
  65. <v-textarea autofocus v-model="s检索内容" :label="'当前文档实体:'+entrys.join('、')" no-resize rows="1"
  66. hide-details="auto" :loading="loading" @keypress.enter="find_entrey"></v-textarea>
  67. </v-col>
  68. <v-col cols="2">
  69. <v-btn color="purple" dark size="x-large" @click="find_entrey()" :loading="loading">
  70. <v-icon left>
  71. mdi-magnify
  72. </v-icon>
  73. 检索
  74. </v-btn>
  75. </v-col>
  76. </v-row>
  77. <div style="margin: auto;width: fit-content;">
  78. <v-chip class="ma-2" color="green" outlined v-for="o已知 in l已知">
  79. <v-icon left>
  80. mdi-chat
  81. </v-icon>【{{o已知.n}}】{{o已知.v}}
  82. </v-chip>
  83. <v-chip class="ma-2" color="red" outlined v-for="s求解 in l求解">
  84. <v-icon left>
  85. mdi-chat-question
  86. </v-icon>
  87. {{s求解}}
  88. </v-chip>
  89. </div>
  90. <v-card elevation="2" v-if="l解.length!=0">
  91. <v-card-title>结果</v-card-title>
  92. <v-divider></v-divider><br>
  93. <v-card-text>
  94. <v-chip class="ma-2" color="green" outlined v-for="s解 in l解">{{s解}}
  95. </v-chip>
  96. </v-card-text>
  97. <v-card-actions>
  98. </v-card-actions>
  99. </v-card>
  100. <v-card elevation="2" v-if="l匹配.length!=0">
  101. <v-card-title>匹配项目</v-card-title>
  102. <v-divider></v-divider><br>
  103. <v-card-text>
  104. <v-data-table :headers="headers" :items="l匹配"></v-data-table>
  105. </v-card-text>
  106. <v-card-actions>
  107. </v-card-actions>
  108. </v-card>
  109. <v-card elevation="2" v-if="l表格内容.length!=0">
  110. <v-card-title>表格内容</v-card-title>
  111. <v-divider></v-divider><br>
  112. <v-card-text>
  113. <v-data-table :headers="headers" :items="l表格内容"></v-data-table>
  114. </v-card-text>
  115. <v-card-actions>
  116. </v-card-actions>
  117. </v-card>
  118. </v-app>
  119. </div>
  120. <script>
  121. app = new Vue({
  122. el: '#app',
  123. vuetify: new Vuetify(),
  124. i18n: i18n,
  125. data: () => ({
  126. l表格内容: [],
  127. headers: [],
  128. entrys: [],
  129. loading: false,
  130. s检索内容: '',
  131. temperature: 0.8,
  132. top_p: 0.2,
  133. max_length: 2000,
  134. llm_type: "",
  135. l已知: [],
  136. l求解: [],
  137. l匹配: [],
  138. l解: []
  139. }),
  140. methods: {
  141. }
  142. })
  143. f载入表格 = async () => {
  144. await new Promise(resolve => {
  145. let input = document.createElement('input')
  146. input.type = 'file'
  147. input.accept = '.xlsx'
  148. input.onchange = function () {
  149. var file = input.files[0];
  150. var reader = new FileReader();
  151. reader.onload = function (e) {
  152. let contents = e.target.result;
  153. workbook = XLSX.read(new Uint8Array(contents), {
  154. type: 'array'
  155. });
  156. app.l表格内容 = XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]])
  157. app.headers = []
  158. for (i in app.l表格内容[0]) if (i) app.headers.push({ text: i, value: i })
  159. app.entrys = app.headers.map(i => i.text)
  160. resolve()
  161. };
  162. reader.readAsArrayBuffer(file);
  163. }
  164. input.click()
  165. })
  166. }
  167. find_entrey = async (e) => {
  168. e && e.preventDefault()
  169. app.loading = true
  170. let entrys = (JSON.parse((await f提取实体()))).parameters
  171. app.loading = false
  172. console.log(entrys)
  173. app.l已知 = [{n:entrys.k,v:entrys.v}]
  174. app.l求解 = [entrys.q]
  175. app.l匹配 = app.l表格内容.filter(e => {
  176. let score = app.l已知.filter(条件 => e[条件.n] == 条件.v).length
  177. if (score > 0) {
  178. e.__score = score
  179. console.log(e, score)
  180. return true
  181. }
  182. })
  183. app.l解 = app.l匹配.map(e =>
  184. app.l求解.map(n => '【' + n + '】' + e[n]).join('\n')
  185. )
  186. }//何一鹤是哪里毕业的
  187. f提取实体 = async () => {
  188. tools = [
  189. {
  190. "name": "read",
  191. "description": `提取问题的关键词`,
  192. "parameters": {
  193. "type": "object",
  194. "properties": {
  195. "k": {
  196. "description": `已知项目(从${app.entrys.join('、')}中选择)`
  197. },
  198. "v": {
  199. "description": "已知内容"
  200. },
  201. "q": { "description": `未知项目(从${app.entrys.join('、')}中选择)` },
  202. },
  203. "required": ['k', 'v','q']
  204. }
  205. }
  206. ]
  207. return await send_raw(app.s检索内容, '', [
  208. {
  209. "role": "system",
  210. "content": JSON.stringify(tools),
  211. },
  212. ], (s) => { },
  213. )
  214. }
  215. </script>
  216. <script src="wd_sdk.js"></script>
  217. <script src="api/llm"></script>
  218. </body>
  219. </html>
粤ICP备19079148号