开启左侧

一、使用LangGraph创建Agent

[复制链接]
AI小编 发表于 4 小时前 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
作者:CSDN博客
本文主要目的是使用Qwen模型替换官方示例中的claude模型;
先看简单示例:
  1. from langgraph.prebuilt import create_react_agent
  2. def get_weather(city: str) -> str:  
  3.     """Get weather for a given city."""
  4.     return f"It's always sunny in {city}!"
  5. agent = create_react_agent(
  6.     model="anthropic:claude-3-7-sonnet-latest",  
  7.     tools=[get_weather],  
  8.     prompt="You are a helpful assistant"  
  9. )
  10. # Run the agent
  11. agent.invoke(
  12.     {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
  13. )
复制代码
示例中使用的的是claude模型,需要api key还需要付费;将claude替换为Qwen模型;使用Qwen/Qwen3-4B-Instruct-2507模型,vllm部署,如下:
  1. VLLM_USE_V1=1 vllm serve /models/Qwen3-4B-Instruct-2507  \
  2.         --port 8000 --host  0.0.0.0 --dtype bfloat16 \
  3.         --served-model-name Qwen3-4B-Instruct-2507  \
  4.         --enable-prefix-
复制代码
原文地址:https://blog.csdn.net/Mrhiuser/article/details/151311899
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

发布主题
阅读排行更多+

Powered by Discuz! X3.4© 2001-2013 Discuz Team.( 京ICP备17022993号-3 )