liunux4odoo 9fddd07afd
- 新功能 (#3944)
- streamlit 更新到 1.34,webui 支持 Dialog 操作
    - streamlit-chatbox 更新到 1.1.12,更好的多会话支持
- 开发者
    - 在 API 中增加项目图片路由(/img/{file_name}),方便前端使用
2024-05-06 09:09:56 +08:00

72 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
import streamlit as st
import streamlit_antd_components as sac
from chatchat.configs import VERSION
from chatchat.server.utils import api_address
from chatchat.webui_pages.utils import *
from chatchat.webui_pages.dialogue.dialogue import dialogue_page, chat_box
from chatchat.webui_pages.knowledge_base.knowledge_base import knowledge_base_page
api = ApiRequest(base_url=api_address())
if __name__ == "__main__":
is_lite = "lite" in sys.argv # TODO: remove lite mode
st.set_page_config(
"Langchain-Chatchat WebUI",
get_img_url("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",
'About': f"""欢迎使用 Langchain-Chatchat WebUI {VERSION}"""
},
layout="wide"
)
# use the following code to set the app to wide mode and the html markdown to increase the sidebar width
st.markdown(
"""
<style>
[data-testid="stSidebarUserContent"] {
padding-top: 20px;
}
.block-container {
padding-top: 25px;
}
[data-testid="stBottomBlockContainer"] {
padding-bottom: 20px;
}
""",
unsafe_allow_html=True,
)
with st.sidebar:
st.image(
get_img_url('logo-long-chatchat-trans-v2.png'),
use_column_width=True
)
st.caption(
f"""<p align="right">当前版本:{VERSION}</p>""",
unsafe_allow_html=True,
)
selected_page = sac.menu(
[
sac.MenuItem("对话", icon="chat"),
sac.MenuItem("知识库管理", icon="hdd-stack"),
],
key="selected_page",
open_index=0
)
sac.divider()
if selected_page == "知识库管理":
knowledge_base_page(api=api, is_lite=is_lite)
else:
dialogue_page(api=api, is_lite=is_lite)