Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
0f3fc523
提交
0f3fc523
authored
5月 21, 2023
作者:
imClumsyPanda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update webui.py and api.py
上级
483b7dd2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
3 行删除
+15
-3
api.py
api.py
+1
-1
webui.py
webui.py
+14
-2
没有找到文件。
api.py
浏览文件 @
0f3fc523
...
@@ -266,7 +266,7 @@ async def bing_search_chat(
...
@@ -266,7 +266,7 @@ async def bing_search_chat(
):
):
pass
pass
source_documents
=
[
source_documents
=
[
f
"""出处 [{inum + 1}]
{doc.metadata['source']}:
\n\n
{doc.page_content}
\n\n
"""
f
"""出处 [{inum + 1}]
<a href="{doc.metadata["source"]}" target="_blank">{doc.metadata["source"]}</a>
\n\n
{doc.page_content}
\n\n
"""
for
inum
,
doc
in
enumerate
(
resp
[
"source_documents"
])
for
inum
,
doc
in
enumerate
(
resp
[
"source_documents"
])
]
]
...
...
webui.py
浏览文件 @
0f3fc523
...
@@ -41,7 +41,19 @@ flag_csv_logger = gr.CSVLogger()
...
@@ -41,7 +41,19 @@ flag_csv_logger = gr.CSVLogger()
def
get_answer
(
query
,
vs_path
,
history
,
mode
,
score_threshold
=
VECTOR_SEARCH_SCORE_THRESHOLD
,
def
get_answer
(
query
,
vs_path
,
history
,
mode
,
score_threshold
=
VECTOR_SEARCH_SCORE_THRESHOLD
,
vector_search_top_k
=
VECTOR_SEARCH_TOP_K
,
chunk_conent
:
bool
=
True
,
vector_search_top_k
=
VECTOR_SEARCH_TOP_K
,
chunk_conent
:
bool
=
True
,
chunk_size
=
CHUNK_SIZE
,
streaming
:
bool
=
STREAMING
):
chunk_size
=
CHUNK_SIZE
,
streaming
:
bool
=
STREAMING
):
if
mode
==
"知识库问答"
and
vs_path
is
not
None
and
os
.
path
.
exists
(
vs_path
):
if
mode
==
"Bing搜索问答"
:
for
resp
,
history
in
local_doc_qa
.
get_search_result_based_answer
(
query
=
query
,
chat_history
=
history
,
streaming
=
streaming
):
source
=
"
\n\n
"
source
+=
""
.
join
(
[
f
"""<details> <summary>出处 [{i + 1}] <a href="{doc.metadata["source"]}" target="_blank">{doc.metadata["source"]}</a> </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
):
for
resp
,
history
in
local_doc_qa
.
get_knowledge_based_answer
(
for
resp
,
history
in
local_doc_qa
.
get_knowledge_based_answer
(
query
=
query
,
vs_path
=
vs_path
,
chat_history
=
history
,
streaming
=
streaming
):
query
=
query
,
vs_path
=
vs_path
,
chat_history
=
history
,
streaming
=
streaming
):
source
=
"
\n\n
"
source
=
"
\n\n
"
...
@@ -264,7 +276,7 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
...
@@ -264,7 +276,7 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
query
=
gr
.
Textbox
(
show_label
=
False
,
query
=
gr
.
Textbox
(
show_label
=
False
,
placeholder
=
"请输入提问内容,按回车进行提交"
)
.
style
(
container
=
False
)
placeholder
=
"请输入提问内容,按回车进行提交"
)
.
style
(
container
=
False
)
with
gr
.
Column
(
scale
=
5
):
with
gr
.
Column
(
scale
=
5
):
mode
=
gr
.
Radio
([
"LLM 对话"
,
"知识库问答"
],
mode
=
gr
.
Radio
([
"LLM 对话"
,
"知识库问答"
,
"Bing搜索问答"
],
label
=
"请选择使用模式"
,
label
=
"请选择使用模式"
,
value
=
"知识库问答"
,
)
value
=
"知识库问答"
,
)
knowledge_set
=
gr
.
Accordion
(
"知识库设定"
,
visible
=
False
)
knowledge_set
=
gr
.
Accordion
(
"知识库设定"
,
visible
=
False
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论