LangGraph get started

pip install -U langgraph
pip install -qU "langchain[anthropic]" to call the model

anthropic 是指 LangChain 库中支持与 Anthropic 公司的大语言模型(如 Claude 系列)集成的功能模块。代表安装 LangChain 时,额外包含与 Anthropic 模型接口的相关依赖包和集成代码。这样安装后,你可以用 LangChain 调用 Anthropic 提供的大语言模型,通过配置 ANTHROPIC_API_KEY 来访问和使用这些模型。

前提需要 An Anthropic API key,但在我的地理位置 not available 。

这个是个 ReAct,并且 LLM 与 tools 没有 bind

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"}]}
)

health agent example

https://github.com/jayrodge/ai-agents/blob/main/smart_health_agent/README.md