当前位置: 首页 > 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.dtcms.com/a/314526.html

相关文章:

  • vue3 elementPlus el-dialog添加拖拽
  • Python实现Word转PDF全攻略:从入门到实战
  • 【人工智能99问】什么是Post-Training,包含哪些内容?(19/99)
  • 机器学习(12):拉索回归Lasso
  • 墨者学院SQL过滤字符后手工绕过漏洞测试(万能口令)
  • 【2025/08/04】GitHub 今日热门项目
  • vue3+vue-flow制作简单可拖拽可增删改流程图
  • 基于Matlab图像处理的液晶显示器表面缺陷检测与分类研究
  • 使用 SecureCRT 连接华为 eNSP 模拟器的方法
  • 【测试】⽤例篇
  • Android Telephony 框架与横向支撑层
  • SpringBoot+SpringMVC常用注解
  • 多线程(线程的创建与常见方法的使用)
  • sqli-labs靶场less29~less35
  • milvus client操作简单示例
  • 数据与模型优化随机森林回归进行天气预测
  • PyTorch深度学习实战(48)——基于Transformer实现机器翻译
  • 1.kotlin数组、集合常用方法
  • Day31:文件的规范拆分与写法
  • 三维模型轻量化双杀技:GISBox的纹理压缩与顶点压缩联合
  • 交叉验证:原理、作用与在机器学习流程中的位置
  • 【笔记】ROS1|1 ROS基本命令介绍及创建工作空间与功能包【旧文转载】
  • 从知识管理到智能协作:Gitee Wiki如何重塑软件研发效率范式
  • AI聊天:虚拟主播的角色提示词
  • HTTPS有哪些优点
  • LLM嵌入特征工程
  • Coze Studio 概览(七)--记忆管理功能
  • 单调栈|图
  • 电脑上不了网怎么办?【图文详解】wifi有网络但是电脑连不上网?网络设置
  • 【C++】——类和对象(下)