langgraph-typescript-quickstart

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LangGraph TypeScript quickstart

LangGraph TypeScript快速入门

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 graph visualization.
遵循在线文档——不要凭记忆自创替代API:
获取该页面内容(通过Docs MCP或HTTP)并实现其中展示的功能(使用Graph API的计算器/数学Agent)。除非用户要求,否则优先选择Graph API而非Functional API。跳过图形可视化步骤。

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
    initChatModel("<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
    createAgent
    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——请使用用户选择的模型替换为
    initChatModel("<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的
    createAgent