用Streamlit搭建vLLM聊天前端
该文档说明如何把Streamlit与vLLM后端API服务结合,先安装vllm、streamlit和openai三个包,再启动vLLM服务并运行示例聊天脚本,从而通过网页界面调用大模型推理。
## 简化[¶](<https://docs.vllm.ai/en/latest/deployment/frameworks/streamlit/#streamlit>) [简化](<https://github.com/streamlit/streamlit>) 让您在几分钟内将 Python 脚本转换成交互式网络应用程序,而不是几周。构建仪表板、生成报告或创建聊天应用程序。 它可以快速与vLLM集成为后端API服务器,通过API调用使强大的LLM推论成为可能. ## 先决条件[¶](<https://docs.vllm.ai/en/latest/deployment/frameworks/streamlit/#prerequisites>) 通过安装所有所需的软件包来设置 vLLM 环境 : ``` pip install vllm streamlit openai ``` ## 部署[¶](<https://docs.vllm.ai/en/latest/deployment/frameworks/streamlit/#deploy>) 1. 启动 vLLM 服务器,使用一个支持的聊天完成模式,例如. ``` vllm serve Qwen/Qwen1.5-0.5B-Chat ``` 2. 使用脚本 : [examples/applications/chatbot/streamlit_openai_chatbot_webserver.py](<https://github.com/vllm-project/vllm/blob/main/examples/applications/chatbot/streamlit_openai_chatbot_webserver.py>) 3. 启动流体网络 UI 并开始聊天 : ``` streamlit run streamlit_openai_chatbot_webserver.py # or specify the VLLM_API_BASE or VLLM_API_KEY VLLM_API_BASE="http://vllm-server-host:vllm-server-port/v1" \ streamlit run streamlit_openai_chatbot_webserver.py # start with debug mode to view more details streamlit run streamlit_openai_chatbot_webserver.py --logger.level=debug ``` [ May 8, 2026 (英语).
查看原始来源