langgraph-typescript-quickstart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLangGraph 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):
-
Ask which provider/model to use. Showcase that LangGraph works with any LangChain chat model. Suggested prompt:Which model should this agent use? Pass astring — e.g.
provider:model,openai:gpt-5.5,anthropic:claude-sonnet-5. Default if you're unsure:google-genai:gemini-2.5-flash-lite.anthropic:claude-sonnet-5The docs often hardcode Anthropic — replace with(or equivalent) using their choice. If using Claude Sonnet 5+, omitinitChatModel("<MODEL>")/temperature/top_p(unsupported).top_k -
Create a new directory (e.g.) and do all work there — do not pollute the open project.
langgraph-agent/ -
Only secret: the provider API key in(gitignored). No LangSmith / Tavily unless they ask. Prefer they edit
.envthemselves — don't paste keys into chat..env -
Install packages from the quickstart plus the provider package for their model.
-
Run the example (e.g. “Add 3 and 4.”), show output, then stop. Point tofor next steps. For a higher-level agent API, use LangChain
langgraph-fundamentalsinstead.createAgent
在快速入门的基础上遵循以下规则(这些规则能让设置保持最简且与模型无关):
-
询问要使用的提供商/模型。展示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——请使用用户选择的模型替换为(或等效方法)。如果使用Claude Sonnet 5+,请省略initChatModel("<MODEL>")/temperature/top_p(这些参数不被支持)。top_k -
创建一个新目录(例如)并在其中完成所有操作——不要污染已有的开放项目。
langgraph-agent/ -
仅需设置的密钥:文件中的提供商API密钥(已添加到git忽略列表)。除非用户要求,否则不要使用LangSmith / Tavily。建议让用户自行编辑
.env文件——不要在聊天中粘贴密钥。.env -
安装快速入门中提到的包,以及所选模型对应的提供商包。
-
运行示例(例如“计算3加4的和”),展示输出结果后停止。引导用户查看了解后续步骤。如需更高级的Agent API,请改用LangChain的
langgraph-fundamentals。createAgent