LangChain

LangChain is an MIT-licensed framework for building AI agents with model integrations, tools and customizable agent loops

Testo originale della fonte · EN

Guarda in azione

Esempio dell’autore

Author diagram: model and agent harness

Author illustration of an agent harness: memory, skills, tools, context, subagents and system prompt surround the model. This is an architecture diagram from the documentation, rather than an application screenshot or tested output.

LangChain author diagram showing model surrounded by memory, skills, tools, context, subagents and system prompt
Apri immagine intera
Licenza

SVG decoded at declared1200×760 viewport; platform font rendering, no crop/upscale. Pixel equality is against that complete rendered RGBA, not a pre-existing publisher bitmap. Lossless WebP matches the full rendered RGBA.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Esempio dell’autore

Source example: first model invocation

Complete Python block from the official README initializes the stated openai:gpt-5.5 model and invokes a greeting. Requires LangChain, the matching provider integration, credentials and model access; the exact source model string is retained, with no generated answer or independent availability test.

Input di esempio

from langchain.chat_models import init_chat_model

model = init_chat_model("openai:gpt-5.5")
result = model.invoke("Hello, world!")
Licenza

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) LangChain, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Esempio dell’autore

Source example: thread ID and typed context

Complete author Python file combines a fresh thread ID, typed user context and InMemorySaver. It uses the source Claude model and requires its provider integration/credentials. No weather tool is provided, so its weather question is not a live-weather integration. Helper assertions are unexecuted.

Input di esempio

# :snippet-start: agent-invocation-thread-and-context-py
from dataclasses import dataclass

from langchain.agents import create_agent
from langchain_core.utils.uuid import uuid7
from langgraph.checkpoint.memory import InMemorySaver


@dataclass
class Context:
    user_id: str


agent = create_agent(
    model="claude-sonnet-4-6",
    tools=[],
    context_schema=Context,
    checkpointer=InMemorySaver(),
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]},
    config={"configurable": {"thread_id": str(uuid7())}},
    context=Context(user_id="user-123"),
)
# :snippet-end:

# :remove-start:
if __name__ == "__main__":
    last = result["messages"][-1]
    text = last.content_blocks[0]["text"] if last.content_blocks else str(last.content)
    assert text.strip(), "expected non-empty assistant reply"
    print("✓ thread_id and context invoke together without error")
# :remove-end:
Licenza

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Esempio dell’autore

Source example: read a profile from memory

Complete author Python file stores fictional John Smith data and exposes a context-selected lookup tool to an agent. Requires LangChain/LangGraph and the stated model provider credentials. InMemoryStore is a demo; use durable storage for production. No real profile lookup or model result was run.

Input di esempio

# :snippet-start: long-term-memory-read-tool-inmemory-py
from dataclasses import dataclass

from langchain.agents import create_agent
from langchain.tools import ToolRuntime, tool
from langchain_core.runnables import Runnable
from langgraph.store.memory import InMemoryStore


@dataclass
class Context:
    user_id: str


# InMemoryStore saves data to an in-memory dictionary. Use a DB-backed store in production.
store = InMemoryStore()

# Write sample data to the store using the put method
store.put(
    (
        "users",
    ),  # Namespace to group related data together (users namespace for user data)
    "user_123",  # Key within the namespace (user ID as key)
    {
        "name": "John Smith",
        "language": "English",
    },  # Data to store for the given user
)


@tool
def get_user_info(runtime: ToolRuntime[Context]) -> str:
    """Look up user info."""
    # Access the store - same as that provided to `create_agent`
    assert runtime.store is not None
    user_id = runtime.context.user_id
    # Retrieve data from store - returns StoreValue object with value and metadata
    user_info = runtime.store.get(("users",), user_id)
    return str(user_info.value) if user_info else "Unknown user"


agent: Runnable = create_agent(
    model="claude-sonnet-4-6",
    tools=[get_user_info],
    # Pass store to agent - enables agent to access store when running tools
    store=store,
    context_schema=Context,
)

# Run the agent
agent.invoke(
    {"messages": [{"role": "user", "content": "look up user information"}]},
    context=Context(user_id="user_123"),
)
# :snippet-end:

# :remove-start:
if __name__ == "__main__":
    # Verify the store has the data
    result = store.get(("users",), "user_123")
    assert result is not None
    assert result.value["name"] == "John Smith"

    print("✓ Read tool with InMemoryStore works correctly")
# :remove-end:
Licenza

Complete original source file/block(s) unchanged. Outer README fence omitted for copying; grouped complete files keep their own language fences. Editorial title/prerequisites added. Nothing executed.

MIT License

Copyright (c) 2025 LangChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FUNZIONI ELENCATE DALLA FONTE

Cosa offre LangChain

  1. 01Build agent loops with create_agent on LangGraph
  2. 02Connect model providers, tools and databases through integrations
  3. 03Customize context and human review through middleware
  4. 04Maintain workflow state with LangGraph checkpointing and persistence
Testo originale della fonte · EN
Cosa lo distingue

Cosa lo distingue

Developers configure the agent loop, tools, application data and checkpoint storage for their use case. The framework is free to use under MIT; model access, hosting and optional LangSmith tracing, evaluation or deployment services need their own setup and may incur separate charges.

Testo originale della fonte · EN
A chi è adatto

A chi è adatto

  • Developers building tool-calling agents around their own application data
  • Engineering teams customizing model, context and human-review workflows
Testo originale della fonte · EN
PRIMA DI SCEGLIERE

Cosa verificare

  • Prova un’attività reale e confronta il risultato con le tue esigenze.
  • Controlla quali dati vengono conservati, condivisi o usati per l’addestramento.
  • Verifica prezzi, limiti d’uso e condizioni di cancellazione sul sito ufficiale.
Ultima verifica

Link ufficiale controllato il 25 ott 2026. Le funzioni non sono state testate in modo indipendente.

Correlati per attività

ProdottiPrezzoAccessoCASI D’USO
LangChainGratisAPIAutomatizzare i flussi di lavoro
LangGraphNon verificatoAPIAutomatizzare i flussi di lavoro
LangBotNon verificatoWeb, APIAutomatizzare i flussi di lavoro
nanobotNon verificatoWeb, API, Windows, macOS, LinuxGenerare codice pronto per la produzione · Automatizzare i flussi di lavoro
FlowiseNon verificatoAPIAutomatizzare i flussi di lavoro