langchain-typescript-quickstart

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LangChain TypeScript quickstart

LangChain 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 (weather agent +
createAgent
). Requires Node 22+.
请参照实时文档操作——不要凭记忆使用替代API:
获取该页面内容(Docs MCP或HTTP方式)并实现其中展示的功能(天气Agent +
createAgent
)。要求Node 22及以上版本。

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 LangChain is model-agnostic. 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
    .
    Swap the quickstart's model string for their choice (or the default).
  2. Create a new directory (e.g.
    langchain-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 the provider package needed for their model if the quickstart's base install isn't enough.
  5. Run the example, show output, then stop. Point to
    langchain-fundamentals
    for next steps.
在快速入门的基础上遵循以下规则(这些规则确保设置极简且与模型无关):
  1. 询问要使用的提供商/模型。体现LangChain的模型无关性。建议提示语:
    该Agent应使用哪个模型?请传入
    provider:model
    格式的字符串——例如
    openai:gpt-5.5
    anthropic:claude-sonnet-5
    google-genai:gemini-2.5-flash-lite
    。若不确定,默认选择:
    anthropic:claude-sonnet-5
    将快速入门中的模型字符串替换为用户选择的(或默认的)模型。
  2. 创建一个目录(例如
    langchain-agent/
    )并在其中完成所有操作——不要污染现有项目。
  3. 仅需配置的密钥:
    .env
    文件中的提供商API密钥(已加入git忽略)。除非用户要求,否则无需配置LangSmith / Tavily。建议用户自行编辑
    .env
    文件——不要在聊天中粘贴密钥。
  4. 如果快速入门的基础安装不足以支持所选模型,安装对应提供商的包。
  5. 运行示例,展示输出,然后停止。如需下一步操作,请参考
    langchain-fundamentals