提交 bb44e587 编写于 作者: W weixin_44463441

Thu Jan 11 19:54:00 CST 2024 inscode

上级 2b8e60df
<template>
<div class="w-full h-screen">
<!-- toolbar -->
<div class="w-full h-14 pt-2 border-b-2 shadow-2xl text-center fixed bg-slate-200">
<a href="#/llm-rep/app/">
<div class="w-full h-14 pt-2 border-b-2 shadow-2xl fixed bg-slate-200 flex items-center">
<div class="flex-none w-1/3">
</div>
<div class="flex-none w-1/3 text-center">
<span class="leading-10 font-bold">{{ name }} {{ config?.mode === 'completions' ? '(无上下文)' : '' }}</span>
</div>
<div class="flex-none w-1/3 *:ml-4 *:text-gray-600 *:hover:text-gray-900 text-sm float-right flex justify-end pr-4">
<button @click="page='chat'">Chat</button>
<button @click="page='content'">知识库</button>
<button>设置</button>
<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 absolute left-4 top-5">
class="w-4 h-4 cursor-pointer inline" @click="cleanHistory">
<path stroke-linecap="round" stroke-linejoin="round"
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
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>
</a>
<span class="leading-10 font-bold">{{ name }} {{ config?.mode === 'completions' ? '(无上下文)' : '' }}</span>
<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 absolute right-4 top-5 cursor-pointer" @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>
</div>
</div>
<!-- main content -->
<div class="flex w-full h-full pt-14">
<!-- left -->
<div class="flex-none w-0 md:w-[260px] bg-slate-200 border-r-2 hidden md:block p-8 text-sm">
<t-form labelAlign="top">
<t-form-item label="GPT服务器类型" name="sdServerType">
<t-select v-model="sdServerType" @change="handleSDServerTypeChange" class="bg-gray-200" style="background: #ccc;font-size:12px;">
<t-option v-for="(item, index) in sdServerTypeOptions" :key="index" :value="item.value" :label="item.label">
{{ item.label }}
</t-option>
</t-select>
</t-form-item>
<t-form-item label="服务器地址" name="sdServerUrl">
<t-textarea placeholder="请输入内容" v-model="sdServerUrl" :autosize="true" @change="saveConfig"/>
</t-form-item>
</t-form>
<t-card class="bg-orange-100 mt-8 text-gray-600 text-sm" v-if="sdServerType === 'common'">
公共服务器为临时提供的测试服务器,可能存在需要排队或随时下线的可能。<br/>
建议使用
<t-tooltip content='购买后上面服务器地址填写 工作台-小羊驼 域名,同时把端口换成8000,并添加"/v1"后缀' theme="primary">
<t-link href="https://inscode.csdn.net/gpu?utm_source=sd_app" target="_blank" :suffix-icon="renderSuffixIcon" underline>私有服务器</t-link>
</t-tooltip>
</t-card>
<t-form labelAlign="top" label-width="100" :style="{display: showProfileSetting ? 'block':'none'}">
<t-form-item label="机器人头像">
<!-- <t-input placeholder="请输入内容" v-model="config.robot_img"/> -->
<t-space direction="vertical" align="center" v-for="imgItem in robotAvatarList" class="mr-2 cursor-pointer hover:bg-blue-600">
<t-image class="rounded-lg border-2 " :class="{ 'border-blue-800': imgItem.src === config.robot_img }"
@click="changeRobotAvatar(imgItem.src)" :src="imgItem.src" fit="cover"
:style="{ width: '40px', height: '40px' }" />
<!-- <span>{{ imgItem.name }}</span> -->
</t-space>
</t-form-item>
<t-form-item label="你的头像">
<t-space direction="vertical" align="center" v-for="imgItem in userAvatarList" class="mr-2 cursor-pointer hover:bg-blue-600">
<t-image class="rounded-lg border-2 " :class="{ 'border-blue-800': imgItem.src === config.user_img }"
@click="changeUserAvatar(imgItem.src)" :src="imgItem.src" fit="cover"
:style="{ width: '40px', height: '40px' }" />
<!-- <span>{{ imgItem.name }}</span> -->
</t-space>
</t-form-item>
<t-form-item label="机器人对你的称呼" help="多个称呼用逗号隔开">
<t-input v-model="config.user_call_name" />
</t-form-item>
</t-form>
<div v-if="page === 'content'" class="w-full bg-slate-300 md:bg-slate-300 p-2 sm:p-8">
<content/>
</div>
<!-- right -->
<div class="flex-auto bg-slate-300 md:bg-slate-300 p-2 sm:p-8">
<div class="flex-auto bg-slate-300 md:bg-slate-300 p-2 sm:p-8" v-else>
<content/>
<div class="w-full bg-slate-200 h-full m-auto relative container max-w-6xl rounded-xl">
<div class="w-full h-full pb-24 p-4 overflow-y-auto overflow-x-hidden" ref="messageList">
......@@ -188,6 +155,7 @@ export default {
},
data() {
return {
page: '',
id: 0,
name: '加载中...',
userAvatarList: [],
......
......@@ -4,7 +4,7 @@
<div class="p-4">
<span>添加内容</span>
<textarea class="block my-2 w-full" v-model="newContent"></textarea>
<textarea class="block my-2 w-full" 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>
......@@ -21,9 +21,11 @@
</thead>
<tbody>
<tr v-for="item in list" class="*:h-12 *:border-b *:border-slate-300 *:pl-2 *:hover:bg-gray-300">
<td >{{ item._id }}</td>
<td>{{ item.content }}</td>
<td class="*:py-1 *:px-4 *:rounded-md *:mr-2 *:text-gray-100">
<td class="w-[80px]">{{ item._id }}</td>
<td>
<textarea class="my-2 w-full bg-gray-100 max-h-48 border-gray-300" 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="updateItem(item)" class="bg-blue-400 hover:bg-blue-500"> 更新</button>
</td>
......@@ -50,31 +52,48 @@ export default {
},
data() {
return {
newContent: '测试内容',
newContent: '',
list: []
}
},
methods: {
add () {
debugger
esClient.add(this.newContent)
esClient.add(this.newContent).then(res=>{
MessagePlugin.success({ content: '添加成功', placement: 'center' })
this.newContent = ''
this.$nextTick(() => {
this.search()
})
})
},
search () {
esClient.query(this.newContent).then(res => {
console.info('query')
console.info(res)
this.list = res
})
},
updateItem (item) {
esClient.update(item._id, item.content).then(res => {
MessagePlugin.success({ content: '更新成功', placement: 'center' })
})
this.$nextTick(() => {
this.search()
}) })
},
deleteItem (item) {
esClient.delete(item._id).then(res => {
MessagePlugin.success({ content: '删除成功', placement: 'center' })
this.$nextTick(() => {
this.search()
})
}).catch(() => {
this.$nextTick(() => {
this.search()
})
})
},
......
......@@ -70,18 +70,8 @@ class RepEs {
user_token: token,
content: content,
}).then(res => {
if (res?.status === 200 && res?.data?.code === 200) {
const result = []
res?.data?.data?.hits.forEach(element => {
result.push({
page_content: element?._source?.content
})
});
resolve(result)
}
console.info(res)
resolve(res)
}).catch((err) => {
......@@ -101,7 +91,7 @@ class RepEs {
axios.delete(url).then(res => {
console.info(res)
resolve(result)
resolve(res)
}).catch((err) => {
console.error(err)
......@@ -120,7 +110,7 @@ class RepEs {
axios.put(url, {content: content}).then(res => {
console.info(res)
resolve(result)
resolve(res)
}).catch((err) => {
console.error(err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册