> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain 概述

> LangChain 是一个开源框架，提供预构建的智能体架构和适用于任何模型或工具的集成方案——让你能够构建出随生态系统快速演进而适应的智能体

LangChain 是开始构建完全由大语言模型驱动的自定义智能体和应用的便捷方式。
只需不到 10 行代码，你就能连接到 OpenAI、Anthropic、Google 以及[更多](/oss/python/integrations/providers/overview)服务。
LangChain 提供了预构建的智能体架构和模型集成，帮助你快速上手，并将大语言模型无缝融入你的智能体和应用中。

<Tip>
  **LangChain vs. LangGraph vs. Deep Agents**

  如果你想构建一个智能体，我们建议从 [Deep Agents](/oss/python/deepagents/overview/) 开始，它“开箱即用”，具备现代特性，如自动压缩长对话、虚拟文件系统以及用于管理和隔离上下文的子智能体生成。

  Deep Agents 是 LangChain [智能体](/oss/python/langchain/agents) 的实现。如果你不需要这些功能，或者希望为你的智能体和自主应用定制自己的方案，可以从 LangChain 开始。

  当你需要更高级的功能，要求结合确定性和智能体工作流并进行深度定制时，请使用 [LangGraph](/oss/python/langgraph/overview)，这是我们底层的智能体编排框架和运行时。
</Tip>

LangChain [智能体](/oss/python/langchain/agents) 构建在 LangGraph 之上，以提供持久化执行、流式处理、人在回路、持久化存储等功能。对于基本的 LangChain 智能体使用，你无需了解 LangGraph。

如果你希望快速构建智能体和自主应用，我们推荐你使用 LangChain。

## <Icon icon="wand" /> 创建一个智能体

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
# pip install -qU langchain "langchain[anthropic]"
from langchain.agents import create_agent

def get_weather(city: str) -> str:
    """获取指定城市的天气。"""
    return f"It's always sunny in {city}!"

agent = create_agent(
    model="anthropic:claude-sonnet-4-6",
    tools=[get_weather],
    system_prompt="你是一个乐于助人的助手",
)

# 运行智能体
agent.invoke(
    {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
)
```

请参阅 [安装说明](/oss/python/langchain/install) 和 [快速入门指南](/oss/python/langchain/quickstart)，开始使用 LangChain 构建你自己的智能体和应用。

<Tip>
  使用 [LangSmith](/langsmith/home) 来追踪请求、调试智能体行为并评估输出。设置 `LANGSMITH_TRACING=true` 和你的 API 密钥即可开始。
</Tip>

## <Icon icon="star" size={20} /> 核心优势

<Columns cols={2}>
  <Card title="标准模型接口" icon="refresh" href="/oss/python/langchain/models" arrow cta="了解更多">
    不同服务提供商有各自独特的模型交互 API，包括响应格式。LangChain 标准化了你与模型的交互方式，让你可以无缝切换提供商并避免被锁定。
  </Card>

  <Card title="易于使用、高度灵活的智能体" icon="wand" href="/oss/python/langchain/agents" arrow cta="了解更多">
    LangChain 的智能体抽象设计旨在易于上手，让你能用不到 10 行代码构建一个简单的智能体。但它也提供了足够的灵活性，让你可以进行所有你想要的上下文工程。
  </Card>

  <Card title="构建于 LangGraph 之上" icon="https://mintcdn.com/hhh-8c10bf0c/1xJTbE4Z922F2hsr/images/brand/langgraph-icon.png?fit=max&auto=format&n=1xJTbE4Z922F2hsr&q=85&s=c4cb3e2d7930270b4dfddbb9b0ae2d55" href="/oss/python/langgraph/overview" arrow cta="了解更多" width="195" height="195" data-path="images/brand/langgraph-icon.png">
    LangChain 的智能体构建于 LangGraph 之上。这让我们能够利用 LangGraph 的持久化执行、人在回路支持、持久化存储等功能。
  </Card>

  <Card title="使用 LangSmith 进行调试" icon="https://mintcdn.com/hhh-8c10bf0c/1xJTbE4Z922F2hsr/images/brand/observability-icon-dark.png?fit=max&auto=format&n=1xJTbE4Z922F2hsr&q=85&s=dd27ed0590c5da94bfd12b5919de3a91" href="/langsmith/observability" arrow cta="了解更多" width="200" height="200" data-path="images/brand/observability-icon-dark.png">
    通过可视化工具深入洞察复杂的智能体行为，这些工具可以追踪执行路径、捕获状态转换并提供详细的运行时指标。
  </Card>
</Columns>

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\langchain\overview.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
