LangChain Framework

repository·master·Indexed 13 days ago

https://github.com/langchain-ai/langchain

An agent engineering platform and framework for building LLM-powered applications. It features a modular architecture to chain together models, tools, and data sources, including the langchain-core base abstractions (v1.5.3) and a wide array of partner integrations for providers like OpenAI, Anthropic, Google, and Hugging Face.

Tokens
83.8K
Snippets
299
Records
373
Agent score
99%

What's inside LangChain

  1. What is langchain-model-profiles?

    master

    langchain-model-profiles is a CLI tool designed for maintainers of LangChain integration packages. It automates the process of fetching and updating model capability data (such as context window sizes, supported modalities, tool calling, and structured output) from models.dev.

    This data is used to populate the .profile field in LangChain chat models, providing programmatic access to model capabilities. The tool merges upstream data from models.dev with local augmentations defined in a profile_augmentations.toml file.

  2. What are LangChain Text Splitters?

    master
    LangChain Text Splitters is a collection of utilities designed to split a wide variety of text documents into smaller, manageable chunks. This is a common preprocessing step for RAG (Retrieval Augmented Generation) workflows to ensure text fits within model context windows and maintains semantic relevance.
  3. Understand the LangChain Monorepo structure

    master

    The LangChain repository is organized as a monorepo where core logic and various integration packages reside in the libs/ directory. Key packages include:

    • core/: Contains the core primitives and abstractions used across the LangChain ecosystem.
    • langchain/: Refers to langchain-classic.
    • langchain_v1/: Refers to the main langchain package.
    • partners/: Contains third-party provider integrations maintained directly by the LangChain team.
    • standard-tests/: Provides standardized tests for integrations.
    • text-splitters/: Contains text splitter utilities.

    Each package contains its own README.md with specific installation and usage instructions.

  4. Overview of the LangChain ecosystem

    master

    LangChain is part of a broader ecosystem designed for building, orchestrating, and deploying LLM applications:

    • LangChain: The core framework for chaining interoperable components and third-party integrations.
    • Deep Agents: A higher-level package built on LangChain for agents with built-in capabilities like planning, subagents, and file system usage.
    • LangGraph: A low-level orchestration framework for building controllable, reliable agent workflows.
    • LangSmith: A platform for agent evaluations, observability, and debugging.
    • LangSmith Deployment: A purpose-built platform for deploying and scaling long-running, stateful agent workflows.
    • Integrations: A vast library of chat/embedding models, tools, toolkits, and vector stores.
  5. What is LangChain Core?

    master

    LangChain Core contains the base abstractions that power the entire LangChain ecosystem. It is designed to be modular and simple, providing interfaces that allow any provider (e.g., model providers, vector stores) to implement required standards so they can be used seamlessly across the ecosystem.

    Key benefits include:

    • Modularity: Abstractions are independent and not tied to specific model providers.
    • Stability: Follows a stable versioning scheme with advance notice for breaking changes.
    • Battle-tested: Widely used in production across the LLM ecosystem.
  6. Enable reasoning/thinking mode in OllamaLLM

    master

    For models that support reasoning (e.g., DeepSeek-R1), you can control how the reasoning process is returned using the reasoning parameter.

    • True: Enables reasoning mode. The reasoning process is captured and returned in the additional_kwargs of the response under the key reasoning_content. The main response text will not include the <think> tags.
    • False: Disables reasoning mode. The model will not perform reasoning.
    • None (Default): The model uses its default behavior. If it performs reasoning, the <think> and </think> tags will be present directly within the main response content.

    Example

    model = OllamaLLM(model="deepseek-r1", reasoning=True)
    response = model.invoke("Explain quantum physics")
    # The reasoning content will be available in response.additional_kwargs['reasoning_content']
    model = OllamaLLM(model="deepseek-r1", reasoning=True)
    response = model.invoke("Explain quantum physics")
  7. When to use LangChain vs LangGraph

    master

    LangChain and LangGraph serve different orchestration needs:

    • Use LangChain if you want to quickly build agents and autonomous applications. It provides a pre-built agent architecture and model integrations (OpenAI, Anthropic, Google, etc.) that allow you to get started with minimal code.
    • Use LangGraph if you have advanced needs requiring a combination of deterministic and agentic workflows, heavy customization, and carefully controlled latency. LangGraph is a low-level agent orchestration framework and runtime.

    Note: LangChain agents are actually built on top of LangGraph to provide features like durable execution, streaming, human-in-the-loop, and persistence, but you do not need to know LangGraph to use basic LangChain agents.

  8. Understand the purpose of langchain-classic

    master

    The langchain-classic package is intended for maintaining compatibility with older LangChain features. It includes:

    • Legacy chains
    • langchain-community re-exports
    • The indexing API
    • Other deprecated functionality

    If you are starting a new project, it is recommended to use the standard langchain package rather than langchain-classic.

  9. Find LangChain integration packages

    master

    LangChain integrations are distributed across several locations:

    1. Directly Maintained Integrations: A subset of integrations (like OpenAI, Anthropic, Ollama, DeepSeek, and xAI) are located in the partners/ directory of this monorepo.
    2. External Repositories: Many popular integrations (such as Google and AWS) have been moved to their own dedicated repositories to improve versioning and dependency management.
    3. Third-Party Packages: Many providers maintain their own official LangChain integration packages on PyPI.

    To find a specific integration, consult the LangChain Integrations documentation.