Introduction 介绍
LangChain is a framework for developing applications powered by large language models (LLMs).
LangChain 是一个用于开发由大型语言模型提供支持的应用程序的框架 (LLMs)。
LangChain simplifies every stage of the LLM application lifecycle:
LangChain 简化了LLM应用程序生命周期的每个阶段:
- Development: Build your applications using LangChain's open-source components and third-party integrations.
Use LangGraph to build stateful agents with first-class streaming and human-in-the-loop support.
开发:使用 LangChain 的开源组件和第三方集成构建应用程序。使用 LangGraph 构建具有一流流式处理和人机回圈支持的有状态代理。 - Productionization: Use LangSmith to inspect, monitor and evaluate your applications, so that you can continuously optimize and deploy with confidence.
产品化:使用 LangSmith 检查、监控和评估您的应用程序,以便您可以放心地持续优化和部署。 - Deployment: Turn your LangGraph applications into production-ready APIs and Assistants with LangGraph Platform.
部署:使用 LangGraph 平台将您的 LangGraph 应用程序转变为生产就绪的 API 和助手。
LangChain implements a standard interface for large language models and related
technologies, such as embedding models and vector stores, and integrates with
hundreds of providers. See the integrations page for
more.
LangChain 为大型语言模型和相关技术(例如嵌入模型和向量存储)实现了标准接口,并与数百个提供商集成。有关更多信息,请参阅集成页面。
选择聊天模式:
pip install -qU "langchain[google-genai]"
import getpass
import os
if not os.environ.get("GOOGLE_API_KEY"):
os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter API key for Google Gemini: ")
from langchain.chat_models import init_chat_model
model = init_chat_model("gemini-2.0-flash", model_provider="google_genai")
model.invoke("Hello, world!")
Architecture 建筑
The LangChain framework consists of multiple open-source libraries. Read more in the
Architecture page.
LangChain 框架由多个开源库组成。在
Architecture 页面。
langchain-core
: Base abstractions for chat models and other components.langchain-core
:聊天模型和其他组件的基本抽象。- Integration packages (e.g.
langchain-openai
,langchain-anthropic
, etc.): Important integrations have been split into lightweight packages that are co-maintained by the LangChain team and the integration developers.
集成包(例如langchain-openai
、langchain-anthropic
等):重要的集成已拆分为轻量级包,由 LangChain 团队和集成开发人员共同维护。 langchain
: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.langchain
:构成应用程序认知架构的链、代理和检索策略。langchain-community
: Third-party integrations that are community maintained.langchain-community
:由社区维护的第三方集成。langgraph
: Orchestration framework for combining LangChain components into production-ready applications with persistence, streaming, and other key features. See LangGraph documentation.langgraph
:编排框架,用于将 LangChain 组件组合成具有持久化、流式处理和其他关键功能的生产就绪型应用程序。请参阅 LangGraph 文档。
Guides 指南
Tutorials 教程
If you're looking to build something specific or are more of a hands-on learner, check out our tutorials section.
This is the best place to get started.
如果您想构建特定的东西或更喜欢动手实践的学习者,请查看我们的教程部分。这是最好的起点。
These are the best ones to get started with:
这些是最好的入门:
- Build a Simple LLM Application
构建一个简单的LLM应用程序 - Build a Chatbot 构建聊天机器人
- Build an Agent 构建代理
- Introduction to LangGraph
LangGraph 简介
Explore the full list of LangChain tutorials here, and check out other LangGraph tutorials here. To learn more about LangGraph, check out our first LangChain Academy course, Introduction to LangGraph, available here.
在此处探索 LangChain 教程的完整列表,并在此处查看其他 LangGraph 教程。要了解有关 LangGraph 的更多信息,请在此处查看我们的第一门 LangChain Academy 课程 LangGraph 简介。
How-to guides 作指南
Here you’ll find short answers to “How do I….?” types of questions.
These how-to guides don’t cover topics in depth – you’ll find that material in the Tutorials and the API Reference.
However, these guides will help you quickly accomplish common tasks using chat models,
vector stores, and other common LangChain components.
在这里,您将找到 “How do I....?” 类型问题的简短答案。这些作指南并不深入涵盖主题 – 您可以在 教程 和 API 参考中找到该材料。但是,这些指南将帮助您使用聊天模型快速完成常见任务。
vector 存储,以及其他常见的 LangChain 组件。
Check out LangGraph-specific how-tos here.
在此处查看特定于 LangGraph 的作方法。
Conceptual guide 概念指南
Introductions to all the key parts of LangChain you’ll need to know! Here you'll find high level explanations of all LangChain concepts.
您需要了解的 LangChain 的所有关键部分介绍!在这里,您可以找到所有 LangChain 概念的高级解释。
For a deeper dive into LangGraph concepts, check out this page.
要更深入地了解 LangGraph 概念,请查看此页面。
Integrations 集成
LangChain is part of a rich ecosystem of tools that integrate with our framework and build on top of it.
If you're looking to get up and running quickly with chat models, vector stores,
or other LangChain components from a specific provider, check out our growing list of integrations.
LangChain 是丰富的工具生态系统的一部分,这些工具与我们的框架集成并基于它构建。如果您希望快速启动并运行来自特定提供商的聊天模型、矢量存储或其他 LangChain 组件,请查看我们不断增长的集成列表。
API reference API 参考
Head to the reference section for full documentation of all classes and methods in the LangChain Python packages.
前往参考部分,了解 LangChain Python 包中所有类和方法的完整文档。
Ecosystem 生态系统
🦜🛠️ LangSmith 🦜🛠️ 朗史密斯
Trace and evaluate your language model applications and intelligent agents to help you move from prototype to production.
跟踪和评估您的语言模型应用程序和智能代理,以帮助您从原型过渡到生产。
🦜🕸️ LangGraph 🦜🕸️ 语言图
Build stateful, multi-actor applications with LLMs. Integrates smoothly with LangChain, but can be used without it. LangGraph powers production-grade agents, trusted by Linkedin, Uber, Klarna, GitLab, and many more.
使用 LLMs构建有状态的多参与者应用程序。与 LangChain 无缝集成,但可以在没有 LangChain 的情况下使用。LangGraph 为生产级代理提供支持,深受 LinkedIn、Uber、Klarna、GitLab 等公司的信赖。
Additional resources 其他资源
Versions 版本
See what changed in v0.3, learn how to migrate legacy code, read up on our versioning policies, and more.
查看 v0.3 中的更改,了解如何迁移旧代码,阅读我们的版本控制策略等。
Security 安全
Read up on security best practices to make sure you're developing safely with LangChain.
阅读安全最佳实践,以确保您使用 LangChain 安全地进行开发。
Contributing 贡献
Check out the developer's guide for guidelines on contributing and help getting your dev environment set up.
查看开发人员指南,了解有关贡献和帮助设置开发环境的指南。