Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
6fc5e823
提交
6fc5e823
authored
4月 19, 2023
作者:
imClumsyPanda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update webui.py
上级
4152fb1c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
10 行删除
+33
-10
webui.py
webui.py
+33
-10
没有找到文件。
webui.py
浏览文件 @
6fc5e823
...
@@ -108,10 +108,27 @@ def get_vector_store(filepath, history):
...
@@ -108,10 +108,27 @@ def get_vector_store(filepath, history):
def
change_vs_name_input
(
vs
):
def
change_vs_name_input
(
vs
):
if
vs
==
"新建知识库"
:
if
vs
==
"新建知识库"
:
return
gr
.
update
(
lines
=
1
,
visible
=
True
)
return
gr
.
update
(
visible
=
True
),
gr
.
update
(
visible
=
True
)
else
:
return
gr
.
update
(
visible
=
False
),
gr
.
update
(
visible
=
False
)
def
change_mode
(
mode
):
if
mode
==
"知识库问答"
:
return
gr
.
update
(
visible
=
True
)
else
:
else
:
return
gr
.
update
(
visible
=
False
)
return
gr
.
update
(
visible
=
False
)
def
add_vs_name
(
vs_name
,
vs_list
,
chatbot
):
if
vs_name
in
vs_list
:
chatbot
=
chatbot
+
[
None
,
"与已有知识库名称冲突,请重新选择其他名称后提交"
]
return
gr
.
update
(
visible
=
True
),
vs_list
,
chatbot
else
:
chatbot
=
chatbot
+
[
None
,
f
"""已新增知识库"{vs_name}" """
]
vs_list
=
vs_list
+
[
vs_name
]
return
gr
.
update
(
visible
=
True
),
vs_list
,
chatbot
block_css
=
""".importantButton {
block_css
=
""".importantButton {
background: linear-gradient(45deg, #7e0570,#5d1c99, #6e00ff) !important;
background: linear-gradient(45deg, #7e0570,#5d1c99, #6e00ff) !important;
...
@@ -140,22 +157,24 @@ model_status = init_model()
...
@@ -140,22 +157,24 @@ model_status = init_model()
with
gr
.
Blocks
(
css
=
block_css
)
as
demo
:
with
gr
.
Blocks
(
css
=
block_css
)
as
demo
:
vs_path
,
file_status
,
model_status
=
gr
.
State
(
""
),
gr
.
State
(
""
),
gr
.
State
(
model_status
)
vs_path
,
file_status
,
model_status
=
gr
.
State
(
""
),
gr
.
State
(
""
),
gr
.
State
(
model_status
)
gr
.
Markdown
(
webui_title
)
gr
.
Markdown
(
webui_title
)
with
gr
.
Tab
(
"
聊天
"
):
with
gr
.
Tab
(
"
对话
"
):
with
gr
.
Row
():
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
2
):
with
gr
.
Column
(
scale
=
10
):
chatbot
=
gr
.
Chatbot
([[
None
,
init_message
],
[
None
,
model_status
.
value
]],
chatbot
=
gr
.
Chatbot
([[
None
,
init_message
],
[
None
,
model_status
.
value
]],
elem_id
=
"chat-box"
,
elem_id
=
"chat-box"
,
show_label
=
False
)
.
style
(
height
=
750
)
show_label
=
False
)
.
style
(
height
=
750
)
query
=
gr
.
Textbox
(
show_label
=
False
,
query
=
gr
.
Textbox
(
show_label
=
False
,
placeholder
=
"请输入提问内容,按回车进行提交"
,
placeholder
=
"请输入提问内容,按回车进行提交"
,
)
.
style
(
container
=
False
)
)
.
style
(
container
=
False
)
with
gr
.
Column
(
scale
=
1
):
with
gr
.
Column
(
scale
=
5
):
gr
.
Markdown
(
"请选择使用模式"
)
mode
=
gr
.
Radio
([
"LLM 对话"
,
"知识库问答"
],
gr
.
Radio
([
"默认"
,
"知识库问答"
],
label
=
"请选择使用模式"
,
label
=
"请选择使用模式"
,
info
=
"默认模式将不使用知识库"
)
value
=
"知识库问答"
,)
with
gr
.
Accordion
(
"配置知识库"
):
vs_setting
=
gr
.
Accordion
(
"配置知识库"
)
# gr.Markdown("配置知识库")
mode
.
change
(
fn
=
change_mode
,
inputs
=
mode
,
outputs
=
vs_setting
)
with
vs_setting
:
select_vs
=
gr
.
Dropdown
(
vs_list
,
select_vs
=
gr
.
Dropdown
(
vs_list
,
label
=
"请选择要加载的知识库"
,
label
=
"请选择要加载的知识库"
,
interactive
=
True
,
interactive
=
True
,
...
@@ -163,9 +182,13 @@ with gr.Blocks(css=block_css) as demo:
...
@@ -163,9 +182,13 @@ with gr.Blocks(css=block_css) as demo:
vs_name
=
gr
.
Textbox
(
label
=
"请输入新建知识库名称"
,
vs_name
=
gr
.
Textbox
(
label
=
"请输入新建知识库名称"
,
lines
=
1
,
lines
=
1
,
interactive
=
True
)
interactive
=
True
)
vs_add
=
gr
.
Button
(
value
=
"添加至知识库选项"
)
vs_add
.
click
(
fn
=
add_vs_name
,
inputs
=
[
vs_name
,
vs_list
,
chatbot
],
outputs
=
[
select_vs
,
vs_list
,
chatbot
])
select_vs
.
change
(
fn
=
change_vs_name_input
,
select_vs
.
change
(
fn
=
change_vs_name_input
,
inputs
=
select_vs
,
inputs
=
select_vs
,
outputs
=
vs_name
)
outputs
=
[
vs_name
,
vs_add
]
)
gr
.
Markdown
(
"向知识库中添加文件"
)
gr
.
Markdown
(
"向知识库中添加文件"
)
with
gr
.
Tab
(
"上传文件"
):
with
gr
.
Tab
(
"上传文件"
):
files
=
gr
.
File
(
label
=
"添加文件"
,
files
=
gr
.
File
(
label
=
"添加文件"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论