Scripts2026年3月29日·1 分钟阅读

LangChain — Build LLM-Powered Applications

The most popular framework for building applications with large language models. Chains, agents, RAG, memory, tool use, and integrations with 700+ providers.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install langchain langchain-openai langchain-anthropic

介绍

LangChain is the standard framework for building LLM-powered applications. Compose chains of prompts, connect to vector stores for RAG, build autonomous agents, and integrate with hundreds of tools and providers.

Best for: Chatbots, RAG pipelines, autonomous agents, document Q&A, data extraction Works with: OpenAI, Anthropic, Google, Ollama, HuggingFace, and 700+ integrations


Core Concepts

Chains

Compose multiple LLM calls and transformations into a pipeline:

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

chain = ChatPromptTemplate.from_template("Summarize: {text}") | ChatOpenAI()
result = chain.invoke({"text": "..."})

RAG (Retrieval-Augmented Generation)

from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings

vectorstore = FAISS.from_documents(docs, OpenAIEmbeddings())
retriever = vectorstore.as_retriever()

Agents

from langchain.agents import create_tool_calling_agent
agent = create_tool_calling_agent(llm, tools, prompt)

Ecosystem

  • LangSmith — Observability and testing platform
  • LangGraph — Stateful multi-actor agent framework
  • LangServe — Deploy chains as REST APIs

🙏

来源与感谢

Created by LangChain. Licensed under MIT. langchain-ai/langchain — 100K+ GitHub stars

相关资产