| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <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=650, 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/vuetify.min.js"></script>
- <style>
- div {
- transition: all 0.3s;
- }
- .v-sheet.v-card {
- margin: 20px;
- padding: 10px;
- }
- svg{
- background-color: white;
- }
- .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="(s题目.length!=0||s提纲.length!=0)?'logo-left':'logo-center'"><b
- style="color: purple;">闻达</b><b>思路</b></div>
- <v-row class="input-box">
- <v-col cols="10">
- <v-textarea autofocus v-model="s题目" label="题目" no-resize rows="1" hide-details="auto"
- @keypress.enter="sctg"></v-textarea>
- </v-col>
- <v-col cols="2">
- <v-btn color="purple" dark size="x-large" @click="f生成提纲()">
- 生成
- </v-btn>
- </v-col>
- </v-row>
- <v-card elevation="2" v-if="s提纲">
- <v-card-title>导图</v-card-title>
- <v-divider></v-divider>
- <v-card-text> <v-row>
- <v-col cols="5">
- <v-textarea autofocus v-model="s提纲" label="文本" rows="20" hide-details="auto"></v-textarea>
- </v-col>
- <v-col cols="7">
- <svg id="markmap" style="width: 100%; height: 600px"></svg> </v-col>
- </v-row>
- </v-card-text>
- <v-card-action>
- <v-btn color="purple" dark size="x-large" @click="mm.svg._groups[0][0].requestFullscreen()">
- 全屏显示
- </v-btn>
- <v-btn color="purple" dark size="x-large" @click="f复制正文()">
- 复制正文
- </v-btn>
- <v-btn color="purple" dark size="x-large" @click="f保存()">
- 保存导图
- </v-btn>
- </v-card-action>
- </v-card>
- <!-- <v-card elevation="2" v-for="result in results">
- <v-card-title>{{result.title}} <v-spacer></v-spacer>
- <v-icon @click="copy(result.content)" v-if="result.prompt">
- mdi-content-copy
- </v-icon>
- <v-icon @click="f重新生成(result)" v-if="result.prompt">
- mdi-refresh
- </v-icon>
- <v-icon @click="f知识库重新生成(result)" v-if="result.prompt">
- mdi-book-open-variant
- </v-icon>
- </v-card-title>
- <v-divider v-if="result.prompt"></v-divider>
- <pre v-text="result.content"></pre>
- </v-card> -->
- <v-snackbar v-model="b显示提示文本" :timeout="3000" style="white-space: pre-line">{{s提示文本}}</v-snackbar>
- <v-dialog v-model="show_dialog" persistent max-width="600px">
- <v-card class="ma-0 pa0">
- <v-card-title>
- <span class="text-h5">{{dialog_title}}</span>
- </v-card-title>
- <v-card-text>
- <v-container>
- <v-textarea autofocus v-model="dialog_input" no-resize rows="2" hide-details="auto"
- @keypress.enter="show_dialog = false;window.dialog_input_resolver()"></v-textarea>
- </v-container>
- </v-card-text>
- <v-card-actions>
- <v-spacer></v-spacer>
- <v-btn color="blue darken-1" text
- @click="show_dialog = false;dialog_input='';window.dialog_input_resolver()">
- 取消
- </v-btn>
- <v-btn color="blue darken-1" text @click="show_dialog = false;window.dialog_input_resolver()">
- 确认
- </v-btn>
- </v-card-actions>
- </v-card>
- </v-dialog>
- </v-app>
- </div>
- <script src="https://cdn.jsdelivr.net/npm/d3@6"></script>
- <script src="https://cdn.jsdelivr.net/npm/markmap-view"></script>
- <script src="https://cdn.jsdelivr.net/npm/markmap-lib"></script>
- <!-- <script src="https://cdn.jsdelivr.net/npm/markmap-toolbar"></script> -->
- <script>
- const { Markmap, loadCSS, loadJS } = window.markmap;
- app = new Vue({
- el: '#app',
- vuetify: new Vuetify(),
- data: () => ({
- s题目: "",
- s提纲: "",
- results: [],
- // 是否显示snackbar
- b显示提示文本: false,
- // snackbar的文本
- s提示文本: "",
- temperature: 0.8,
- top_p: 0.2,
- max_length: 2000,
- llm_type: "",
- //显示对话框
- show_dialog: false,
- //对话框标题
- dialog_title: "",
- //对话框用户输入
- dialog_input: ""
- }),
- methods: {
- },
- watch: {
- s提纲: () => {
- window.b需重新生成 = true
- }
- }
- })
- f生成提纲 = async (e) => {
- e && e.preventDefault()
- let prompt = `根据所给内容:${app.s题目},以markmap代码生成足够深度以包含尽量多主要细节的思维导图。`
- return await send_raw(prompt, '', [
- {
- "role": "user",
- "content": "根据所给内容:学习英语,以markmap代码生成足够深度以包含尽量多主要细节的思维导图。",
- },
- {
- "role": "AI",
- "content": "# 学习英语\n## 听力训练\n* 听力技巧\n\t+ 集中注意力\n\t+ 听取关键词\n\t+ 理解句子结构\n\t+ 预测对话内容\n* 听力材料\n\t+ 英语新闻\n\t\t- 新闻内容\n\t\t- 新闻结构\n\t\t- 新闻时间\n\t+ 英语电影\n\t\t- 电影内容\n\t\t- 电影结构\n\t\t- 电影时间\n\t+ 英语歌曲\n\t\t- 歌曲内容\n\t\t- 歌曲结构\n\t\t- 歌曲时间\n## 阅读训练\n* 阅读技巧\n\t+ 阅读顺序\n\t+ 阅读材料分类\n\t+ 阅读策略\n\t+ 阅读时间控制\n* 阅读材料\n\t+ 英语新闻\n\t\t- 新闻主题\n\t\t- 新闻时间\n\t\t- 新闻内容\n\t+ 英语小说\n\t\t- 小说主题\n\t\t- 小说时间\n\t\t- 小说内容\n\t+ 英语散文\n\t\t- 散文主题\n\t\t- 散文时间\n\t\t- 散文内容\n\t+ 英语学术论文\n\t\t- 论文主题\n\t\t- 论文时间\n\t\t- 论文内容\n\t+ 英语杂志\n\t\t- 杂志主题\n\t\t- 杂志时间\n\t\t- 杂志内容\n## 写作训练\n* 写作技巧\n\t+ 写作顺序\n\t+ 写作材料分类\n\t+ 写作策略\n\t+ 写作时间控制\n* 写作材料\n\t+ 英语作文\n\t\t- 作文主题\n\t\t- 作文时间\n\t\t- 作文内容\n\t+ 英语日记\n\t\t- 日记主题\n\t\t- 日记时间\n\t\t- 日记内容\n\t+ 英语文章\n\t\t- 文章主题\n\t\t- 文章时间\n\t\t- 文章内容\n\t+ 英语演讲\n\t\t- 演讲主题\n\t\t- 演讲时间\n\t\t- 演讲内容\n\t+ 英语文章\n\t\t- 文章主题\n\t\t- 文章时间\n\t\t- 文章内容\n\t+ 英语论文\n\t\t- 论文主题\n\t\t- 论文时间\n\t\t- 论文内容\n\t+ 英语杂志\n\t\t- 杂志主题\n\t\t- 杂志时间\n\t\t- 杂志内容",
- "sources": []
- }
- ], (s) => { app.s提纲 = s })
- }
- setInterval(() => {
- if (window.b需重新生成) {
- window.b需重新生成 = false
- f生成导图()
- }
- }, 1000)
- f清除导图 = async (e) => {
- const svgEl = document.querySelector('#markmap');
- while (svgEl.children.length > 0) svgEl.removeChild(svgEl.children[0])
- }
- f生成导图 = async (e) => {
- const transformer = new markmap.Transformer()
- const { root, features } = transformer.transform(app.s提纲)
- if (window.mm) {
- window.mm.setData(root);
- window.mm.fit();
- } else {
- window.mm = Markmap.create('#markmap', null, root)
- //toolbar = markmap.Toolbar.create(mm);
- //document.body.append(toolbar.el);
- }
- }
- sctg = f生成提纲
- f生成正文 = async (e) => {
- resp = app.s提纲
- .replace(/\n- /g, '\n1.')//兼容不同格式
- .split("\n")
- for (let i in resp) {
- let line = resp[i]
- if (line == "") continue
- line = line.split(".")
- if (line.length < 2) {
- continue // 判断非提纲内容
- }
- let num = find_RomanNumerals(line[0])
- if (num <= 0 || num == 100) {
- let paragraph = {
- title: resp[i],
- content: '',
- prompt: "根据主题:" + app.s题目 + "\n对下列段落进行详细的撰写:" + line[1]
- }
- app.results.push(paragraph)
- await send_raw(paragraph.prompt, '', [], (s) => { paragraph.content = s })
- } else {
- app.results.push({ title: resp[i], content: "" }) // 保存提纲
- }
- }
- }
- f重新生成 = async (paragraph) => {
- await edit(paragraph)
- await send_raw(paragraph.prompt, '', [], (s) => { paragraph.content = s })
- }
- f知识库重新生成 = async (paragraph) => {
- ` response = await fetch("/api/list_rtst_in_disk", {
- method: 'post',
- })
- let list_rtst_in_disk = await response.json()
- list_rtst_in_disk = list_rtst_in_disk.map(decodeURI).map(s => "rtst:10:" + s)
- kownladge = await find_dynamic(paragraph.title.split(".")[1], 5, { libraryStategy:list_rtst_in_disk.map(encodeURI).join(" "), maxItmes: 100 })
- `
- kownladge = await find(paragraph.title.split(".")[1], 5)
- kownladge = kownladge.filter(i => !i.score || i.score < 150)
- await send_raw(paragraph.prompt + '\n参考下列资料:\n' +
- kownladge.map((e, i) => i + 1 + "." + e.content).join('\n'), '', [], (s) => { paragraph.content = s })
- }
- f复制正文 = async () => {
- copy(app.results.map(i => i.title + "\n" + i.content).join("\n"))
- }
- f保存 = async () => {
- const blob = new Blob([new XMLSerializer().serializeToString(mm.svg._groups[0][0])], {
- type: "text/plain;charset=utf-8"
- })
- const objectURL = URL.createObjectURL(blob)
- const aTag = document.createElement('a')
- aTag.href = objectURL
- aTag.download = '【闻达思路】'+ app.s题目+".svg"
- aTag.click()
- URL.revokeObjectURL(objectURL)
- }
- alert = (text) => {
- app.s提示文本 = text; //.replace(/\n/g,"<br>")
- app.b显示提示文本 = true;
- }
- //编辑prompt
- edit = async (current_conversation) => {
- let s修改后的内容 = await input('请输入新的提示词', current_conversation.prompt)
- if (s修改后的内容) {
- current_conversation.prompt = s修改后的内容
- alert('修改成功')
- } else
- alert('取消修改')
- }
- //获取用户输入
- input = async (title = '请输入', input = '') => {
- app.dialog_title = title
- app.dialog_input = input
- app.show_dialog = true
- await new Promise(resolve => {
- window.dialog_input_resolver = resolve
- })
- return app.dialog_input
- }
- </script>
- <script src="wd_sdk.js"></script>
- <script src="api/llm"></script>
- </body>
- </html>
|