FastChat:开源 LLM 对话机器人平台 2026 版

FastChat 是 OpenAssistant、Vicuna 的开源平台。支持多模型管理、API 服务、Web UI。FastChat 让 LLM 可商用化。

  • ⭐ 32000
  • Python
  • FastAPI
  • Gradio
  • Apache 2.0
  • 更新于 2026-05-18

什么是 FastChat? #

FastChat 是 OpenAssistant、Vicuna 的开源平台。支持多模型管理、API 服务、Web UI。让 LLM 可商用化。

安装 #

pip install fschat

启动服务 #

控制器 #

python -m fastchat.serve.controller

模型工作者 #

python -m fastchat.serve.model_worker \
    --model-path /models/vicuna-7b \
    --controller http://localhost:21001

API 服务器 #

python -m fastchat.serve.openai_api_server \
    --controller http://localhost:21001 \
    --model-list vicuna-7b,gpt-4

Web UI #

启动 Gradio 界面 #

python -m fastchat.serve.gradio_web_server

访问 http://localhost:7860 使用 Web UI。

界面功能 #

  • 模型选择
  • 对话历史
  • 参数调节(temperature、top_p)
  • 输出复制

API 接口 #

OpenAI 格式兼容 #

import openai

openai.api_base = "http://localhost:8000/v1"

response = openai.ChatCompletion.create(
    model="vicuna-7b",
    messages=[{"role": "user", "content": "你好"}]
)

命令行调用 #

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "vicuna-7b", "messages": [{"role": "user", "content": "解释一下机器学习"}]}'

多模型管理 #

注册模型 #

python -m fastchat.serve.model_worker \
    --model-path /models/vicuna-13b \
    --model-names vicuna-13b,vicuna-13b-chat

负载均衡 #

FastChat 自动做模型工作者负载均衡。

性能优化 #

vLLM 集成 #

# 使用 vLLM 高效推理
python -m fastchat.serve.model_worker \
    --model-path /models/vicuna-7b \
    --load-momentum vllm

分布式推理 #

# 多卡推理
export CUDA_VISIBLE_DEVICES=0,1,2,3
python -m fastchat.serve.model_worker --num-gpus 4

部署配置 #

Docker 镜像 #

FROM lmstudio/fastchat:latest
COPY models/ /models/
CMD ["python", "-m", "fastchat.serve.controller"]

Kubernetes #

apiVersion: apps/v1
kind: Deployment
metadata:
  name: fastchat-worker
spec:
  replicas: 3
  template:
    spec:
      containers:
      - name: worker
        image: lmstudio/fastchat
        args: ["python", "-m", "fastchat.serve.model_worker"]

常用模型 #

模型参数用途
Vicuna7B/13B对话
LongWolf7B长文本
ChatGLM6B/13B中文对话
Chinese-CLIP多模态图文检索

常见问题 #

Q: FastChat 支持多语言吗?

答:支持。模型决定语言能力。

Q: 如何添加新模型?

答:下载模型权重放到指定目录,注册即可。

Q: 支持流式响应吗?

答:支持。服务端发送 Server-Sent Events。

总结 #

FastChat 把开源 LLM 变成「生产级对话平台」。从模型部署到 Web UI,全套方案。


参考:lm-sys.org 官网 更新:2026-05-18

💬 留言讨论