Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
ed7c5485
提交
ed7c5485
authored
6月 15, 2023
作者:
imClumsyPanda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add delete knowledge base and delete files from knowledge base to webui
上级
331f39cd
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
97 行增加
和
26 行删除
+97
-26
.gitignore
.gitignore
+1
-0
local_doc_qa.py
chains/local_doc_qa.py
+10
-0
README.md
knowledge_base/samples/content/README.md
+0
-0
test.jpg
knowledge_base/samples/content/test.jpg
+0
-0
test.pdf
knowledge_base/samples/content/test.pdf
+0
-0
test.txt
knowledge_base/samples/content/test.txt
+0
-0
MyFAISS.py
vectorstores/MyFAISS.py
+21
-10
webui.py
webui.py
+65
-16
没有找到文件。
.gitignore
浏览文件 @
ed7c5485
...
@@ -167,6 +167,7 @@ log/*
...
@@ -167,6 +167,7 @@ log/*
vector_store/*
vector_store/*
content/*
content/*
api_content/*
api_content/*
knowledge_base/*
llm/*
llm/*
embedding/*
embedding/*
...
...
chains/local_doc_qa.py
浏览文件 @
ed7c5485
...
@@ -297,6 +297,16 @@ class LocalDocQA:
...
@@ -297,6 +297,16 @@ class LocalDocQA:
status
=
vector_store
.
update_doc
(
filepath
,
docs
)
status
=
vector_store
.
update_doc
(
filepath
,
docs
)
return
status
return
status
def
list_file_from_vector_store
(
self
,
vs_path
,
fullpath
=
False
):
vector_store
=
load_vector_store
(
vs_path
,
self
.
embeddings
)
docs
=
vector_store
.
list_docs
()
if
fullpath
:
return
docs
else
:
return
[
os
.
path
.
split
(
doc
)[
-
1
]
for
doc
in
docs
]
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# 初始化消息
# 初始化消息
...
...
knowledge_base/samples/content/README.md
deleted
100644 → 0
浏览文件 @
331f39cd
差异被折叠。
点击展开。
knowledge_base/samples/content/test.jpg
deleted
100644 → 0
浏览文件 @
331f39cd
7.9 KB
knowledge_base/samples/content/test.pdf
deleted
100644 → 0
浏览文件 @
331f39cd
File deleted
knowledge_base/samples/content/test.txt
deleted
100644 → 0
浏览文件 @
331f39cd
差异被折叠。
点击展开。
vectorstores/MyFAISS.py
浏览文件 @
ed7c5485
from
langchain.vectorstores
import
FAISS
from
langchain.vectorstores
import
FAISS
from
langchain.vectorstores.base
import
VectorStore
from
langchain.vectorstores.base
import
VectorStore
from
langchain.vectorstores.faiss
import
dependable_faiss_import
from
langchain.vectorstores.faiss
import
dependable_faiss_import
from
typing
import
Any
,
Callable
,
List
,
Tuple
,
Dict
from
typing
import
Any
,
Callable
,
List
,
Dict
from
langchain.docstore.base
import
Docstore
from
langchain.docstore.base
import
Docstore
from
langchain.docstore.document
import
Document
from
langchain.docstore.document
import
Document
import
numpy
as
np
import
numpy
as
np
...
@@ -109,15 +109,22 @@ class MyFAISS(FAISS, VectorStore):
...
@@ -109,15 +109,22 @@ class MyFAISS(FAISS, VectorStore):
docs
.
append
(
doc
)
docs
.
append
(
doc
)
return
docs
return
docs
def
delete_doc
(
self
,
source
):
def
delete_doc
(
self
,
source
:
str
or
List
[
str
]
):
try
:
try
:
ids
=
[
k
for
k
,
v
in
self
.
docstore
.
_dict
.
items
()
if
v
.
metadata
[
"source"
]
==
source
]
if
isinstance
(
source
,
str
):
for
id
in
ids
:
ids
=
[
k
for
k
,
v
in
self
.
docstore
.
_dict
.
items
()
if
v
.
metadata
[
"source"
]
==
source
]
index
=
list
(
self
.
index_to_docstore_id
.
keys
())[
list
(
self
.
index_to_docstore_id
.
values
())
.
index
(
id
)]
else
:
self
.
index_to_docstore_id
.
pop
(
index
)
ids
=
[
k
for
k
,
v
in
self
.
docstore
.
_dict
.
items
()
if
v
.
metadata
[
"source"
]
in
source
]
self
.
docstore
.
_dict
.
pop
(
id
)
if
len
(
ids
)
==
0
:
return
f
"docs delete success"
return
f
"docs delete fail"
except
:
else
:
for
id
in
ids
:
index
=
list
(
self
.
index_to_docstore_id
.
keys
())[
list
(
self
.
index_to_docstore_id
.
values
())
.
index
(
id
)]
self
.
index_to_docstore_id
.
pop
(
index
)
self
.
docstore
.
_dict
.
pop
(
id
)
return
f
"docs delete success"
except
Exception
as
e
:
print
(
e
)
return
f
"docs delete fail"
return
f
"docs delete fail"
def
update_doc
(
self
,
source
,
new_docs
):
def
update_doc
(
self
,
source
,
new_docs
):
...
@@ -125,5 +132,9 @@ class MyFAISS(FAISS, VectorStore):
...
@@ -125,5 +132,9 @@ class MyFAISS(FAISS, VectorStore):
delete_len
=
self
.
delete_doc
(
source
)
delete_len
=
self
.
delete_doc
(
source
)
ls
=
self
.
add_documents
(
new_docs
)
ls
=
self
.
add_documents
(
new_docs
)
return
f
"docs update success"
return
f
"docs update success"
except
:
except
Exception
as
e
:
print
(
e
)
return
f
"docs update fail"
return
f
"docs update fail"
def
list_docs
(
self
):
return
list
(
set
(
v
.
metadata
[
"source"
]
for
v
in
self
.
docstore
.
_dict
.
values
()))
webui.py
浏览文件 @
ed7c5485
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论