当前位置: 首页 > news >正文

vllm启动Qwen/Qwen3-Coder-30B-A3B-Instruct并支持工具调用

阿里云千问团队在2025年8月1号推出了Qwen3-Coder系列的一个比较小参数版本Qwen/Qwen3-Coder-30B-A3B-Instruct 具有较强的性能并且对显存要求没那么高。那么我们应该如何在本地启动并使用这个模型开发Agent呢?

众所周知,Agent相比于LLM的最大的区别就是Agent可以使用各种各样的工具,所以我们想使用Qwen3-Coder-30B-A3B-Instruct开发Agent的前提就是让它支持工具调用。

硬件参数

显卡:H20(96G VRAM)

模型下载

安装modelscope

pip install modelscope

下载模型

modelscope download --model Qwen/Qwen3-Coder-30B-A3B-Instruct

注:模型文件大小在39GB左右,请提供足够的磁盘空间

VLLM模型服务

安装vllm>=0.10.0

推荐使用uv安装

pip install uv
uv venv
source .venv/bin/activate
uv pip install -U vllm --torch-backend auto

VLLM服务配置

model: Qwen/Qwen3-Coder-30B-A3B-Instruct
served_model_name: qwen3-coder
host: 0.0.0.0
port: 8000
tensor-parallel-size: 1
gpu-memory-utilization: 0.9
api-key: your-api-key
disable-fastapi-docs: true
enable-auto-tool-choice: true
tool-call-parser: qwen3_coder
max-model-len: 32768

将这份配置保存为qwen3-coder.yml

启动VLLM模型服务

vllm serve --config vllm-coder.yml

观察日志输出,如果出现和上图一样的日志就代表模型服务启动成功了

工具调用测试

工具调用测试我准备使用openai-agents[litellm]测试

安装openai-agents-python

uv pip install "openai-agents[litellm]"

测试代码

import asyncio
from agents.extensions.models.litellm_model import LitellmModel
from agents import Agent, function_tool, Runnerqwen3_coder = LitellmModel(base_url="http://localhost:8000/v1",  # vllm 服务地址api_key="your-api-key",  # 注意这里只是方便演示,不推荐将api-key直接写到代码中,应该使用环境变量的方式os.getenv("API_KEY")model="openai/qwen3-coder",
)@function_tool
def get_user_info(user_id: str):"""get user info toolArgs:user_id: strreturn user info in dict"""return {"name": "Jack", "age": 18, "id": user_id}agent = Agent(name="Your Agent",instructions="使用工具完成用户任务",model=qwen3_coder,tools=[get_user_info],
)async def main():result = await Runner.run(agent, input="我的用户ID是1234,我是谁?")print(result.final_output)if __name__ == "__main__":asyncio.run(main())

将代码保存成agent.py文件

运行代码

uv run python agent.py

测试结果

从图中可以看出模型已经成功调用get_user_info工具获取到用户信息。

http://www.xdnf.cn/news/1242613.html

相关文章:

  • MLIR Introduction
  • android内存作假通杀补丁(4GB作假8GB)
  • History 模式 vs Hash 模式:Vue Router 技术决策因素详解
  • ZYNQ-按键消抖
  • JavaScript 中的流程控制语句详解
  • 3.JVM,JRE和JDK的关系是什么
  • 第二十四天(数据结构:栈和队列)队列实践请看下一篇
  • SQL注入SQLi-LABS 靶场less39-50详细通关攻略
  • 基于实时音视频技术的远程控制传输SDK的功能设计
  • 【ECCV2024】AdaCLIP:基于混合可学习提示适配 CLIP 的零样本异常检测
  • [GESP202306 四级] 2023年6月GESP C++四级上机题超详细题解,附带讲解视频!
  • 刷题记录0804
  • ref和reactive的区别
  • 8位以及32位的MCU如何进行选择?
  • ArrayDeque双端队列--底层原理可视化
  • Redis 常用数据结构以及单线程模型
  • LeetCode 140:单词拆分 II
  • Array容器学习
  • app-1
  • 优选算法 力扣 11. 盛最多水的容器 双指针降低时间复杂度 贪心策略 C++题解 每日一题
  • Javascript面试题及详细答案150道之(031-045)
  • python包管理器uv踩坑
  • 力扣面试150题--加一
  • PCL统计点云Volume
  • ArcGIS的字段计算器生成随机数
  • 配置Mybatis环境
  • 【多智能体cooragent】CoorAgent 系统中 5 个核心系统组件分析
  • 一起学springAI系列一:流式返回
  • 【实战】Dify从0到100进阶--中药科普助手(1)
  • 嵌入式硬件中三极管原理分析与控制详解