langgraph-python-quickstart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLangGraph 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):
-
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+, omitinit_chat_model("<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.create_agent
在快速入门基础上应用以下规则(这些规则可确保设置极简且与模型无关):
-
询问要使用的提供商/模型。展示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+,请省略init_chat_model("<MODEL>")/temperature/top_p参数(该模型不支持这些参数)。top_k -
创建一个新目录(例如)并在该目录中完成所有操作——不要污染现有项目。
langgraph-agent/ -
仅需保密的内容:文件中的提供商API密钥(已添加到git忽略列表)。除非用户要求,否则不使用LangSmith / Tavily。优先让用户自行编辑
.env文件——不要将密钥粘贴到聊天框中。.env -
安装快速入门指南中提到的包,加上对应模型提供商的包。
-
运行示例(例如“计算3加4”),展示输出结果后停止。后续步骤可参考。如果需要更高级的Agent API,请使用LangChain
langgraph-fundamentals。",create_agent