From 4f4928e5367a9dc04dd692ec6095009a7473dea9 Mon Sep 17 00:00:00 2001
From: xerrors
Date: Tue, 3 Sep 2024 16:37:59 +0800
Subject: [PATCH] syncupdate packages
---
src/config/__init__.py | 11 +-
web/src/assets/main.css | 3 +-
web/src/components/ChatComponent.vue | 3 +-
web/src/components/RefsComponent.vue | 7 +-
web/src/views/DataBaseInfoView.vue | 300 +++++++++++++++------------
web/src/views/GraphView.vue | 24 ++-
web/src/views/SettingView.vue | 8 +-
7 files changed, 197 insertions(+), 159 deletions(-)
diff --git a/src/config/__init__.py b/src/config/__init__.py
index b98038c4..50ae6ce7 100644
--- a/src/config/__init__.py
+++ b/src/config/__init__.py
@@ -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.")
diff --git a/web/src/assets/main.css b/web/src/assets/main.css
index 8dd4cc93..238be927 100644
--- a/web/src/assets/main.css
+++ b/web/src/assets/main.css
@@ -7,7 +7,8 @@
/* layout */
.layout-container {
- padding: 10px 30px;
+ width: 100%;
+ padding: 16px 30px;
background-color: #FCFEFF;
h2 {
diff --git a/web/src/components/ChatComponent.vue b/web/src/components/ChatComponent.vue
index 81db3604..37374d1a 100644
--- a/web/src/components/ChatComponent.vue
+++ b/web/src/components/ChatComponent.vue
@@ -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;
diff --git a/web/src/components/RefsComponent.vue b/web/src/components/RefsComponent.vue
index 1223053f..40249865 100644
--- a/web/src/components/RefsComponent.vue
+++ b/web/src/components/RefsComponent.vue
@@ -28,13 +28,13 @@
相似度距离:
-
+
重排序分数:
@@ -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;
diff --git a/web/src/views/DataBaseInfoView.vue b/web/src/views/DataBaseInfoView.vue
index 1f6e6658..22c4d85c 100644
--- a/web/src/views/DataBaseInfoView.vue
+++ b/web/src/views/DataBaseInfoView.vue
@@ -18,14 +18,6 @@
{{ database.embed_model }}
-
参数配置
-
-
向知识库中添加文件
-
-
- 点击或者把文件拖拽到这里上传
-
- 目前仅支持上传文本文件,如 .pdf, .txt, .md。且同名文件无法重复添加。
-
-
-
-
- 添加到知识库
-
-
刷新状态
-
-
-
- {{ text.toUpperCase() }}
-
- {{ text.toUpperCase() }}
-
-
-
-
-
-
-
-
-
-
-
-
-
- 删除
-
-
- {{ formatRelativeTime(Math.round(text*1000)) }}
- {{ text }}
-
-
-
- 共 {{ selectedFile?.lines.length }} 个片段
-
- Chunk #{{ line.id }} {{ line.text }}
-
-
-
-
-
检索测试
-
-
-
-
- #{{ idx + 1 }}
- {{ result.file.filename }}
- 距离:{{ result.distance.toFixed(4) }}
- 重排序:{{ result.rerank_score.toFixed(4) }}
-
-
{{ result.entity.text }}
+
+
+ 添加文件
+
+
向知识库中添加文件
+
+
+ 点击或者把文件拖拽到这里上传
+
+ 目前仅支持上传文本文件,如 .pdf, .txt, .md。且同名文件无法重复添加。
+
+
+
+
+ 添加到知识库
+
+
刷新状态
+
+
+
+ {{ text.toUpperCase() }}
+
+ {{ text.toUpperCase() }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+ {{ formatRelativeTime(Math.round(text*1000)) }}
+ {{ text }}
+
+
+
+ 共 {{ selectedFile?.lines.length }} 个片段
+
+ Chunk #{{ line.id }} {{ line.text }}
+
+
-
-
+
+
+ 检索测试
+
+
检索测试
+
+
+
+
+ #{{ idx + 1 }}
+ {{ result.file.filename }}
+ 距离:{{ result.distance.toFixed(4) }}
+ 重排序:{{ result.rerank_score.toFixed(4) }}
+
+
{{ result.entity.text }}
+
+
+
+
+
+
@@ -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;
diff --git a/web/src/views/GraphView.vue b/web/src/views/GraphView.vue
index 13afc759..4e7320fc 100644
--- a/web/src/views/GraphView.vue
+++ b/web/src/views/GraphView.vue
@@ -1,5 +1,5 @@
-
+
Neo4j 图数据库
基于 Neo4j 构建的图数据库。
@@ -50,13 +50,12 @@
-
- 前往 设置 页面配置知识库。
+ 前往 设置 页面配置图数据库。
@@ -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);
diff --git a/web/src/views/SettingView.vue b/web/src/views/SettingView.vue
index b64a389d..0960b94c 100644
--- a/web/src/views/SettingView.vue
+++ b/web/src/views/SettingView.vue
@@ -88,13 +88,13 @@
@change="handleChange('enable_knowledge_base', !configStore.config.enable_knowledge_base)"
/>
-
+
{{ items?.enable_search_engine.des }}
{
+ 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)