syncupdate packages
This commit is contained in:
parent
8d6107fa0a
commit
4f4928e536
@ -38,12 +38,12 @@ class Config(SimpleConfig):
|
||||
|
||||
### >>> 默认配置
|
||||
# 可以在 config/base.yaml 中覆盖
|
||||
self.add_item("mode", default="cli", des="运行模式", choices=["cli", "api"])
|
||||
self.add_item("stream", default=True, des="是否开启流式输出")
|
||||
self.add_item("save_dir", default="saves", des="保存目录")
|
||||
# 功能选项
|
||||
self.add_item("enable_reranker", default=False, des="是否开启重排序")
|
||||
self.add_item("enable_knowledge_base", default=False, des="是否开启知识库")
|
||||
self.add_item("enable_knowledge_graph", default=False, des="是否开启知识图谱")
|
||||
self.add_item("enable_search_engine", default=False, des="是否开启搜索引擎")
|
||||
|
||||
# 模型配置
|
||||
@ -70,6 +70,13 @@ class Config(SimpleConfig):
|
||||
"choices": choices
|
||||
}
|
||||
|
||||
def __dict__(self):
|
||||
blocklist = [
|
||||
"_config_items",
|
||||
"model_names",
|
||||
]
|
||||
return {k: v for k, v in self.items() if k not in blocklist}
|
||||
|
||||
def handle_self(self):
|
||||
### handle local model
|
||||
model_root_dir = os.getenv("MODEL_ROOT_DIR", "pretrained_models")
|
||||
@ -98,7 +105,6 @@ class Config(SimpleConfig):
|
||||
content = f.read()
|
||||
if content:
|
||||
local_config = json.loads(content)
|
||||
local_config.pop("_config_items")
|
||||
self.update(local_config)
|
||||
else:
|
||||
print(f"{self.filename} is empty.")
|
||||
@ -108,7 +114,6 @@ class Config(SimpleConfig):
|
||||
content = f.read()
|
||||
if content:
|
||||
local_config = yaml.safe_load(content)
|
||||
local_config.pop("_config_items")
|
||||
self.update(local_config)
|
||||
else:
|
||||
print(f"{self.filename} is empty.")
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
/* layout */
|
||||
|
||||
.layout-container {
|
||||
padding: 10px 30px;
|
||||
width: 100%;
|
||||
padding: 16px 30px;
|
||||
background-color: #FCFEFF;
|
||||
|
||||
h2 {
|
||||
|
||||
@ -329,6 +329,7 @@ const updateStatus = (id, status) => {
|
||||
return acc;
|
||||
}, {})
|
||||
}
|
||||
scrollToBottom()
|
||||
}
|
||||
|
||||
const simpleCall = (message) => {
|
||||
@ -573,7 +574,7 @@ watch(
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
flex-grow: 1;
|
||||
padding: 1rem;
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
|
||||
@ -28,13 +28,13 @@
|
||||
<p class="result-distance">
|
||||
<strong>相似度距离:</strong>
|
||||
<div class="scorebar">
|
||||
<a-progress :percent="(res.distance * 100).toFixed(2)" stroke-color="#1677FF" :size="[200, 10]"/>
|
||||
<a-progress :percent="parseFloat((res.distance * 100).toFixed(2))" stroke-color="#1677FF" :size="[200, 10]"/>
|
||||
</div>
|
||||
</p>
|
||||
<p class="result-rerank-score">
|
||||
<p class="result-rerank-score" v-if="res.rerank_score">
|
||||
<strong>重排序分数:</strong>
|
||||
<div class="scorebar">
|
||||
<a-progress :percent="(res.rerank_score * 100).toFixed(2)" stroke-color="#1677FF" :size="[200, 10]"/>
|
||||
<a-progress :percent="parseFloat((res.rerank_score * 100).toFixed(2))" stroke-color="#1677FF" :size="[200, 10]"/>
|
||||
</div>
|
||||
</p>
|
||||
<a-divider />
|
||||
@ -74,7 +74,6 @@ const showRefs = computed(() => message.value.role=='received' && message.value.
|
||||
.item {
|
||||
background: var(--main-10);
|
||||
color: var(--main-600);
|
||||
border: 1px solid var(--main-50);
|
||||
padding: 2px 8px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
|
||||
@ -18,14 +18,6 @@
|
||||
<a-tag color="blue" v-if="database.embed_model">{{ database.embed_model }}</a-tag>
|
||||
</div>
|
||||
<a-divider/>
|
||||
<div class="pagebtns">
|
||||
<div @click="state.curPage='add'" :class="{ 'active': state.curPage === 'add' }">
|
||||
<CloudUploadOutlined />添加文件
|
||||
</div>
|
||||
<div @click="state.curPage='query-test'" :class="{ 'active': state.curPage === 'query-test' }">
|
||||
<SearchOutlined />检索测试
|
||||
</div>
|
||||
</div>
|
||||
<div class="query-params" v-if="state.curPage == 'query-test'">
|
||||
<p style="text-align: center; margin: 0;"><strong>参数配置</strong></p>
|
||||
<div class="params-item">
|
||||
@ -46,7 +38,10 @@
|
||||
<div class="sider-bottom">
|
||||
</div>
|
||||
</div>
|
||||
<div class="db-info-container" v-if="state.curPage == 'add'">
|
||||
<a-tabs v-model:activeKey="state.curPage" class="atab-container" type="card">
|
||||
<a-tab-pane key="add">
|
||||
<template #tab><span><CloudUploadOutlined />添加文件</span></template>
|
||||
<div class="db-info-container">
|
||||
<h3>向知识库中添加文件</h3>
|
||||
<div class="upload">
|
||||
<a-upload-dragger
|
||||
@ -118,7 +113,10 @@
|
||||
</p>
|
||||
</a-drawer>
|
||||
</div>
|
||||
<div class="db-info-container" v-else-if="state.curPage == 'query-test'">
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="query-test" force-render>
|
||||
<template #tab><span><SearchOutlined />检索测试</span></template>
|
||||
<div class="db-info-container">
|
||||
<h3>检索测试</h3>
|
||||
<div class="query-action">
|
||||
<a-textarea
|
||||
@ -127,8 +125,9 @@
|
||||
:auto-size="{ minRows: 2, maxRows: 10 }"
|
||||
/>
|
||||
<!-- :loading="state.searchLoading" -->
|
||||
<a-button @click="onQuery" :disabled="queryText.length == 0" :loading="state.searchLoading">
|
||||
<SearchOutlined v-if="!state.searchLoading"/>检索
|
||||
<a-button class="btn-query" @click="onQuery" :disabled="queryText.length == 0">
|
||||
<span v-if="!state.searchLoading"><SearchOutlined /> 检索</span>
|
||||
<span v-else><LoadingOutlined /></span>
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="query-test" v-if="queryResult">
|
||||
@ -143,6 +142,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
<!-- <a-tab-pane key="3" tab="Tab 3">Content of Tab Pane 3</a-tab-pane> -->
|
||||
</a-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -160,6 +162,7 @@ import {
|
||||
DeleteOutlined,
|
||||
CloudUploadOutlined,
|
||||
SearchOutlined,
|
||||
LoadingOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
|
||||
|
||||
@ -490,38 +493,38 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.pagebtns {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
// .pagebtns {
|
||||
// display: flex;
|
||||
// flex-direction: column;
|
||||
// gap: 16px;
|
||||
|
||||
> div {
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10px 16px;
|
||||
height: auto;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
background: var(--main-light-5);
|
||||
letter-spacing: 4px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--main-light-2);
|
||||
// > div {
|
||||
// gap: 1rem;
|
||||
// width: 100%;
|
||||
// display: flex;
|
||||
// justify-content: center;
|
||||
// align-items: center;
|
||||
// padding: 10px 16px;
|
||||
// height: auto;
|
||||
// border-radius: 4px;
|
||||
// border: none;
|
||||
// background: var(--main-light-5);
|
||||
// letter-spacing: 4px;
|
||||
// border-radius: 8px;
|
||||
// border: 1px solid var(--main-light-2);
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
background: var(--main-light-3);
|
||||
}
|
||||
}
|
||||
// &:hover {
|
||||
// cursor: pointer;
|
||||
// background: var(--main-light-3);
|
||||
// }
|
||||
// }
|
||||
|
||||
.active {
|
||||
color: var(--main-color);
|
||||
background: var(--main-light-3);
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
// .active {
|
||||
// color: var(--main-color);
|
||||
// background: var(--main-light-3);
|
||||
// font-weight: bold;
|
||||
// }
|
||||
// }
|
||||
|
||||
.query-params {
|
||||
display: flex;
|
||||
@ -549,10 +552,13 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.atab-container {
|
||||
padding: 12px 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.db-info-container {
|
||||
padding: 20px;
|
||||
flex: 1 1 auto;
|
||||
overflow: scroll;
|
||||
|
||||
.query-action {
|
||||
display: flex;
|
||||
@ -564,13 +570,13 @@ onMounted(() => {
|
||||
border: 1px solid var(--main-light-2);
|
||||
}
|
||||
|
||||
button {
|
||||
button.btn-query {
|
||||
height: auto;
|
||||
width: 120px;
|
||||
width: 100px;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
background: var(--main-light-2);
|
||||
background: var(--main-light-3);
|
||||
color: var(--main-color);
|
||||
|
||||
&:disabled {
|
||||
@ -627,6 +633,24 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 10px;
|
||||
background: var(--main-color);
|
||||
display: block;
|
||||
opacity: 0.5;
|
||||
z-index: -1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
color: var(--c-text-light-1);
|
||||
font-size: small;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="graph-container layout-container" v-if="configStore.config.enable_knowledge_base">
|
||||
<div class="graph-container layout-container" v-if="state.showPage">
|
||||
<div class="info">
|
||||
<h2>Neo4j 图数据库</h2>
|
||||
<p>基于 Neo4j 构建的图数据库。</p>
|
||||
@ -50,13 +50,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="main" id="container"></div>
|
||||
|
||||
</div>
|
||||
<div class="database-empty" v-else>
|
||||
<a-empty>
|
||||
<template #description>
|
||||
<span>
|
||||
前往 <router-link to="/setting" style="color: var(--main-color); font-weight: bold;">设置</router-link> 页面配置知识库。
|
||||
前往 <router-link to="/setting" style="color: var(--main-color); font-weight: bold;">设置</router-link> 页面配置图数据库。
|
||||
</span>
|
||||
</template>
|
||||
</a-empty>
|
||||
@ -94,10 +93,13 @@ const state = reactive({
|
||||
searchLoading: false,
|
||||
showModal: false,
|
||||
precessing: false,
|
||||
showPage: computed(() => configStore.config.enable_knowledge_base && configStore.config.enable_knowledge_graph),
|
||||
})
|
||||
|
||||
const getCurWidth = () => document.getElementById("container").offsetWidth
|
||||
const getCurHeight = () => document.getElementById("container").offsetHeight
|
||||
// const showPage = computed(() => {
|
||||
// return configStore.config.enable_knowledge_base && configStore.config.enable_knowledge_graph
|
||||
// })
|
||||
|
||||
|
||||
const graphData = computed(() => {
|
||||
return {
|
||||
@ -174,14 +176,15 @@ const randerGraph = () => {
|
||||
graphInstance.render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!state.showPage) {
|
||||
return
|
||||
}
|
||||
|
||||
graphInstance = new Graph({
|
||||
container: document.getElementById("container"),
|
||||
width: getCurWidth(),
|
||||
height: getCurHeight(),
|
||||
width: document.getElementById("container").offsetWidth,
|
||||
height: document.getElementById("container").offsetHeight,
|
||||
autoFit: true,
|
||||
autoResize: true,
|
||||
layout: {
|
||||
@ -273,6 +276,7 @@ const handleDrop = (event) => {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
color: var(--c-text-light-1);
|
||||
|
||||
@ -88,13 +88,13 @@
|
||||
@change="handleChange('enable_knowledge_base', !configStore.config.enable_knowledge_base)"
|
||||
/>
|
||||
</div>
|
||||
<!-- <div class="card">
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_knowledge_graph.des }}</span>
|
||||
<a-switch
|
||||
:checked="configStore.config.enable_knowledge_graph"
|
||||
@change="handleChange('enable_knowledge_graph', !configStore.config.enable_knowledge_graph)"
|
||||
/>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="card">
|
||||
<span class="label">{{ items?.enable_search_engine.des }}</span>
|
||||
<a-switch
|
||||
@ -136,6 +136,10 @@ const state = reactive({
|
||||
})
|
||||
|
||||
const handleChange = (key, e) => {
|
||||
if (key == 'enable_knowledge_graph' && e && !configStore.config.enable_knowledge_base) {
|
||||
message.error('请先启用知识库功能')
|
||||
return
|
||||
}
|
||||
console.log('Change', key, e)
|
||||
needRestart[key] = true
|
||||
configStore.setConfigValue(key, e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user