Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
f7044f6f
提交
f7044f6f
authored
5月 29, 2023
作者:
imClumsyPanda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update webui.py
上级
c7106317
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
17 行删除
+20
-17
webui.py
webui.py
+20
-17
没有找到文件。
webui.py
浏览文件 @
f7044f6f
...
...
@@ -50,18 +50,18 @@ def get_answer(query, vs_path, history, mode, score_threshold=VECTOR_SEARCH_SCOR
enumerate
(
resp
[
"source_documents"
])])
history
[
-
1
][
-
1
]
+=
source
yield
history
,
""
elif
mode
==
"知识库问答"
and
vs_path
is
not
None
and
os
.
path
.
exists
(
vs_path
):
for
resp
,
history
in
local_doc_qa
.
get_knowledge_based_answer
(
query
=
query
,
vs_path
=
vs_path
,
chat_history
=
history
,
streaming
=
streaming
):
source
=
"
\n\n
"
source
+=
""
.
join
(
[
f
"""<details> <summary>出处 [{i + 1}] {os.path.split(doc.metadata["source"])[-1]}</summary>
\n
"""
f
"""{doc.page_content}
\n
"""
f
"""</details>"""
for
i
,
doc
in
enumerate
(
resp
[
"source_documents"
])])
history
[
-
1
][
-
1
]
+=
source
yield
history
,
""
elif
mode
==
"知识库问答"
and
vs_path
is
not
None
and
os
.
path
.
exists
(
vs_path
)
and
"index.faiss"
in
os
.
listdir
(
vs_path
)
:
for
resp
,
history
in
local_doc_qa
.
get_knowledge_based_answer
(
query
=
query
,
vs_path
=
vs_path
,
chat_history
=
history
,
streaming
=
streaming
):
source
=
"
\n\n
"
source
+=
""
.
join
(
[
f
"""<details> <summary>出处 [{i + 1}] {os.path.split(doc.metadata["source"])[-1]}</summary>
\n
"""
f
"""{doc.page_content}
\n
"""
f
"""</details>"""
for
i
,
doc
in
enumerate
(
resp
[
"source_documents"
])])
history
[
-
1
][
-
1
]
+=
source
yield
history
,
""
elif
mode
==
"知识库测试"
:
if
os
.
path
.
exists
(
vs_path
):
resp
,
prompt
=
local_doc_qa
.
get_knowledge_based_conent_test
(
query
=
query
,
vs_path
=
vs_path
,
...
...
@@ -86,12 +86,11 @@ def get_answer(query, vs_path, history, mode, score_threshold=VECTOR_SEARCH_SCOR
yield
history
+
[[
query
,
"请选择知识库后进行测试,当前未选择知识库。"
]],
""
else
:
for
answer_result
in
local_doc_qa
.
llm
.
generatorAnswer
(
prompt
=
query
,
history
=
history
,
for
answer_result
in
local_doc_qa
.
llm
.
generatorAnswer
(
prompt
=
query
,
history
=
history
[:
-
1
]
,
streaming
=
streaming
):
resp
=
answer_result
.
llm_output
[
"answer"
]
history
=
answer_result
.
history
history
[
-
1
][
-
1
]
=
resp
+
(
"
\n\n
当前知识库为空,如需基于知识库进行问答,请先加载知识库后,再进行提问。"
if
mode
==
"知识库问答"
else
""
)
history
[
-
1
][
-
1
]
=
resp
yield
history
,
""
logger
.
info
(
f
"flagging: username={FLAG_USER_NAME},query={query},vs_path={vs_path},mode={mode},history={history}"
)
flag_csv_logger
.
flag
([
query
,
vs_path
,
history
,
mode
],
username
=
FLAG_USER_NAME
)
...
...
@@ -169,9 +168,13 @@ def change_vs_name_input(vs_id, history):
if
vs_id
==
"新建知识库"
:
return
gr
.
update
(
visible
=
True
),
gr
.
update
(
visible
=
True
),
gr
.
update
(
visible
=
False
),
None
,
history
else
:
file_status
=
f
"已加载知识库{vs_id},请开始提问"
vs_path
=
os
.
path
.
join
(
VS_ROOT_PATH
,
vs_id
)
if
"index.faiss"
in
os
.
listdir
(
vs_path
):
file_status
=
f
"已加载知识库{vs_id},请开始提问"
else
:
file_status
=
f
"已选择知识库{vs_id},当前知识库中未上传文件,请先上传文件后,再开始提问"
return
gr
.
update
(
visible
=
False
),
gr
.
update
(
visible
=
False
),
gr
.
update
(
visible
=
True
),
\
os
.
path
.
join
(
VS_ROOT_PATH
,
vs_id
)
,
history
+
[[
None
,
file_status
]]
vs_path
,
history
+
[[
None
,
file_status
]]
knowledge_base_test_mode_info
=
(
"【注意】
\n\n
"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论