2023-08-03 13:41:31 +08:00
|
|
|
|
# 运行方式:
|
|
|
|
|
|
# 1. 安装必要的包:pip install streamlit-option-menu streamlit-chatbox>=1.1.3
|
|
|
|
|
|
# 2. 运行本机fastchat服务:python server\llm_api.py 或者 运行对应的sh文件
|
|
|
|
|
|
# 3. 运行API服务器:python server/api.py。如果使用api = ApiRequest(no_remote_api=True),该步可以跳过。
|
|
|
|
|
|
# 4. 运行WEB UI:streamlit run webui.py --server.port 7860
|
|
|
|
|
|
|
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-01 14:18:30 +08:00
|
|
|
|
|
|
|
|
|
|
api = ApiRequest()
|
2023-05-18 22:54:41 +08:00
|
|
|
|
|
2023-07-28 06:58:34 +08:00
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
st.set_page_config("langchain-chatglm WebUI")
|
|
|
|
|
|
|
|
|
|
|
|
pages = {"对话": {"icon": "chat",
|
|
|
|
|
|
"func": dialogue_page,
|
|
|
|
|
|
},
|
|
|
|
|
|
"知识库管理": {"icon": "database-fill-gear",
|
2023-08-01 14:47:38 +08:00
|
|
|
|
"func": knowledge_base_page,
|
2023-07-28 06:58:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
"模型配置": {"icon": "gear",
|
2023-08-01 14:47:38 +08:00
|
|
|
|
"func": model_config_page,
|
2023-07-28 06:58:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
with st.sidebar:
|
|
|
|
|
|
selected_page = option_menu("langchain-chatglm",
|
|
|
|
|
|
options=list(pages.keys()),
|
|
|
|
|
|
icons=[i["icon"] for i in pages.values()],
|
|
|
|
|
|
menu_icon="chat-quote",
|
|
|
|
|
|
default_index=0)
|
|
|
|
|
|
|
2023-08-01 15:08:19 +08:00
|
|
|
|
pages[selected_page]["func"](api)
|