1 Star 0 Fork 3

qiuweifan/Langchain-Chatchat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webui.py 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
# 运行方式:
# 1. 安装必要的包:pip install streamlit-option-menu streamlit-chatbox>=1.1.6
# 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
import streamlit as st
from webui_pages.utils import *
from streamlit_option_menu import option_menu
from webui_pages import *
import os
from configs import VERSION
api = ApiRequest(base_url="http://127.0.0.1:7861", no_remote_api=False)
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",
'About': f"""欢迎使用 Langchain-Chatchat WebUI {VERSION}!"""
}
)
if not chat_box.chat_inited:
st.toast(
f"欢迎使用 [`Langchain-Chatchat`](https://github.com/chatchat-space/Langchain-Chatchat) ! \n\n"
f"当前使用模型`{LLM_MODEL}`, 您可以开始提问了."
)
pages = {
"对话": {
"icon": "chat",
"func": dialogue_page,
},
"知识库管理": {
"icon": "hdd-stack",
"func": knowledge_base_page,
},
}
with st.sidebar:
st.image(
os.path.join(
"img",
"logo-long-chatchat-trans-v2.png"
),
use_column_width=True
)
st.caption(
f"""<p align="right">当前版本:{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,
# menu_icon="chat-quote",
default_index=default_index,
)
if selected_page in pages:
pages[selected_page]["func"](api)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qiuweifan/Langchain-Chatchat.git
git@gitee.com:qiuweifan/Langchain-Chatchat.git
qiuweifan
Langchain-Chatchat
Langchain-Chatchat
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385