forked from TsinghuaDatabaseGroup/DB-GPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webui.py
76 lines (65 loc) · 1.89 KB
/
webui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import streamlit as st
from webui_pages.diagnose import diagnose_page
from webui_pages.reports.resports import reports_page
from webui_pages.utils import *
from streamlit_option_menu import option_menu
from webui_pages.dialogue.dialogue import dialogue_page
from webui_pages.knowledge_base import knowledge_base_page
import os
import sys
from configs import VERSION
from server.utils import api_address
api = ApiRequest(base_url=api_address())
if __name__ == "__main__":
is_lite = "lite" in sys.argv
st.set_page_config(
"DB-GPT",
os.path.join("img", "chat_icon_blue_square_v2.png"),
layout="wide",
initial_sidebar_state="expanded"
)
css = """
<style>
.block-container {
padding-left: 20px !important;
padding-right: 20px !important;
padding-top: 40px !important;
padding-bottom: 40px !important;
}
</style>
"""
st.write(css, unsafe_allow_html=True)
pages = {
"Knowledge Base": {
"icon": "hdd-stack",
"func": knowledge_base_page,
},
"Chat": {
"icon": "chat",
"func": dialogue_page,
},
"Diagnosis": {
"icon": "heart-pulse",
"func": diagnose_page,
},
"History": {
"icon": "file-earmark-text",
"func": reports_page,
}
}
with st.sidebar:
st.caption(
f"""<p align="right">D-Bot Version:{VERSION}</p>""",
unsafe_allow_html=True,
)
options = list(pages)
icons = [x["icon"] for x in pages.values()]
default_index = 0
selected_page = option_menu(
"",
options=options,
icons=icons,
default_index=default_index,
)
if selected_page in pages:
pages[selected_page]["func"](api=api, is_lite=is_lite)