跳到内容

Streamlit

Streamlit 让您可以在几分钟内(而非几周内)将 Python 脚本转换为交互式 Web 应用程序。无论是构建仪表板、生成报告,还是创建聊天应用,它都能轻松胜任。

它可以快速与作为后端 API 服务器的 vLLM 集成,从而通过 API 调用实现强大的 LLM 推理功能。

先决条件

通过安装所有必需的包来设置 vLLM 环境

pip install vllm streamlit openai

部署

  1. 使用受支持的聊天补全模型启动 vLLM 服务器,例如

    vllm serve Qwen/Qwen1.5-0.5B-Chat
    
  2. 使用该脚本: examples/online_serving/streamlit_openai_chatbot_webserver.py

  3. 启动 Streamlit Web 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
    

    Chat with vLLM assistant in Streamlit