langgraph-python-quickstart

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LangGraph Python quickstart

LangGraph Python快速入门

Follow the live docs — do not invent an alternate API from memory:
Fetch that page (Docs MCP or HTTP) and implement what it shows (calculator / math agent with the Graph API). Prefer the Graph API path over the Functional API unless the user asks otherwise. Skip IPython graph visualization.
请遵循在线文档——不要凭记忆自行编写替代API:
获取该页面内容(通过Docs MCP或HTTP)并实现其中展示的功能(使用Graph API构建计算器/数学Agent)。除非用户另有要求,否则优先使用Graph API而非Functional API。跳过IPython图表可视化步骤。

Local setup constraints

本地设置约束

Apply these on top of the quickstart (they keep setup minimal and model-agnostic):
  1. Ask which provider/model to use. Showcase that LangGraph works with any LangChain chat model. Suggested prompt:
    Which model should this agent use? Pass a
    provider:model
    string — e.g.
    openai:gpt-5.5
    ,
    anthropic:claude-sonnet-5
    ,
    google_genai:gemini-2.5-flash-lite
    . Default if you're unsure:
    anthropic:claude-sonnet-5
    .
    The docs often hardcode Anthropic — replace with
    init_chat_model("<MODEL>")
    (or equivalent) using their choice. If using Claude Sonnet 5+, omit
    temperature
    /
    top_p
    /
    top_k
    (unsupported).
  2. Create a new directory (e.g.
    langgraph-agent/
    ) and do all work there — do not pollute the open project.
  3. Only secret: the provider API key in
    .env
    (gitignored). No LangSmith / Tavily unless they ask. Prefer they edit
    .env
    themselves — don't paste keys into chat.
  4. Install packages from the quickstart plus the provider package for their model.
  5. Run the example (e.g. “Add 3 and 4.”), show output, then stop. Point to
    langgraph-fundamentals
    for next steps. For a higher-level agent API, use LangChain
    create_agent
    instead.
在快速入门基础上应用以下规则(这些规则可确保设置极简且与模型无关):
  1. 询问要使用的提供商/模型。展示LangGraph可与任意LangChain聊天模型配合使用。建议提示语:
    该Agent应使用哪个模型?请传入
    provider:model
    格式的字符串——例如
    openai:gpt-5.5
    anthropic:claude-sonnet-5
    google_genai:gemini-2.5-flash-lite
    。如果不确定,默认使用:
    anthropic:claude-sonnet-5
    文档中通常硬编码使用Anthropic——请替换为用户选择的
    init_chat_model("<MODEL>")
    (或等效代码)。如果使用Claude Sonnet 5+,请省略
    temperature
    /
    top_p
    /
    top_k
    参数(该模型不支持这些参数)。
  2. 创建一个目录(例如
    langgraph-agent/
    )并在该目录中完成所有操作——不要污染现有项目。
  3. 仅需保密的内容:
    .env
    文件中的提供商API密钥(已添加到git忽略列表)。除非用户要求,否则不使用LangSmith / Tavily。优先让用户自行编辑
    .env
    文件——不要将密钥粘贴到聊天框中。
  4. 安装快速入门指南中提到的包,加上对应模型提供商的包。
  5. 运行示例(例如“计算3加4”),展示输出结果后停止。后续步骤可参考
    langgraph-fundamentals
    。如果需要更高级的Agent API,请使用LangChain
    create_agent
    。",