提交 da071258 编写于 作者: W weixin_44463441

Auto Commit

上级 d966ca23
<template>
<div class="w-full h-dvh">
<!-- toolbar -->
<div class="w-full h-14 border-b-2 shadow-2xl fixed bg-slate-200 flex justify-between items-center px-4 md:px-10">
<div class="w-full h-14 border-b-2 shadow-2xl fixed bg-slate-200 flex justify-between items-center px-2 sm:px-8">
<div class="flex-none flex gap-2 items-center">
<img class="w-8 h-8 rounded-full" src="https://csdn-665-inscode.s3.cn-north-1.jdcloud-oss.com/inscode/202307/622aa39c1f9b166ab1a38c05/1689313832234-63659446-QeEVrAvJoQIMBZjs2NChZ0MzsXv2Gz8B/avatar"/>
<span class="font-bold">{{ name }}</span>
</div>
<div class="flex-none *:ml-4 text-sm flex justify-end items-center">
<div class="flex-none text-sm flex justify-end items-center gap-4">
<button @click="page='chat'" :class="['text-gray-600', page === 'chat' ? 'text-blue-600' : '', page === 'chat' ? 'underline' : '']">Chat</button>
<button @click="page='content'" :class="['text-gray-600', page === 'content' ? 'text-blue-600' : '', page === 'content' ? 'underline' : '']">知识库</button>
<button>设置</button>
<button class="text-gray-500">设置</button>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
<!-- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-4 h-4 cursor-pointer inline" @click="cleanHistory">
<path stroke-linecap="round" stroke-linejoin="round"
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
</svg>
</svg> -->
</div>
......@@ -63,7 +63,9 @@
<!-- <markdown-it-vue class="md-body" content="123" :options="mdOptions" :key="index" v-if="item.message"/> -->
</template>
<p class="text-sm" v-else>思考中...</p>
<p v-else>
<t-loading text="AI思考中..." size="small"/>
</p>
</div>
</div>
......@@ -81,8 +83,8 @@
</div>
<div class="w-full absolute bottom-0 bg-slate-100 h-22 py-2 px-2 rounded flex flex-col text-sm">
<div class="w-full h-10 flex">
<input v-model="prompt" class="flex-auto ring-0 outline-0 pl-2 bg-slate-200 h-10 border-0" v-on:keyup.enter="query" placeholder="提示词" />
<div class="w-full h-10 flex justify-between items-center gap-4">
<input v-model="prompt" class="flex-auto ring-0 outline-0 pl-2 bg-slate-200 h-10 border-0 text-sm text-gray-700" v-on:keyup.enter="query" placeholder="提示词" />
<t-dropdown :options="options" @click="clickHandler" class="ml-4 mt-1" v-if="mode === 'draw'">
<t-button theme="default" variant="text" shape="square">
......@@ -97,9 +99,14 @@
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg> -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-6 h-6 text-red-800 hover:text-red-600 cursor-pointer inline" @click="cleanHistory">
<path stroke-linecap="round" stroke-linejoin="round"
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor"
class="w-6 mx-2 ml-4 mt-2 h-6 flex-none text-cyan-800 font-bold hover:text-cyan-600 cursor-pointer"
class="w-6 text-blue-800 font-bold hover:text-cyan-600 cursor-pointer"
@click="query">
<path stroke-linecap="round" stroke-linejoin="round"
d="M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5" />
......@@ -299,7 +306,7 @@ export default {
if (this.indexClient) {
this.indexClient.query(newPrompt).then(res => {
this.getAnswer(res, newPrompt, currentMsg)
this.getAnswer(res?.list, newPrompt, currentMsg)
}).catch((err) => {
this.getAnswer(null, newPrompt, currentMsg)
})
......
......@@ -3,25 +3,26 @@
<div class="p-4">
<div class="flex ju">
<input class="block my-2 w-full" v-model="newContent" maxLength="50"/>
<button class="bg-gray-300 px-4 h-10 rounded hover:bg-gray-400" @click="add"> add</button>
<button class="bg-gray-300 px-4 h-10 rounded hover:bg-gray-400 ml-2" @click="search"> search</button>
<div class="flex items-center gap-4">
<textarea class="block w-full rounded text-sm text-gray-600 h-10" v-model="newContent" maxLength="512" placeholder="输入需要搜索或保存的内容"></textarea>
<button class="bg-gray-500 px-4 h-10 rounded hover:bg-gray-600 text-gray-50" @click="search"> search</button>
<button class="bg-blue-500 px-4 h-10 rounded hover:bg-blue-600 text-gray-200" @click="add">+add</button>
</div>
<span>添加内容</span>
<textarea class="block my-2 w-full" v-model="newContent" maxLength="512"></textarea>
<!-- <span>添加内容</span>
<textarea class="block my-2 w-full rounded" v-model="newContent" maxLength="512"></textarea>
<button class="bg-gray-300 py-2 px-4 rounded hover:bg-gray-400" @click="add"> add</button>
<button class="bg-gray-300 py-2 px-4 rounded hover:bg-gray-400 ml-2" @click="search"> search</button>
-->
<div class="w-full mt-4">
<div class="float-right">
<div class="flex justify-between items-center">
<span class="text-gray-500 text-sm">
{{ data?.total }}条数据
{{ data?.total }} 条数据
</span>
<button v-if="data?.total === 0" class="bg-green-600 px-2 text-sm hover:bg-green-700 rounded-lg text-gray-100 h-6" @click="showLoadDataDialog=true">添加样例数据</button>
</div>
<table class="table-auto w-full bg-gray-200 text-left">
<thead>
......@@ -38,14 +39,21 @@
<textarea class="my-2 w-full bg-gray-100 max-h-48 border-gray-300 text-slate-600 text-sm" v-model="item.content" maxLength="512"></textarea>
</td>
<td class="*:py-1 *:px-4 *:rounded-md *:mr-2 *:text-gray-100 w-[160px]">
<button @click="deleteItem(item)" class="bg-orange-400 hover:bg-orange-500"> 删除</button>
<button @click="deleteItem(item)" class="bg-orange-400 hover:bg-orange-500 sm:inline"> 删除</button>
<button @click="updateItem(item)" class="bg-blue-400 hover:bg-blue-500"> 更新</button>
</td>
</tr>
</tbody>
</table>
</div>
<t-dialog
theme="warning"
header="确认操作"
body="是否需要加载样例数据?"
:visible.sync="showLoadDataDialog"
@confirm="loadDefaultContent"
:onClose="()=>showLoadDataDialog=false"
/>
</div>
</div>
......@@ -56,6 +64,8 @@ import Config from '../../js/config'
import RepEs from '../../js/repEs'
import { MessagePlugin } from 'tdesign-vue-next';
import ragDefaultData from '../../js/ragDefaultContent'
const esClient = new RepEs(Config.getData().data.ext)
export default {
......@@ -64,51 +74,91 @@ export default {
},
data() {
return {
showLoadDataDialog:false,
newContent: '',
list: [],
data: {}
}
},
mounted() {
this.search()
},
methods: {
add () {
add (functionInputContent) {
esClient.add(this.newContent).then(res=>{
MessagePlugin.success({ content: '添加成功', placement: 'center' })
let content = this.newContent
let showProcess = true
if (typeof functionInputContent === 'string' && functionInputContent) {
content = functionInputContent
showProcess = false
}
if (content.length < 10) {
MessagePlugin.error({ content: '内容长度需要超过10个字符', placement: 'center' })
} else {
esClient.add(content).then(res=>{
this.newContent = ''
if (showProcess) {
MessagePlugin.success({ content: '添加成功', placement: 'center' })
this.reloadData()
}
this.$nextTick(() => {
this.search()
})
})
}
},
search () {
esClient.query(this.newContent).then(res => {
console.info(res)
this.data = res
})
console.info(res)
this.data = res
})
},
updateItem (item) {
esClient.update(item._id, item.content).then(res => {
MessagePlugin.success({ content: '更新成功', placement: 'center' })
this.$nextTick(() => {
this.search()
}) })
if (item.content && item.content.length > 10) {
esClient.update(item._id, item.content).then(res => {
MessagePlugin.success({ content: '更新成功', placement: 'center' })
this.reloadData()
})
} else {
MessagePlugin.error({ content: '内容长度需要超过10个字符', placement: 'center' })
}
},
reloadData (waitMs=600) {
this.$nextTick(() => {
setTimeout(() => {
this.search()
}, waitMs)
})
},
deleteItem (item) {
esClient.delete(item._id).then(res => {
MessagePlugin.success({ content: '删除成功', placement: 'center' })
this.$nextTick(() => {
this.search()
})
this.reloadData()
}).catch(() => {
this.$nextTick(() => {
this.search()
})
this.reloadData()
})
},
loadDefaultContent () {
this.showLoadDataDialog = false
MessagePlugin.loading({ content: '正在导入,请稍等...', placement: 'center', duration: 2000 })
ragDefaultData.forEach(item => {
this.add(item)
})
this.reloadData(2000)
}
}
}
......
......@@ -12,7 +12,8 @@ const prompt_template = `
`
// 欢迎语,用户打开时自动发送给用户
const welcome_text = `你好,欢迎使用私人知识库,知识库仅供测试,数据可能随时被删除,请不用存放重要数据。
const welcome_text = `欢迎使用私人知识库,知识库仅供测试,数据可能随时被删除,请不用存放重要数据。
"知识库"页面用来管理内容,你可以导入样例数据快速体验,也可以添加自己的数据。
注意:结果由AI生成,可能存在不符合实际的联想内容,请注意甄别!
`
......
const content = [
`CSDN公司简介
董事长/创始人/CEO:蒋涛
CSDN使命:成就一亿技术人
CSDN愿景:成为技术人交流和成长的家园
官网地址: https://www.csdn.net/
CSDN(中国开发者网络)创立于1999年,是全球知名中文开发者网站。秉承成就一亿技术人的使命,为IT技术人成长及科技企业发展,提供开发者生态的全方位服务。CSDN在社区基础上,通过知识云、人才云、开发云三大服务,赋能开发者、研发团队及科技企业在IT知识学习、人才招聘、研发效能与协同管理等方面的高速成长与发展。
人人都是开发者,家家都是技术公司,CSDN全力前行,共建中国十万亿技术大生态!
公司主要数据:
全球编程类网站排名第7(来源:Similarweb 2022.05)
注册用户超过3500万,覆盖90%的中文开发者
超过1000家企业客户和合作伙伴
新媒体矩阵粉丝数量超过3100万
员工近800名,分布在北京、长沙、上海、深圳、杭州、成都等城市,并在美国硅谷常设办事处
`,
`InsCode 是一个一站式的软件开发服务平台,从开发-部署-运维-运营,都可以在 InsCode 轻松完成。
InsCode 的 Ins 是 Inspiration,意思是创作、寻找有灵感的代码。
官网地址:https://inscode.csdn.net/
开发团队介绍:
是由CSDN的开发云团队负责开发的,负责人是梁灏。
InsCode主要功能包括:
1. 云端开发环境,免费提供的 2 核/4 GB 开发环境;
2. 丰富的模板,如 Python、Java、HTML/CSS/JS、PHP、Go等语言模板的支持:
3. 内置AI辅助编程,可以实现添加注释、解释代码、完成代码、寻找错误、优化代码、添加测试、代码提问等 AI 功能。
4. 社区,开发的项目,可以发布到社区,每个发布的作品都是开源的,所以 InsCode 也是一个很好的学习平台。
5. 快速部署,可以一键部署开发的应用,或者直接部署 GitHub 应用。部署后提供独立的域名访问,并永久在线。
使用场景介绍:随时随地写代码,快速启动项目​,实时调试网页​,一键部署​,GPU 云容器​。
`,
`gitcode gitCode介绍
GitCode是CSDN战略打造的一站式开源代码协作平台
官网地址:https://gitcode.com/
平台定位与核心场景:
1.代码托管平台:解决开发者与企业代码协作与存储场景
2.开源社区:提供开源项目运营平台,推广开源项目,获取开源使用者和贡献者
3.软件开发生产线:帮助开发者与企业解决研发流程与提升研发效能
4.AI开源搜索: 面开发者的 AI 开源搜索工具,目的是为了帮助开发者快速寻找开源项目代码、解决开发问题和快速寻找答案,帮助开发者提升效率的同时利用代码仓托管能力建立自己个人知识库
`,
`RAG (Retrieval Augmented Generatio) 检索增强生成
检索增强生成 (RAG) 是一种使用来自私有或专有数据源的信息来辅助文本生成的技术。它将检索模型(设计用于搜索大型数据集或知识库)和生成模型(例如大型语言模型 (LLM),此类模型会使用检索到的信息生成可供阅读的文本回复)结合在一起。
通过从更多数据源添加背景信息,以及通过训练来补充 LLM 的原始知识库,检索增强生成能够提高搜索体验的相关性。这能够改善大型语言模型的输出,但又无需重新训练模型。额外信息源的范围很广,从训练 LLM 时并未用到的互联网上的新信息,到专有商业背景信息,或者属于企业的机密内部文档,都会包含在内。
RAG 对于诸如回答问题和内容生成等任务,具有极大价值,因为它能支持生成式 AI 系统使用外部信息源生成更准确且更符合语境的回答。它会实施搜索检索方法(通常是语义搜索或混合搜索)来回应用户的意图并提供更相关的结果。
`
]
export default content
\ No newline at end of file
......@@ -105,12 +105,16 @@ class RepEs {
}
update (id, content) {
debugger
const url = this.index_url + '/' + this.index_name + '/_doc/' + id
const token = this.token
return new Promise(function(resolve,rejcet){
axios.put(url, {content: content}).then(res => {
axios.put(url, {
user_token: token,
content: content
}).then(res => {
console.info(res)
resolve(res)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册