update webui.py and README.md

This commit is contained in:
imClumsyPanda 2023-08-12 15:02:14 +08:00
parent 2ad33e010d
commit f4a42b8ccb
2 changed files with 28 additions and 12 deletions

View File

@ -52,8 +52,8 @@
1. 使用 [FastChat](https://github.com/lm-sys/FastChat) 提供开源 LLM 模型的 API以 OpenAI API 接口形式接入,提升 LLM 模型加载效果;
2. 使用 [langchain](https://github.com/langchain-ai/langchain) 中已有 Chain 的实现,便于后续接入不同类型 Chain并将对 Agent 接入开展测试;
3. 使用 [FastAPI](https://github.com/tiangolo/fastapi) 提供 API 服务,全部接口可在 FastAPI 自动生成的 docs 中开展测试,且所有对话接口支持通过参数设置流式或非流式输出;
4. 使用 [Streamlit](https://github.com/streamlit/streamlit) 提供 WebUI 服务,可选是否基于 API 服务启动 WebUI且后续可支持不同形式输出内容的显示
5. 除 [FAISS](https://github.com/facebookresearch/faiss) 向量库外,还提供 [Milvus](https://github.com/milvus-io/milvus), [PGVector](https://github.com/pgvector/pgvector) 向量库的接入;
4. 使用 [Streamlit](https://github.com/streamlit/streamlit) 提供 WebUI 服务,可选是否基于 API 服务启动 WebUI增加会话管理,可以自定义会话主题并切换,且后续可支持不同形式输出内容的显示;
5. 除支持 [FAISS](https://github.com/facebookresearch/faiss) 向量库外,还提供 [Milvus](https://github.com/milvus-io/milvus), [PGVector](https://github.com/pgvector/pgvector) 向量库的接入;
6. 项目中默认 LLM 模型改为 [THUDM/chatglm2-6b](https://huggingface.co/THUDM/chatglm2-6b),默认 Embedding 模型改为 [moka-ai/m3e-base](https://huggingface.co/moka-ai/m3e-base),文件加载方式与文段划分方式也有调整,后续将重新实现上下文扩充,并增加可选设置。
## 模型支持
@ -247,14 +247,22 @@ $python server/llm_api_shutdown.py --serve all
$ python server/api.py
```
启动 API 服务后,可访问 `localhost:7861``{API 所在服务器 IP}:7861` FastAPI 自动生成的 docs 进行接口查看与测试。
#### 4.3 启动 Web UI 服务
执行 [webui.py](webui.py) 启动 **Web UI** 服务
执行 [webui.py](webui.py) 启动 **Web UI** 服务(默认使用端口`8501`
```shell
$ python webui.py
```
或使用以下命令指定启动 **Web UI** 服务并指定端口号
```shell
$ python webui.py --server.port 666
```
### 常见问题
参见 [常见问题](docs/FAQ.md)。

View File

@ -48,12 +48,20 @@ if __name__ == "__main__":
}
pages.update(pages2)
def on_change(key):
selection = st.session_state[key]
st.write(f"Selection changed to {selection}")
with st.sidebar:
selected_page = option_menu("langchain-chatglm",
selected_page = option_menu(
"langchain-chatglm",
options=list(pages.keys()),
icons=[i["icon"] for i in pages.values()],
menu_icon="chat-quote",
default_index=list(pages.keys()).index(st.session_state["cur_chat_name"]))
default_index=list(pages.keys()).index(st.session_state["cur_chat_name"]),
)
if selected_page == "新建对话":
new_chat_name = f"对话{len(st.session_state.chat_list) + 1}"
st.session_state.chat_list[new_chat_name] = {"need_rename": True}