函数调用
上游 README 明确提到本地 API 支持 function calling,但暂时要求 `stream=False`。
社区文档站,基于公开的 Qwen 上游材料整理,不应默认视为官方上游主页。
API
上游文档同时覆盖了通过 `openai_api.py` 暴露的本地类 OpenAI API,以及不自建服务时可选的 DashScope。
本地 API 示例依赖 FastAPI、Uvicorn、`openai<1.0`、Pydantic 和 `sse_starlette`,然后运行 `openai_api.py`。
如果你不想维护本地推理服务,README 还单独给出了 DashScope 的托管 API 入口。
import openai
openai.api_base = "http://localhost:8000/v1"
openai.api_key = "none"
response = openai.ChatCompletion.create(
model="Qwen",
messages=[{"role": "user", "content": "你好"}],
stream=False,
stop=[]
)
print(response.choices[0].message.content)
上游 README 明确提到本地 API 支持 function calling,但暂时要求 `stream=False`。
当你需要托管服务而非本地兼容层时,直接使用 DashScope。
查看链接在 vLLM 路径中,FastChat 也能提供类 OpenAI 的 API Server。
来源锚点