AI创想
标题:
一、使用LangGraph创建Agent
[打印本页]
作者:
AI小编
时间:
6 小时前
标题:
一、使用LangGraph创建Agent
作者:CSDN博客
本文主要目的是使用Qwen模型替换官方示例中的claude模型;
先看简单示例:
from langgraph.prebuilt import create_react_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}!"
agent = create_react_agent(
model="anthropic:claude-3-7-sonnet-latest",
tools=[get_weather],
prompt="You are a helpful assistant"
)
# Run the agent
agent.invoke(
{"messages": [{"role": "user", "content": "what is the weather in sf"}]}
)
复制代码
示例中使用的的是claude模型,需要api key还需要付费;将claude替换为Qwen模型;使用Qwen/Qwen3-4B-Instruct-2507模型,vllm部署,如下:
VLLM_USE_V1=1 vllm serve /models/Qwen3-4B-Instruct-2507 \
--port 8000 --host 0.0.0.0 --dtype bfloat16 \
--served-model-name Qwen3-4B-Instruct-2507 \
--enable-prefix-
复制代码
原文地址:https://blog.csdn.net/Mrhiuser/article/details/151311899
欢迎光临 AI创想 (https://www.llms-ai.com/)
Powered by Discuz! X3.4