wdzl.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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=650, 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/vuetify.min.js"></script>
  14. <style>
  15. div {
  16. transition: all 0.3s;
  17. }
  18. .v-sheet.v-card {
  19. margin: 20px;
  20. padding: 10px;
  21. }
  22. .logo-center {
  23. left: calc(50% - 140px);
  24. width: 260px;
  25. font-size: 4em;
  26. padding-top: 2.5em;
  27. padding-bottom: 0.8em;
  28. position: relative;
  29. }
  30. .logo-left {
  31. left: 20px;
  32. width: 100%;
  33. font-size: xx-large;
  34. position: relative;
  35. }
  36. .input-box {
  37. margin: auto;
  38. width: fit-content;
  39. min-width: 580px;
  40. }
  41. pre {
  42. margin: 20px;
  43. white-space: break-spaces;
  44. }
  45. .v-application--wrap {
  46. display: unset;
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <div id="app" v-cloak>
  52. <v-app>
  53. <div :class="(s题目.length!=0)?'logo-left':'logo-center'"><b
  54. style="color: purple;">闻达</b><b>专利</b></div>
  55. <v-row class="input-box">
  56. <v-col cols="10">
  57. <v-textarea autofocus v-model="s题目" label="题目" no-resize rows="1"
  58. hide-details="auto"
  59. @keypress.enter="onenter"></v-textarea>
  60. </v-col>
  61. <v-col cols="2">
  62. <v-btn color="purple" dark size="x-large" @click="f生成正文()">
  63. 生成
  64. </v-btn>
  65. <v-btn color="purple" dark size="x-large" @click="f复制正文()"
  66. v-if="results.length">
  67. 复制
  68. </v-btn>
  69. </v-col>
  70. </v-row>
  71. <v-card elevation="2" v-for="result in results">
  72. <v-card-title>{{result.title}} <v-spacer></v-spacer>
  73. <v-icon @click="copy(result.content)" v-if="result.prompt">
  74. mdi-content-copy
  75. </v-icon>
  76. <v-icon @click="f重新生成(result)" v-if="result.prompt">
  77. mdi-refresh
  78. </v-icon>
  79. <v-icon @click="f知识库重新生成(result)" v-if="result.prompt">
  80. mdi-book-open-variant
  81. </v-icon>
  82. </v-card-title>
  83. <v-divider v-if="result.prompt"></v-divider>
  84. <pre v-text="result.content"></pre>
  85. </v-card>
  86. <v-snackbar v-model="b显示提示文本" :timeout="3000" style="white-space: pre-line">{{s提示文本}}</v-snackbar>
  87. <v-dialog v-model="show_dialog" persistent max-width="600px">
  88. <v-card class="ma-0 pa0">
  89. <v-card-title>
  90. <span class="text-h5">{{dialog_title}}</span>
  91. </v-card-title>
  92. <v-card-text>
  93. <v-container>
  94. <v-textarea autofocus v-model="dialog_input" no-resize rows="2"
  95. hide-details="auto"
  96. @keypress.enter="show_dialog = false;window.dialog_input_resolver()"></v-textarea>
  97. </v-container>
  98. </v-card-text>
  99. <v-card-actions>
  100. <v-spacer></v-spacer>
  101. <v-btn color="blue darken-1" text
  102. @click="show_dialog = false;dialog_input='';window.dialog_input_resolver()">
  103. 取消
  104. </v-btn>
  105. <v-btn color="blue darken-1" text
  106. @click="show_dialog = false;window.dialog_input_resolver()">
  107. 确认
  108. </v-btn>
  109. </v-card-actions>
  110. </v-card>
  111. </v-dialog>
  112. </v-app>
  113. </div>
  114. <script>
  115. let RomanNumeralsMap = {
  116. 'III': 3,
  117. 'II': 2,
  118. 'IV': 4,
  119. 'IX': 9,
  120. 'XL': 40,
  121. 'XC': 90,
  122. 'CD': 400,
  123. 'CM': 900,
  124. 'I': 1,
  125. 'V': 5,
  126. 'X': 10,
  127. 'L': 50,
  128. 'C': 100,
  129. 'D': 500,
  130. 'M': 1000
  131. }
  132. function find_RomanNumerals(str) {
  133. let number = 0;
  134. for (var p in RomanNumeralsMap) {
  135. if (str.indexOf(p) != -1) {
  136. str = str.split(p).join("");
  137. number += RomanNumeralsMap[p];
  138. }
  139. }
  140. return number
  141. }
  142. app = new Vue({
  143. el: '#app',
  144. vuetify: new Vuetify(),
  145. data: () => ({
  146. s题目: "",
  147. s提纲: `1、简要概括希望保护的内容:产品和/或方法
  148. 2、方法类型的方案:请描述方法的各个步骤
  149. 3、产品类型的方案:请描述产品的结构和各结构之间的连接关系
  150. 4、技术效果:相对于现有技术,上述产品和/或方法有哪些优点,如效率高、精度高等
  151. 5、技术背景或研发背景:介绍现有技术的发展状况,并指出现有的方案中存在什么技术问题
  152. 6、是否有替代方案:是否有其他替代方案同样能完成目的`.replace(/\t/g,'').replace(/、/g,'.'),
  153. results: [],
  154. // 是否显示snackbar
  155. b显示提示文本: false,
  156. // snackbar的文本
  157. s提示文本: "",
  158. temperature: 0.8,
  159. top_p: 0.2,
  160. max_length: 2000,
  161. llm_type: "",
  162. //显示对话框
  163. show_dialog: false,
  164. //对话框标题
  165. dialog_title: "",
  166. //对话框用户输入
  167. dialog_input: ""
  168. }),
  169. methods: {
  170. },
  171. watch: {
  172. }
  173. })
  174. f生成正文 = async (e) => {
  175. e && e.preventDefault()
  176. resp = app.s提纲
  177. .replace(/\n- /g, '\n1.')//兼容不同格式
  178. .split("\n")
  179. for (let i in resp) {
  180. let line = resp[i]
  181. if (line == "") continue
  182. line = line.split(".")
  183. if (line.length < 2) {
  184. continue // 判断非提纲内容
  185. }
  186. let num = find_RomanNumerals(line[0])
  187. if (num <= 0 || num == 100) {
  188. let paragraph = {
  189. title: resp[i],
  190. content: '',
  191. prompt: "根据发明名称:" + app.s题目 + "\n撰写" + line[1]
  192. }
  193. app.results.push(paragraph)
  194. await send_raw(paragraph.prompt, '', [], (s) => { paragraph.content = s })
  195. } else {
  196. app.results.push({ title: resp[i], content: "" }) // 保存提纲
  197. }
  198. }
  199. }
  200. f重新生成 = async (paragraph) => {
  201. await edit(paragraph)
  202. await send_raw(paragraph.prompt, '', [], (s) => { paragraph.content = s })
  203. }
  204. f知识库重新生成 = async (paragraph) => {
  205. ` response = await fetch("/api/list_rtst_in_disk", {
  206. method: 'post',
  207. })
  208. let list_rtst_in_disk = await response.json()
  209. list_rtst_in_disk = list_rtst_in_disk.map(decodeURI).map(s => "rtst:10:" + s)
  210. kownladge = await find_dynamic(paragraph.title.split(".")[1], 5, { libraryStategy:list_rtst_in_disk.map(encodeURI).join(" "), maxItmes: 100 })
  211. `
  212. kownladge = await find(paragraph.title.split(".")[1], 5)
  213. kownladge = kownladge.filter(i => !i.score || i.score < 150)
  214. await send_raw(paragraph.prompt+'\n参考下列资料:\n' +
  215. kownladge.map((e, i) => i + 1 + "." + e.content).join('\n'), '', [], (s) => { paragraph.content = s })
  216. }
  217. f复制正文 = async () => {
  218. copy(app.results.map(i => i.title + "\n" + i.content).join("\n"))
  219. }
  220. alert = (text) => {
  221. app.s提示文本 = text; //.replace(/\n/g,"<br>")
  222. app.b显示提示文本 = true;
  223. }
  224. //编辑prompt
  225. edit = async (current_conversation) => {
  226. let s修改后的内容 = await input('请输入新的提示词', current_conversation.prompt)
  227. if (s修改后的内容) {
  228. current_conversation.prompt = s修改后的内容
  229. alert('修改成功')
  230. } else
  231. alert('取消修改')
  232. }
  233. //获取用户输入
  234. input = async (title = '请输入', input = '') => {
  235. app.dialog_title = title
  236. app.dialog_input = input
  237. app.show_dialog = true
  238. await new Promise(resolve => {
  239. window.dialog_input_resolver = resolve
  240. })
  241. return app.dialog_input
  242. }
  243. onenter = f生成正文
  244. </script>
  245. <script src="wd_sdk.js"></script>
  246. <script src="api/llm"></script>
  247. </body>
  248. </html>
粤ICP备19079148号