Langchain-Chatchat/webui.py

62 lines
1.7 KiB
Python
Raw Normal View History

2023-07-27 23:22:07 +08:00
import streamlit as st
2023-08-01 14:47:38 +08:00
from webui_pages.utils import *
2023-07-28 06:58:34 +08:00
from streamlit_option_menu import option_menu
2023-08-01 14:47:38 +08:00
from webui_pages import *
2023-08-13 22:25:01 +08:00
import os
from configs import VERSION
from server.utils import api_address
2023-08-01 14:18:30 +08:00
api = ApiRequest(base_url=api_address())
2023-07-28 06:58:34 +08:00
if __name__ == "__main__":
st.set_page_config(
"Langchain-Chatchat WebUI",
os.path.join("img", "chatchat_icon_blue_square_v2.png"),
initial_sidebar_state="expanded",
menu_items={
'Get Help': 'https://github.com/chatchat-space/Langchain-Chatchat',
'Report a bug': "https://github.com/chatchat-space/Langchain-Chatchat/issues",
2023-11-13 09:20:19 +08:00
'About': f"""欢迎使用 思极大模型 WebUI {VERSION}"""
}
)
2023-07-28 06:58:34 +08:00
2023-08-13 17:53:59 +08:00
pages = {
"对话": {
"icon": "chat",
2023-08-12 14:08:21 +08:00
"func": dialogue_page,
},
"知识库管理": {
"icon": "hdd-stack",
"func": knowledge_base_page,
},
2023-08-12 02:30:50 +08:00
}
2023-07-28 06:58:34 +08:00
with st.sidebar:
2023-08-13 22:25:01 +08:00
st.image(
os.path.join(
"img",
2023-11-13 09:20:19 +08:00
"siji.jpg"
#"logo-long-chatchat-trans-v2.png"
2023-08-13 22:25:01 +08:00
),
use_column_width=True
)
st.caption(
f"""<p align="right">当前版本:{VERSION}</p>""",
unsafe_allow_html=True,
)
2023-08-13 17:53:59 +08:00
options = list(pages)
icons = [x["icon"] for x in pages.values()]
2023-08-13 17:53:59 +08:00
default_index = 0
2023-08-12 15:02:14 +08:00
selected_page = option_menu(
2023-08-13 22:25:01 +08:00
"",
options=options,
icons=icons,
2023-08-13 22:25:01 +08:00
# menu_icon="chat-quote",
default_index=default_index,
2023-08-12 15:02:14 +08:00
)
if selected_page in pages:
pages[selected_page]["func"](api)