mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 13:23:16 +08:00
* update ApiRequest: 删除no_remote_api本地调用模式;支持同步/异步调用 * 实现API和WEBUI的分离: - API运行服务器上的配置通过/llm_model/get_model_config、/server/configs接口提供,WEBUI运行机器上的配置项仅作为代码内部默认值使用 - 服务器可用的搜索引擎通过/server/list_search_engines提供 - WEBUI可选LLM列表中只列出在FSCHAT_MODEL_WORKERS中配置的模型 - 修改WEBUI中默认LLM_MODEL获取方式,改为从api端读取 - 删除knowledge_base_chat中`local_doc_url`参数 其它修改: - 删除多余的kb_config.py.exmaple(名称错误) - server_config中默认关闭vllm - server_config中默认注释除智谱AI之外的在线模型 - 修改requests从系统获取的代理,避免model worker注册错误 * 修正: - api.list_config_models返回模型原始配置 - api.list_config_models和api.get_model_config中过滤online api模型的敏感信息 - 将GPT等直接访问的模型列入WEBUI可选模型列表 其它: - 指定langchain==0.3.313, fschat==0.2.30, langchain-experimental==0.0.30
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
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
|
||
from server.utils import api_address
|
||
|
||
|
||
api = ApiRequest(base_url=api_address())
|
||
|
||
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:
|
||
running_models = api.list_running_models()
|
||
st.toast(
|
||
f"欢迎使用 [`Langchain-Chatchat`](https://github.com/chatchat-space/Langchain-Chatchat) ! \n\n"
|
||
f"当前运行中的模型`{running_models}`, 您可以开始提问了."
|
||
)
|
||
|
||
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)
|