From 20c5eba3a28e6ff924c129f4977d7e0fa89a3d89 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Sun, 9 Nov 2025 21:19:12 -0500 Subject: [PATCH] refs(py): updates --- pipeline/preprocessors/link_map.py | 3 +- reference/python/docs/langchain/agents.md | 4 + reference/python/docs/langchain/embeddings.md | 4 + reference/python/docs/langchain/messages.md | 4 + reference/python/docs/langchain/middleware.md | 44 +- reference/python/docs/langchain/models.md | 4 + reference/python/docs/langchain/tools.md | 4 + reference/python/uv.lock | 70 +-- src/oss/deepagents/overview.mdx | 2 +- .../javascript/integrations/chat/index.mdx | 6 +- src/oss/langchain/agents.mdx | 12 +- src/oss/langchain/middleware.mdx | 402 +++++++++--------- src/oss/langgraph/graph-api.mdx | 78 ++-- src/oss/langgraph/use-graph-api.mdx | 3 +- .../chat/google_generative_ai.mdx | 9 +- src/oss/python/integrations/chat/index.mdx | 46 +- .../integrations/text_embedding/fake.mdx | 2 +- .../text_embedding/ibm_watsonx.mdx | 2 +- .../integrations/text_embedding/index.mdx | 32 +- .../integrations/text_embedding/mistralai.mdx | 2 +- .../integrations/text_embedding/nomic.mdx | 2 +- .../text_embedding/nvidia_ai_endpoints.mdx | 2 +- 22 files changed, 409 insertions(+), 328 deletions(-) diff --git a/pipeline/preprocessors/link_map.py b/pipeline/preprocessors/link_map.py index 4fe91f1d59..785129769a 100644 --- a/pipeline/preprocessors/link_map.py +++ b/pipeline/preprocessors/link_map.py @@ -104,7 +104,6 @@ class LinkMap(TypedDict): "system_prompt": "langchain/agents/#langchain.agents.create_agent(system_prompt)", "AgentState": "langchain/agents/#langchain.agents.AgentState", "ModelRequest": "langchain/middleware/#langchain.agents.middleware.ModelRequest", - "ModelRequest(response_format)": "langchain/middleware/#langchain.agents.middleware.ModelRequest(response_format)", "@dynamic_prompt": "langchain/middleware/#langchain.agents.middleware.dynamic_prompt", "@before_model": "langchain/middleware/#langchain.agents.middleware.before_model", "@after_model": "langchain/middleware/#langchain.agents.middleware.after_model", @@ -161,7 +160,7 @@ class LinkMap(TypedDict): "AnthropicLLM": "integrations/langchain_anthropic/AnthropicLLM/", # Models "init_chat_model": "langchain/models/#langchain.chat_models.init_chat_model", - "init_chat_model(model_provider)": "langchain/models/#langchain.chat_models.init_chat_model(model_provider)", + "init_chat_model(model)": "langchain/models/#langchain.chat_models.init_chat_model(model)", "BaseChatModel": "langchain_core/language_models/#langchain_core.language_models.chat_models.BaseChatModel", "BaseChatModel.invoke": "langchain_core/language_models/#langchain_core.language_models.chat_models.BaseChatModel.invoke", "BaseChatModel.stream": "langchain_core/language_models/#langchain_core.language_models.chat_models.BaseChatModel.stream", diff --git a/reference/python/docs/langchain/agents.md b/reference/python/docs/langchain/agents.md index 53e8c5881f..4f48f5af53 100644 --- a/reference/python/docs/langchain/agents.md +++ b/reference/python/docs/langchain/agents.md @@ -1,3 +1,7 @@ +!!! warning "Reference docs" + + This page contains **reference documentation** for Agents. See [the docs](https://docs.langchain.com/oss/python/langchain/agents) for conceptual guides, tutorials, and examples on using Agents. + ::: langchain.agents diff --git a/reference/python/docs/langchain/embeddings.md b/reference/python/docs/langchain/embeddings.md index a7224dc128..00ec2f16a6 100644 --- a/reference/python/docs/langchain/embeddings.md +++ b/reference/python/docs/langchain/embeddings.md @@ -1,3 +1,7 @@ +!!! warning "Reference docs" + + This page contains **reference documentation** for Embeddings. See [the docs](https://docs.langchain.com/oss/python/langchain/retrieval#embedding-models) for conceptual guides, tutorials, and examples on using Embeddings. + ::: langchain.embeddings diff --git a/reference/python/docs/langchain/messages.md b/reference/python/docs/langchain/messages.md index e488410a1c..625547f213 100644 --- a/reference/python/docs/langchain/messages.md +++ b/reference/python/docs/langchain/messages.md @@ -1,3 +1,7 @@ +!!! warning "Reference docs" + + This page contains **reference documentation** for Messages. See [the docs](https://docs.langchain.com/oss/python/langchain/messages) for conceptual guides, tutorials, and examples on using Messages. + ::: langchain.messages options: summary: true diff --git a/reference/python/docs/langchain/middleware.md b/reference/python/docs/langchain/middleware.md index df1514cca1..44444bf130 100644 --- a/reference/python/docs/langchain/middleware.md +++ b/reference/python/docs/langchain/middleware.md @@ -1,9 +1,44 @@ +!!! warning "Reference docs" + + This page contains **reference documentation** for Middleware. See [the docs](https://docs.langchain.com/oss/python/langchain/middleware) for conceptual guides, tutorials, and examples on using Middleware. + +## Middleware classes + +| CLASS | DESCRIPTION | +| -------------- | ----------- | +| [`ContextEditingMiddleware`](./#langchain.agents.middleware.ContextEditingMiddleware) | Edit context in agent workflows | +| [`HumanInTheLoopMiddleware`](./#langchain.agents.middleware.HumanInTheLoopMiddleware) | Enable human intervention in agent processes | +| [`LLMToolSelectorMiddleware`](./#langchain.agents.middleware.LLMToolSelectorMiddleware) | Select tools using LLM-based logic | +| [`LLMToolEmulator`](./#langchain.agents.middleware.LLMToolEmulator) | Emulate tool execution using LLM | +| [`ModelCallLimitMiddleware`](./#langchain.agents.middleware.ModelCallLimitMiddleware) | Limit the number of model calls | +| [`ModelFallbackMiddleware`](./#langchain.agents.middleware.ModelFallbackMiddleware) | Provide fallback model options | +| [`PIIMiddleware`](./#langchain.agents.middleware.PIIMiddleware) | Handle personally identifiable information | +| [`SummarizationMiddleware`](./#langchain.agents.middleware.SummarizationMiddleware) | Summarize content in agent workflows | +| [`TodoListMiddleware`](./#langchain.agents.middleware.TodoListMiddleware) | Manage TODO lists in agent processes | +| [`ToolCallLimitMiddleware`](./#langchain.agents.middleware.ToolCallLimitMiddleware) | Limit the number of tool calls | +| [`AgentMiddleware`](./#langchain.agents.middleware.AgentMiddleware) | Base middleware class for agent operations | + +## Components and utilities + +The following classes and functions provide the foundation for building and managing agent middleware: + +| COMPONENT | DESCRIPTION | +| -------------- | ----------- | +| [`AgentState`](./#langchain.agents.middleware.AgentState) | Represent the state of an agent | +| [`ClearToolUsesEdit`](./#langchain.agents.middleware.ClearToolUsesEdit) | Function to clear tool usage edits | +| [`InterruptOnConfig`](./#langchain.agents.middleware.InterruptOnConfig) | Configuration class for interruption handling | +| [`ModelRequest`](./#langchain.agents.middleware.ModelRequest) | Represent a request to a model | +| [`ModelResponse`](./#langchain.agents.middleware.ModelResponse) | Represent a response from a model | +| [`before_model`](./#langchain.agents.middleware.before_model) | Function executed before model calls | +| [`after_model`](./#langchain.agents.middleware.after_model) | Function executed after model calls | +| [`wrap_model_call`](./#langchain.agents.middleware.wrap_model_call) | Function wrapper for model calls | +| [`wrap_tool_call`](./#langchain.agents.middleware.wrap_tool_call) | Function wrapper for tool calls | + + ::: langchain.agents.middleware options: - summary: - # - classes: true + summary: false group_by_category: false members: - ContextEditingMiddleware @@ -15,7 +50,7 @@ - PIIMiddleware - PIIDetectionError - SummarizationMiddleware - - TodoListMiddleWare + - TodoListMiddleware - ToolCallLimitMiddleware - AgentMiddleware - AgentState @@ -27,5 +62,4 @@ - after_model - wrap_model_call - wrap_tool_call - - dynamic-prompt - ModelRequest diff --git a/reference/python/docs/langchain/models.md b/reference/python/docs/langchain/models.md index 1d12fcc0bf..f8b563ffd0 100644 --- a/reference/python/docs/langchain/models.md +++ b/reference/python/docs/langchain/models.md @@ -1,5 +1,9 @@ # Chat models +!!! warning "Reference docs" + + This page contains **reference documentation** for chat models. See [the docs](https://docs.langchain.com/oss/python/langchain/models) for conceptual guides, tutorials, and examples on using chat models. + ::: langchain.chat_models options: parameter_headings: true diff --git a/reference/python/docs/langchain/tools.md b/reference/python/docs/langchain/tools.md index 0049e8be20..e4c90d259d 100644 --- a/reference/python/docs/langchain/tools.md +++ b/reference/python/docs/langchain/tools.md @@ -1,3 +1,7 @@ +!!! warning "Reference docs" + + This page contains **reference documentation** for Tools. See [the docs](https://docs.langchain.com/oss/python/langchain/tools) for conceptual guides, tutorials, and examples on using Tools. + ::: langchain.tools.tool ::: langchain.tools.BaseTool options: diff --git a/reference/python/uv.lock b/reference/python/uv.lock index 6f7be41f4d..217ab9827d 100644 --- a/reference/python/uv.lock +++ b/reference/python/uv.lock @@ -1997,8 +1997,8 @@ wheels = [ [[package]] name = "langchain" -version = "1.0.4" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Flangchain_v1#e023201d4214bf06904ac3cb4a2855516456b0ce" } +version = "1.0.5" +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Flangchain_v1#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "langgraph" }, @@ -2007,8 +2007,8 @@ dependencies = [ [[package]] name = "langchain-anthropic" -version = "1.0.1" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fanthropic#e023201d4214bf06904ac3cb4a2855516456b0ce" } +version = "1.0.2" +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fanthropic#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "anthropic" }, { name = "langchain-core" }, @@ -2068,7 +2068,7 @@ dependencies = [ [[package]] name = "langchain-chroma" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fchroma#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fchroma#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "chromadb" }, { name = "langchain-core" }, @@ -2078,7 +2078,7 @@ dependencies = [ [[package]] name = "langchain-classic" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Flangchain#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Flangchain#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "langchain-text-splitters" }, @@ -2121,8 +2121,8 @@ dependencies = [ [[package]] name = "langchain-core" -version = "1.0.3" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fcore#e023201d4214bf06904ac3cb4a2855516456b0ce" } +version = "1.0.4" +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fcore#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "jsonpatch" }, { name = "langsmith" }, @@ -2146,7 +2146,7 @@ dependencies = [ [[package]] name = "langchain-deepseek" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fdeepseek#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fdeepseek#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "langchain-openai" }, @@ -2155,7 +2155,7 @@ dependencies = [ [[package]] name = "langchain-exa" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fexa#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fexa#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "exa-py" }, { name = "langchain-core" }, @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "langchain-fireworks" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Ffireworks#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Ffireworks#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "aiohttp" }, { name = "fireworks-ai" }, @@ -2176,7 +2176,7 @@ dependencies = [ [[package]] name = "langchain-google-community" version = "3.0.0" -source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fcommunity#e9a9e0c30a2bdb1c1a8d83524073a332d13f2e35" } +source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fcommunity#d26f946cd74a1e0d24b426ed5eb69bbf925f618e" } dependencies = [ { name = "google-api-core" }, { name = "google-api-python-client" }, @@ -2190,7 +2190,7 @@ dependencies = [ [[package]] name = "langchain-google-genai" version = "3.0.1" -source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fgenai#e9a9e0c30a2bdb1c1a8d83524073a332d13f2e35" } +source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fgenai#d26f946cd74a1e0d24b426ed5eb69bbf925f618e" } dependencies = [ { name = "filetype" }, { name = "google-ai-generativelanguage" }, @@ -2201,7 +2201,7 @@ dependencies = [ [[package]] name = "langchain-google-vertexai" version = "3.0.2" -source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fvertexai#e9a9e0c30a2bdb1c1a8d83524073a332d13f2e35" } +source = { git = "https://github.com/langchain-ai/langchain-google.git?subdirectory=libs%2Fvertexai#d26f946cd74a1e0d24b426ed5eb69bbf925f618e" } dependencies = [ { name = "bottleneck" }, { name = "google-cloud-aiplatform" }, @@ -2218,7 +2218,7 @@ dependencies = [ [[package]] name = "langchain-groq" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fgroq#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fgroq#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "groq" }, { name = "langchain-core" }, @@ -2227,7 +2227,7 @@ dependencies = [ [[package]] name = "langchain-huggingface" version = "1.0.1" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fhuggingface#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fhuggingface#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "huggingface-hub" }, { name = "langchain-core" }, @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "langchain-mistralai" version = "1.0.1" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fmistralai#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fmistralai#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "httpx" }, { name = "httpx-sse" }, @@ -2277,7 +2277,7 @@ dependencies = [ [[package]] name = "langchain-model-profiles" version = "0.0.3" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fmodel-profiles#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fmodel-profiles#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "typing-extensions" }, ] @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "langchain-nomic" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fnomic#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fnomic#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "nomic" }, @@ -2306,7 +2306,7 @@ dependencies = [ [[package]] name = "langchain-ollama" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Follama#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Follama#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "ollama" }, @@ -2315,7 +2315,7 @@ dependencies = [ [[package]] name = "langchain-openai" version = "1.0.2" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fopenai#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fopenai#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "openai" }, @@ -2325,7 +2325,7 @@ dependencies = [ [[package]] name = "langchain-perplexity" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fperplexity#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fperplexity#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "openai" }, @@ -2334,7 +2334,7 @@ dependencies = [ [[package]] name = "langchain-prompty" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fprompty#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fprompty#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "pyyaml" }, @@ -2343,7 +2343,7 @@ dependencies = [ [[package]] name = "langchain-qdrant" version = "1.1.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fqdrant#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fqdrant#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, { name = "pydantic" }, @@ -2499,7 +2499,7 @@ dependencies = [ [[package]] name = "langchain-tests" version = "1.0.1" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fstandard-tests#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fstandard-tests#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "httpx" }, { name = "langchain-core" }, @@ -2517,7 +2517,7 @@ dependencies = [ [[package]] name = "langchain-text-splitters" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Ftext-splitters#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Ftext-splitters#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "langchain-core" }, ] @@ -2536,7 +2536,7 @@ dependencies = [ [[package]] name = "langchain-xai" version = "1.0.0" -source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fxai#e023201d4214bf06904ac3cb4a2855516456b0ce" } +source = { git = "https://github.com/langchain-ai/langchain.git?subdirectory=libs%2Fpartners%2Fxai#1996d81d72f70c0df87b8965df9b7050e00115f4" } dependencies = [ { name = "aiohttp" }, { name = "langchain-core" }, @@ -2547,7 +2547,7 @@ dependencies = [ [[package]] name = "langgraph" version = "1.0.2" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Flanggraph#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Flanggraph#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "langchain-core" }, { name = "langgraph-checkpoint" }, @@ -2560,7 +2560,7 @@ dependencies = [ [[package]] name = "langgraph-checkpoint" version = "3.0.1" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "langchain-core" }, { name = "ormsgpack" }, @@ -2579,7 +2579,7 @@ dependencies = [ [[package]] name = "langgraph-checkpoint-postgres" version = "3.0.1" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint-postgres#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint-postgres#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "langgraph-checkpoint" }, { name = "orjson" }, @@ -2590,7 +2590,7 @@ dependencies = [ [[package]] name = "langgraph-checkpoint-sqlite" version = "3.0.0" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint-sqlite#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fcheckpoint-sqlite#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "aiosqlite" }, { name = "langgraph-checkpoint" }, @@ -2600,7 +2600,7 @@ dependencies = [ [[package]] name = "langgraph-prebuilt" version = "1.0.2" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fprebuilt#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fprebuilt#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "langchain-core" }, { name = "langgraph-checkpoint" }, @@ -2609,7 +2609,7 @@ dependencies = [ [[package]] name = "langgraph-sdk" version = "0.2.9" -source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fsdk-py#9fd3dfc54223f082823dacd3c1e78ac0d9852122" } +source = { git = "https://github.com/langchain-ai/langgraph?subdirectory=libs%2Fsdk-py#cf3e8252f5516b312e4738125c503977b0be3a3f" } dependencies = [ { name = "httpx" }, { name = "orjson" }, @@ -2626,8 +2626,8 @@ dependencies = [ [[package]] name = "langsmith" -version = "0.4.41" -source = { git = "https://github.com/langchain-ai/langsmith-sdk.git?subdirectory=python#46598b0240fc7889783bfa6db761608d258c46fd" } +version = "0.4.42" +source = { git = "https://github.com/langchain-ai/langsmith-sdk.git?subdirectory=python#1ec709e6b90c1c7226ddb7fb495519501e8c5ccc" } dependencies = [ { name = "httpx" }, { name = "orjson", marker = "platform_python_implementation != 'PyPy'" }, diff --git a/src/oss/deepagents/overview.mdx b/src/oss/deepagents/overview.mdx index 3bdb5c9594..2d33b417f3 100644 --- a/src/oss/deepagents/overview.mdx +++ b/src/oss/deepagents/overview.mdx @@ -71,7 +71,7 @@ Deep agents applications can be deployed via [LangSmith Deployment](/langsmith/d ::: -:::python +:::js Build your first deep agent diff --git a/src/oss/javascript/integrations/chat/index.mdx b/src/oss/javascript/integrations/chat/index.mdx index 58ffa58862..4c787c8d14 100644 --- a/src/oss/javascript/integrations/chat/index.mdx +++ b/src/oss/javascript/integrations/chat/index.mdx @@ -2,7 +2,7 @@ title: Chat models --- -[Chat models](/oss/langchain/models) are language models that use a sequence of [messages](/oss/langchain/messages) as inputs and return messages as outputs (as opposed to plaintext). +[Chat models](/oss/langchain/models) are language models that use a sequence of [messages](/oss/langchain/messages) as inputs and return messages as outputs (as opposed to plaintext). ## Install and use @@ -264,6 +264,10 @@ title: Chat models ## Featured providers + + **While these LangChain classes support the indicated advanced feature**, you may need to refer to provider-specific documentation to learn which hosted models or backends support the feature. + + | Model | Stream | JSON mode | [Tool Calling](/oss/langchain/tools/) | [`withStructuredOutput()`](/oss/langchain/structured-output#the-.withstructuredoutput-method) | [Multimodal](/oss/langchain/messages#multimodal) | | :----------------------------------------------------------------------- | :----: | :-------: | :----------------------------------------: | :------------------------------------------------------------------------------------------: | :-------------------------------------------: | | [`BedrockChat`](/oss/integrations/chat/bedrock/) | βœ… | ❌ | 🟑 (Bedrock Anthropic only) | 🟑 (Bedrock Anthropic only) | 🟑 (Bedrock Anthropic only) | diff --git a/src/oss/langchain/agents.mdx b/src/oss/langchain/agents.mdx index f43f6d1b1b..c687215c36 100644 --- a/src/oss/langchain/agents.mdx +++ b/src/oss/langchain/agents.mdx @@ -2,8 +2,6 @@ title: Agents --- - - Agents combine language models with [tools](/oss/langchain/tools) to create systems that can reason about tasks, decide which tools to use, and iteratively work towards solutions. :::python @@ -68,7 +66,7 @@ The [model](/oss/langchain/models) is the reasoning engine of your agent. It can Static models are configured once when creating the agent and remain unchanged throughout execution. This is the most common and straightforward approach. -To initialize a static model from a model identifier string: +To initialize a static model from a model identifier string: :::python ```python wrap @@ -93,7 +91,7 @@ const agent = createAgent({ :::python - Model identifier strings support automatic inference (e.g., `"gpt-5"` will be inferred as `"openai:gpt-5"`). Refer to the @[reference][init_chat_model(model_provider)] to see a full list of model identifier string mappings. + Model identifier strings support automatic inference (e.g., `"gpt-5"` will be inferred as `"openai:gpt-5"`). Refer to the @[reference][init_chat_model(model)] to see a full list of model identifier string mappings. For more control over the model configuration, initialize a model instance directly using the provider package. In this example, we use @[`ChatOpenAI`]. See [Chat models](/oss/integrations/chat) for other available chat model classes. @@ -567,7 +565,7 @@ await agent.invoke({ For streaming steps and / or tokens from the agent, refer to the [streaming](/oss/langchain/streaming) guide. -Otherwise, the agent follows the LangGraph [Graph API](/oss/langgraph/use-graph-api) and supports all associated methods. +Otherwise, the agent follows the LangGraph [Graph API](/oss/langgraph/use-graph-api) and supports all associated methods, such as `stream` and `invoke`. ## Advanced concepts @@ -575,7 +573,7 @@ Otherwise, the agent follows the LangGraph [Graph API](/oss/langgraph/use-graph- :::python -In some situations, you may want the agent to return an output in a specific format. LangChain provides strategies for structured output via the @[`response_format`][ModelRequest(response_format)] parameter. +In some situations, you may want the agent to return an output in a specific format. LangChain provides strategies for structured output via the `response_format` parameter. #### ToolStrategy @@ -660,7 +658,7 @@ console.log(result.structuredResponse); ``` ::: -To learn about structured output, see [Structured output](/oss/langchain/structured-output). + To learn about structured output, see [Structured output](/oss/langchain/structured-output). ### Memory diff --git a/src/oss/langchain/middleware.mdx b/src/oss/langchain/middleware.mdx index 984b5d7efa..929b7ff5b8 100644 --- a/src/oss/langchain/middleware.mdx +++ b/src/oss/langchain/middleware.mdx @@ -3,59 +3,59 @@ title: Middleware description: Control and customize agent execution at every step --- - - Middleware provides a way to more tightly control what happens inside the agent. The core agent loop involves calling a model, letting it choose tools to execute, and then finishing when it calls no more tools:
- Core agent loop diagram + Core agent loop diagram
Middleware exposes hooks before and after each of those steps:
- Middleware flow diagram + Middleware flow diagram
## What can middleware do? - - Track agent behavior with logging, analytics, and debugging - - - Transform prompts, tool selection, and output formatting - - - Add retries, fallbacks, and early termination logic - - - Apply rate limits, guardrails, and PII detection - + + Track agent behavior with logging, analytics, and debugging + + + Transform prompts, tool selection, and output formatting + + + Add retries, fallbacks, and early termination logic + + + Apply rate limits, guardrails, and PII detection + -Add middleware by passing it to @[`create_agent`]: +Add middleware by passing them to @[`create_agent`]: :::python ```python from langchain.agents import create_agent from langchain.agents.middleware import SummarizationMiddleware, HumanInTheLoopMiddleware - agent = create_agent( model="gpt-4o", tools=[...], - middleware=[SummarizationMiddleware(), HumanInTheLoopMiddleware()], + middleware=[ + SummarizationMiddleware(...), + HumanInTheLoopMiddleware(...) + ], ) ``` ::: @@ -76,6 +76,8 @@ const agent = createAgent({ ``` ::: +Refer to the docs below for a list of parameters and configuration details for each type of middleware. + ## Built-in middleware LangChain provides prebuilt middleware for common use cases: @@ -85,10 +87,10 @@ LangChain provides prebuilt middleware for common use cases: Automatically summarize conversation history when approaching token limits. -**Perfect for:** -- Long-running conversations that exceed context windows -- Multi-turn dialogues with extensive history -- Applications where preserving full conversation context matters + **Perfect for:** + - Long-running conversations that exceed context windows + - Multi-turn dialogues with extensive history + - Applications where preserving full conversation context matters :::python @@ -134,54 +136,54 @@ const agent = createAgent({ :::python - - Model for generating summaries + + Model for generating summaries. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. See @[`init_chat_model`][init_chat_model(model)] for more information. - Token threshold for triggering summarization + Token threshold for triggering summarization - Recent messages to preserve + Recent messages to preserve - Custom token counting function. Defaults to character-based counting. + Custom token counting function. Defaults to character-based counting. - Custom prompt template. Uses built-in template if not specified. + Custom prompt template. Uses built-in template if not specified. - Prefix for summary messages + Prefix for summary messages ::: :::js - - Model for generating summaries + + Model for generating summaries. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. - Token threshold for triggering summarization + Token threshold for triggering summarization - Recent messages to preserve + Recent messages to preserve - Custom token counting function. Defaults to character-based counting. + Custom token counting function. Defaults to character-based counting. - Custom prompt template. Uses built-in template if not specified. + Custom prompt template. Uses built-in template if not specified. - Prefix for summary messages + Prefix for summary messages ::: @@ -192,10 +194,10 @@ const agent = createAgent({ Pause agent execution for human approval, editing, or rejection of tool calls before they execute. -**Perfect for:** -- High-stakes operations requiring human approval (database writes, financial transactions) -- Compliance workflows where human oversight is mandatory -- Long running conversations where human feedback is used to guide the agent + **Perfect for:** + - High-stakes operations requiring human approval (database writes, financial transactions) + - Compliance workflows where human oversight is mandatory + - Long running conversations where human feedback is used to guide the agent :::python @@ -254,50 +256,50 @@ const agent = createAgent({ :::python - Mapping of tool names to approval configs. Values can be `True` (interrupt with default config), `False` (auto-approve), or an `InterruptOnConfig` object. + Mapping of tool names to approval configs. Values can be `True` (interrupt with default config), `False` (auto-approve), or an `InterruptOnConfig` object. - Prefix for action request descriptions + Prefix for action request descriptions **`InterruptOnConfig` options:** - List of allowed decisions: `"approve"`, `"edit"`, or `"reject"` + List of allowed decisions: `'approve'`, `'edit'`, or `'reject'` - Static string or callable function for custom description + Static string or callable function for custom description ::: :::js - Mapping of tool names to approval configs + Mapping of tool names to approval configs **Tool approval config options:** - Whether approval is allowed + Whether approval is allowed - Whether editing is allowed + Whether editing is allowed - Whether responding/rejection is allowed + Whether responding/rejection is allowed ::: -**Important:** Human-in-the-loop middleware requires a [checkpointer](/oss/langgraph/persistence#checkpoints) to maintain state across interruptions. + **Important:** Human-in-the-loop middleware requires a [checkpointer](/oss/langgraph/persistence#checkpoints) to maintain state across interruptions. -See the [human-in-the-loop documentation](/oss/langchain/human-in-the-loop) for complete examples and integration patterns. + See the [human-in-the-loop documentation](/oss/langchain/human-in-the-loop) for complete examples and integration patterns. ### Anthropic prompt caching @@ -305,14 +307,14 @@ See the [human-in-the-loop documentation](/oss/langchain/human-in-the-loop) for Reduce costs by caching repetitive prompt prefixes with Anthropic models. -**Perfect for:** -- Applications with long, repeated system prompts -- Agents that reuse the same context across invocations -- Reducing API costs for high-volume deployments + **Perfect for:** + - Applications with long, repeated system prompts + - Agents that reuse the same context across invocations + - Reducing API costs for high-volume deployments -Learn more about [Anthropic Prompt Caching](https://docs.claude.com/en/docs/build-with-claude/prompt-caching#cache-limitations) strategies and limitations. + Learn more about [Anthropic Prompt Caching](https://docs.claude.com/en/docs/build-with-claude/prompt-caching#cache-limitations) strategies and limitations. :::python @@ -374,25 +376,25 @@ const result = await agent.invoke({ :::python - Cache type. Only `"ephemeral"` is currently supported. + Cache type. Only `'ephemeral'` is currently supported. - Time to live for cached content. Valid values: `"5m"` or `"1h"` + Time to live for cached content. Valid values: `'5m'` or `'1h'` - Minimum number of messages before caching starts + Minimum number of messages before caching starts - Behavior when using non-Anthropic models. Options: `"ignore"`, `"warn"`, or `"raise"` + Behavior when using non-Anthropic models. Options: `'ignore'`, `'warn'`, or `'raise'` ::: :::js - Time to live for cached content. Valid values: `"5m"` or `"1h"` + Time to live for cached content. Valid values: `'5m'` or `'1h'` ::: @@ -403,10 +405,10 @@ const result = await agent.invoke({ Limit the number of model calls to prevent infinite loops or excessive costs. -**Perfect for:** -- Preventing runaway agents from making too many API calls -- Enforcing cost controls on production deployments -- Testing agent behavior within specific call budgets + **Perfect for:** + - Preventing runaway agents from making too many API calls + - Enforcing cost controls on production deployments + - Testing agent behavior within specific call budgets :::python @@ -417,7 +419,7 @@ from langchain.agents.middleware import ModelCallLimitMiddleware agent = create_agent( model="gpt-4o", - tools=[...], + tools=[], # Add tools as needed middleware=[ ModelCallLimitMiddleware( thread_limit=10, # Max 10 calls per thread (across runs) @@ -451,29 +453,29 @@ const agent = createAgent({ :::python - Maximum model calls across all runs in a thread. Defaults to no limit. + Maximum model calls across all runs in a thread. Defaults to no limit. - Maximum model calls per single invocation. Defaults to no limit. + Maximum model calls per single invocation. Defaults to no limit. - Behavior when limit is reached. Options: `"end"` (graceful termination) or `"error"` (raise exception) + Behavior when limit is reached. Options: `'end'` (graceful termination) or `'error'` (raise exception) ::: :::js - Maximum model calls across all runs in a thread. Defaults to no limit. + Maximum model calls across all runs in a thread. Defaults to no limit. - Maximum model calls per single invocation. Defaults to no limit. + Maximum model calls per single invocation. Defaults to no limit. - Behavior when limit is reached. Options: `"end"` (graceful termination) or `"error"` (throw exception) + Behavior when limit is reached. Options: `'end'` (graceful termination) or `'error'` (throw exception) ::: @@ -484,11 +486,11 @@ const agent = createAgent({ Control agent execution by limiting the number of tool calls, either globally across all tools or for specific tools. -**Perfect for:** -- Preventing excessive calls to expensive external APIs -- Limiting web searches or database queries -- Enforcing rate limits on specific tool usage -- Protecting against runaway agent loops + **Perfect for:** + - Preventing excessive calls to expensive external APIs + - Limiting web searches or database queries + - Enforcing rate limits on specific tool usage + - Protecting against runaway agent loops :::python @@ -513,15 +515,16 @@ To limit tool calls globally across all tools or for specific tools, set `toolNa | Behavior | Effect | Best For | |----------|--------|----------| -| **`"continue"`** (default) | Blocks exceeded calls with error messages, agent continues | Most use cases - agent handles limits gracefully | -| **`"error"`** | Raises exception immediately | Complex workflows where you want to handle the limit error manually | -| **`"end"`** | Stops with ToolMessage + AI message | Single-tool scenarios (errors if other tools pending) | +| **`'continue'`** (default) | Blocks exceeded calls with error messages, agent continues | Most use cases - agent handles limits gracefully | +| **`'error'`** | Raises exception immediately | Complex workflows where you want to handle the limit error manually | +| **`'end'`** | Stops with ToolMessage + AI message | Single-tool scenarios (errors if other tools pending) | :::python ```python from langchain.agents import create_agent from langchain.agents.middleware import ToolCallLimitMiddleware + # Global limit: max 20 calls per thread, 10 per run global_limiter = ToolCallLimitMiddleware( thread_limit=20, @@ -619,47 +622,49 @@ const agent = createAgent({ :::python - Name of specific tool to limit. If not provided, limits apply to **all tools globally**. + Name of specific tool to limit. If not provided, limits apply to **all tools globally**. - Maximum tool calls across all runs in a thread (conversation). Persists across multiple invocations with the same thread ID. Requires a checkpointer to maintain state. `None` means no thread limit. + Maximum tool calls across all runs in a thread (conversation). Persists across multiple invocations with the same thread ID. Requires a checkpointer to maintain state. `None` means no thread limit. - Maximum tool calls per single invocation (one user message β†’ response cycle). Resets with each new user message. `None` means no run limit. + Maximum tool calls per single invocation (one user message β†’ response cycle). Resets with each new user message. `None` means no run limit. - **Note:** At least one of `thread_limit` or `run_limit` must be specified. + **Note:** At least one of `thread_limit` or `run_limit` must be specified. - Behavior when limit is reached: - - `"continue"` (default) - Block exceeded tool calls with error messages, let other tools and the model continue. The model decides when to end based on the error messages. - - `"error"` - Raise a `ToolCallLimitExceededError` exception, stopping execution immediately - - `"end"` - Stop execution immediately with a ToolMessage and AI message for the exceeded tool call. Only works when limiting a single tool; raises `NotImplementedError` if other tools have pending calls. + Behavior when limit is reached: + + - `'continue'` (default) - Block exceeded tool calls with error messages, let other tools and the model continue. The model decides when to end based on the error messages. + - `'error'` - Raise a `ToolCallLimitExceededError` exception, stopping execution immediately + - `'end'` - Stop execution immediately with a `ToolMessage` and AI message for the exceeded tool call. Only works when limiting a single tool; raises `NotImplementedError` if other tools have pending calls. ::: :::js - Name of specific tool to limit. If not provided, limits apply to **all tools globally**. + Name of specific tool to limit. If not provided, limits apply to **all tools globally**. - Maximum tool calls across all runs in a thread (conversation). Persists across multiple invocations with the same thread ID. Requires a checkpointer to maintain state. `undefined` means no thread limit. + Maximum tool calls across all runs in a thread (conversation). Persists across multiple invocations with the same thread ID. Requires a checkpointer to maintain state. `undefined` means no thread limit. - Maximum tool calls per single invocation (one user message β†’ response cycle). Resets with each new user message. `undefined` means no run limit. + Maximum tool calls per single invocation (one user message β†’ response cycle). Resets with each new user message. `undefined` means no run limit. - **Note:** At least one of `threadLimit` or `runLimit` must be specified. + **Note:** At least one of `threadLimit` or `runLimit` must be specified. - Behavior when limit is reached: - - `"continue"` (default) - Block exceeded tool calls with error messages, let other tools and the model continue. The model decides when to end based on the error messages. - - `"error"` - Throw a `ToolCallLimitExceededError` exception, stopping execution immediately - - `"end"` - Stop execution immediately with a ToolMessage and AI message for the exceeded tool call. Only works when limiting a single tool; throws error if other tools have pending calls. + Behavior when limit is reached: + + - `'continue'` (default) - Block exceeded tool calls with error messages, let other tools and the model continue. The model decides when to end based on the error messages. + - `'error'` - Throw a `ToolCallLimitExceededError` exception, stopping execution immediately + - `'end'` - Stop execution immediately with a ToolMessage and AI message for the exceeded tool call. Only works when limiting a single tool; throws error if other tools have pending calls. ::: @@ -670,10 +675,10 @@ const agent = createAgent({ Automatically fallback to alternative models when the primary model fails. -**Perfect for:** -- Building resilient agents that handle model outages -- Cost optimization by falling back to cheaper models -- Provider redundancy across OpenAI, Anthropic, etc. + **Perfect for:** + - Building resilient agents that handle model outages + - Cost optimization by falling back to cheaper models + - Provider redundancy across OpenAI, Anthropic, etc. :::python @@ -684,7 +689,7 @@ from langchain.agents.middleware import ModelFallbackMiddleware agent = create_agent( model="gpt-4o", # Primary model - tools=[...], + tools=[], # Add tools as needed middleware=[ ModelFallbackMiddleware( "gpt-4o-mini", # Try first on error @@ -716,7 +721,7 @@ const agent = createAgent({ :::python - First fallback model to try when the primary model fails. Can be a model string (e.g., `"openai:gpt-4o-mini"`) or a `BaseChatModel` instance. + First fallback model to try when the primary model fails. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. @@ -747,10 +752,10 @@ The middleware accepts a variable number of string arguments representing fallba Detect and handle Personally Identifiable Information in conversations. -**Perfect for:** -- Healthcare and financial applications with compliance requirements -- Customer service agents that need to sanitize logs -- Any application handling sensitive user data + **Perfect for:** + - Healthcare and financial applications with compliance requirements + - Customer service agents that need to sanitize logs + - Any application handling sensitive user data :::python @@ -761,7 +766,7 @@ from langchain.agents.middleware import PIIMiddleware agent = create_agent( model="gpt-4o", - tools=[...], + tools=[], # Add tools as needed middleware=[ # Redact emails in user input PIIMiddleware("email", strategy="redact", apply_to_input=True), @@ -813,61 +818,63 @@ const agent = createAgent({ :::python - Type of PII to detect. Can be a built-in type (`email`, `credit_card`, `ip`, `mac_address`, `url`) or a custom type name. + Type of PII to detect. Can be a built-in type (`email`, `credit_card`, `ip`, `mac_address`, `url`) or a custom type name. - How to handle detected PII. Options: - - `"block"` - Raise exception when detected - - `"redact"` - Replace with `[REDACTED_TYPE]` - - `"mask"` - Partially mask (e.g., `****-****-****-1234`) - - `"hash"` - Replace with deterministic hash + How to handle detected PII. Options: + + - `'block'` - Raise exception when detected + - `'redact'` - Replace with `[REDACTED_TYPE]` + - `'mask'` - Partially mask (e.g., `****-****-****-1234`) + - `'hash'` - Replace with deterministic hash - Custom detector function or regex pattern. If not provided, uses built-in detector for the PII type. + Custom detector function or regex pattern. If not provided, uses built-in detector for the PII type. - Check user messages before model call + Check user messages before model call - Check AI messages after model call + Check AI messages after model call - Check tool result messages after execution + Check tool result messages after execution ::: :::js - Type of PII to detect. Can be a built-in type (`email`, `credit_card`, `ip`, `mac_address`, `url`) or a custom type name. + Type of PII to detect. Can be a built-in type (`email`, `credit_card`, `ip`, `mac_address`, `url`) or a custom type name. - How to handle detected PII. Options: - - `"block"` - Throw error when detected - - `"redact"` - Replace with `[REDACTED_TYPE]` - - `"mask"` - Partially mask (e.g., `****-****-****-1234`) - - `"hash"` - Replace with deterministic hash + How to handle detected PII. Options: + + - `'block'` - Throw error when detected + - `'redact'` - Replace with `[REDACTED_TYPE]` + - `'mask'` - Partially mask (e.g., `****-****-****-1234`) + - `'hash'` - Replace with deterministic hash - Custom detector regex pattern. If not provided, uses built-in detector for the PII type. + Custom detector regex pattern. If not provided, uses built-in detector for the PII type. - Check user messages before model call + Check user messages before model call - Check AI messages after model call + Check AI messages after model call - Check tool result messages after execution + Check tool result messages after execution ::: @@ -878,9 +885,9 @@ const agent = createAgent({ Equip agents with task planning and tracking capabilities for complex multi-step tasks. -**Perfect for:** -- Complex multi-step tasks requiring coordination across multiple tools -- Long-running operations where progress visibility is important + **Perfect for:** + - Complex multi-step tasks requiring coordination across multiple tools + - Long-running operations where progress visibility is important Just as humans are more effective when they write down and track tasks, agents benefit from structured task management to break down complex problems, adapt plans as new information emerges, and provide transparency into their workflow. @@ -888,7 +895,7 @@ Just as humans are more effective when they write down and track tasks, agents b You may have noticed patterns like this in Claude Code, which writes out a to-do list before tackling complex, multi-part tasks. -This middleware automatically provides agents with a `write_todos` tool and system prompts to guide effective task planning. + This middleware automatically provides agents with a `write_todos` tool and system prompts to guide effective task planning. :::python @@ -1012,11 +1019,11 @@ console.log(result.todos); // Track the agent's progress through each step :::python - Custom system prompt for guiding todo usage. Uses built-in prompt if not specified. + Custom system prompt for guiding todo usage. Uses built-in prompt if not specified. - Custom description for the `write_todos` tool. Uses built-in description if not specified. + Custom description for the `write_todos` tool. Uses built-in description if not specified. ::: @@ -1031,10 +1038,10 @@ No configuration options available (uses defaults). Use an LLM to intelligently select relevant tools before calling the main model. -**Perfect for:** -- Agents with many tools (10+) where most aren't relevant per query -- Reducing token usage by filtering irrelevant tools -- Improving model focus and accuracy + **Perfect for:** + - Agents with many tools (10+) where most aren't relevant per query + - Reducing token usage by filtering irrelevant tools + - Improving model focus and accuracy :::python @@ -1079,33 +1086,35 @@ const agent = createAgent({ :::python - Model for tool selection. Can be a model string or `BaseChatModel` instance. Defaults to the agent's main model. + Model for tool selection. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. See @[`init_chat_model`][init_chat_model(model)] for more information. + + Defaults to the agent's main model. - Instructions for the selection model. Uses built-in prompt if not specified. + Instructions for the selection model. Uses built-in prompt if not specified. - Maximum number of tools to select. Defaults to no limit. + Maximum number of tools to select. Defaults to no limit. - List of tool names to always include in the selection + List of tool names to always include in the selection ::: :::js - - Model for tool selection. Defaults to the agent's main model. + + Model for tool selection. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. Defaults to the agent's main model. - Maximum number of tools to select. Defaults to no limit. + Maximum number of tools to select. Defaults to no limit. - Array of tool names to always include in the selection + Array of tool names to always include in the selection ::: @@ -1118,10 +1127,10 @@ const agent = createAgent({ Automatically retry failed tool calls with configurable exponential backoff. -**Perfect for:** -- Handling transient failures in external API calls -- Improving reliability of network-dependent tools -- Building resilient agents that gracefully handle temporary errors + **Perfect for:** + - Handling transient failures in external API calls + - Improving reliability of network-dependent tools + - Building resilient agents that gracefully handle temporary errors ```python @@ -1147,38 +1156,38 @@ agent = create_agent( - Maximum number of retry attempts after the initial call (3 total attempts with default) + Maximum number of retry attempts after the initial call (3 total attempts with default) - Optional list of tools or tool names to apply retry logic to. If `None`, applies to all tools. + Optional list of tools or tool names to apply retry logic to. If `None`, applies to all tools. - Either a tuple of exception types to retry on, or a callable that takes an exception and returns `True` if it should be retried. + Either a tuple of exception types to retry on, or a callable that takes an exception and returns `True` if it should be retried. - Behavior when all retries are exhausted. Options: - - `"return_message"` - Return a ToolMessage with error details (allows LLM to handle failure) - - `"raise"` - Re-raise the exception (stops agent execution) - - Custom callable - Function that takes the exception and returns a string for the ToolMessage content + Behavior when all retries are exhausted. Options: + - `'return_message'` - Return a `ToolMessage` with error details (allows LLM to handle failure) + - `'raise'` - Re-raise the exception (stops agent execution) + - Custom callable - Function that takes the exception and returns a string for the `ToolMessage` content - Multiplier for exponential backoff. Each retry waits `initial_delay * (backoff_factor ** retry_number)` seconds. Set to 0.0 for constant delay. + Multiplier for exponential backoff. Each retry waits `initial_delay * (backoff_factor ** retry_number)` seconds. Set to `0.0` for constant delay. - Initial delay in seconds before first retry + Initial delay in seconds before first retry - Maximum delay in seconds between retries (caps exponential backoff growth) + Maximum delay in seconds between retries (caps exponential backoff growth) - Whether to add random jitter (Β±25%) to delay to avoid thundering herd + Whether to add random jitter (`Β±25%`) to delay to avoid thundering herd @@ -1192,10 +1201,10 @@ agent = create_agent( Emulate tool execution using an LLM for testing purposes, replacing actual tool calls with AI-generated responses. -**Perfect for:** -- Testing agent behavior without executing real tools -- Developing agents when external tools are unavailable or expensive -- Prototyping agent workflows before implementing actual tools + **Perfect for:** + - Testing agent behavior without executing real tools + - Developing agents when external tools are unavailable or expensive + - Prototyping agent workflows before implementing actual tools ```python @@ -1226,7 +1235,7 @@ agent = create_agent( - Model to use for generating emulated tool responses. Can be a model identifier string or BaseChatModel instance. + Model to use for generating emulated tool responses. Can be a model identifier string (e.g., `'openai:gpt-4o-mini'`) or a `BaseChatModel` instance. See @[`init_chat_model`][init_chat_model(model)] for more information. @@ -1238,10 +1247,10 @@ agent = create_agent( Manage conversation context by trimming, summarizing, or clearing tool uses. -**Perfect for:** -- Long conversations that need periodic context cleanup -- Removing failed tool attempts from context -- Custom context management strategies + **Perfect for:** + - Long conversations that need periodic context cleanup + - Removing failed tool attempts from context + - Custom context management strategies :::python @@ -1252,7 +1261,7 @@ from langchain.agents.middleware import ContextEditingMiddleware, ClearToolUsesE agent = create_agent( model="gpt-4o", - tools=[...], + tools=[], # Add tools as needed middleware=[ ContextEditingMiddleware( edits=[ @@ -1286,49 +1295,49 @@ const agent = createAgent({ :::python - List of `ContextEdit` strategies to apply + List of `ContextEdit` strategies to apply - Token counting method. Options: `"approximate"` or `"model"` + Token counting method. Options: `'approximate'` or `'model'` **@[`ClearToolUsesEdit`] options:** - Token count that triggers the edit + Token count that triggers the edit - Minimum tokens to reclaim + Minimum tokens to reclaim - Number of recent tool results to preserve + Number of recent tool results to preserve - Whether to clear tool call parameters + Whether to clear tool call parameters - List of tool names to exclude from clearing + List of tool names to exclude from clearing - Placeholder text for cleared outputs + Placeholder text for cleared outputs ::: :::js - Array of `ContextEdit` strategies to apply + Array of `ContextEdit` strategies to apply **@[`ClearToolUsesEdit`] options:** - Token count that triggers the edit + Token count that triggers the edit ::: @@ -1810,7 +1819,6 @@ const result = await agent.invoke({ Context properties are configuration values passed through the runnable config. Unlike state, context is read-only and typically used for configuration that doesn't change during execution. - Middleware can define context requirements that must be satisfied through the agent's configuration: ```typescript @@ -1951,11 +1959,11 @@ const earlyExitMiddleware = createMiddleware({ Available jump targets: -- `"end"`: Jump to the end of the agent execution -- `"tools"`: Jump to the tools node -- `"model"`: Jump to the model node (or the first `before_model` hook) +- `'end'`: Jump to the end of the agent execution +- `'tools'`: Jump to the tools node +- `'model'`: Jump to the model node (or the first `before_model` hook) -**Important:** When jumping from `before_model` or `after_model`, jumping to `"model"` will cause all `before_model` middleware to run again. +**Important:** When jumping from `before_model` or `after_model`, jumping to `'model'` will cause all `before_model` middleware to run again. To enable jumping, decorate your hook with `@hook_config(can_jump_to=[...])`: @@ -2008,10 +2016,10 @@ const conditionalMiddleware = createMiddleware({ Select relevant tools at runtime to improve performance and accuracy. -**Benefits:** -- **Shorter prompts** - Reduce complexity by exposing only relevant tools -- **Better accuracy** - Models choose correctly from fewer options -- **Permission control** - Dynamically filter tools based on user access + **Benefits:** + - **Shorter prompts** - Reduce complexity by exposing only relevant tools + - **Better accuracy** - Models choose correctly from fewer options + - **Permission control** - Dynamically filter tools based on user access :::python diff --git a/src/oss/langgraph/graph-api.mdx b/src/oss/langgraph/graph-api.mdx index a9db258597..821557d44e 100644 --- a/src/oss/langgraph/graph-api.mdx +++ b/src/oss/langgraph/graph-api.mdx @@ -15,7 +15,9 @@ At its core, LangGraph models agent workflows as graphs. You define the behavior 3. [`Edges`](#edges): Functions that determine which `Node` to execute next based on the current state. They can be conditional branches or fixed transitions. -By composing `Nodes` and `Edges`, you can create complex, looping workflows that evolve the state over time. The real power, though, comes from how LangGraph manages that state. To emphasize: `Nodes` and `Edges` are nothing more than functions - they can contain an LLM or just good ol' code. +By composing `Nodes` and `Edges`, you can create complex, looping workflows that evolve the state over time. The real power, though, comes from how LangGraph manages that state. + +To emphasize: `Nodes` and `Edges` are nothing more than functions – they can contain an LLM or just good ol' code. In short: _nodes do the work, edges tell what to do next_. @@ -53,7 +55,9 @@ const graph = new StateGraph(StateAnnotation) ::: -You **MUST** compile your graph before you can use it. + + You **MUST** compile your graph before you can use it. + ## State @@ -68,9 +72,9 @@ The first thing you do when you define a graph is define the `State` of the grap ### Schema :::python -The main documented way to specify the schema of a graph is by using a [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict). If you want to provide default values in your state, use a [`dataclass`](https://docs.python.org/3/library/dataclasses.html). We also support using a Pydantic [BaseModel](/oss/langgraph/use-graph-api#use-pydantic-models-for-graph-state) as your graph state if you want recursive data validation (though note that pydantic is less performant than a `TypedDict` or `dataclass`). +The main documented way to specify the schema of a graph is by using a [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict). If you want to provide default values in your state, use a [`dataclass`](https://docs.python.org/3/library/dataclasses.html). We also support using a Pydantic [`BaseModel`](/oss/langgraph/use-graph-api#use-pydantic-models-for-graph-state) as your graph state if you want recursive data validation (though note that Pydantic is less performant than a `TypedDict` or `dataclass`). -By default, the graph will have the same input and output schemas. If you want to change this, you can also specify explicit input and output schemas directly. This is useful when you have a lot of keys, and some are explicitly for input and others for output. See the [guide here](/oss/langgraph/use-graph-api#define-input-and-output-schemas) for how to use. +By default, the graph will have the same input and output schemas. If you want to change this, you can also specify explicit input and output schemas directly. This is useful when you have a lot of keys, and some are explicitly for input and others for output. See the [guide](/oss/langgraph/use-graph-api#define-input-and-output-schemas) for more information. ::: :::js @@ -197,7 +201,19 @@ There are two subtle and important points to note here: 1. We pass `state: InputState` as the input schema to `node_1`. But, we write out to `foo`, a channel in `OverallState`. How can we write out to a state channel that is not included in the input schema? This is because a node _can write to any state channel in the graph state._ The graph state is the union of the state channels defined at initialization, which includes `OverallState` and the filters `InputState` and `OutputState`. -2. We initialize the graph with `StateGraph(OverallState,input_schema=InputState,output_schema=OutputState)`. So, how can we write to `PrivateState` in `node_2`? How does the graph gain access to this schema if it was not passed in the `StateGraph` initialization? We can do this because _nodes can also declare additional state channels_ as long as the state schema definition exists. In this case, the `PrivateState` schema is defined, so we can add `bar` as a new state channel in the graph and write to it. +2. We initialize the graph with: + + ```python + StateGraph( + OverallState, + input_schema=InputState, + output_schema=OutputState + ) + ``` + + So, how can we write to `PrivateState` in `node_2`? How does the graph gain access to this schema if it was not passed in the `StateGraph` initialization? + + We can do this because `_nodes` can also declare additional state `channels_` as long as the state schema definition exists. In this case, the `PrivateState` schema is defined, so we can add `bar` as a new state channel in the graph and write to it. ::: :::js @@ -215,11 +231,9 @@ Reducers are key to understanding how updates from nodes are applied to the `Sta These two examples show how to use the default reducer: -**Example A:** - :::python -```python +```python Example A from typing_extensions import TypedDict class State(TypedDict): @@ -231,7 +245,7 @@ class State(TypedDict): :::js -```typescript +```typescript Example A const State = z.object({ foo: z.number(), bar: z.array(z.string()), @@ -250,11 +264,9 @@ In this example, no reducer functions are specified for any key. Let's assume th `{ foo: 1, bar: ["hi"] }`. Let's then assume the first `Node` returns `{ foo: 2 }`. This is treated as an update to the state. Notice that the `Node` does not need to return the whole `State` schema - just an update. After applying this update, the `State` would then be `{ foo: 2, bar: ["hi"] }`. If the second node returns `{ bar: ["bye"] }` then the `State` would then be `{ foo: 2, bar: ["bye"] }` ::: -**Example B:** - :::python -```python +```python Example B from typing import Annotated from typing_extensions import TypedDict from operator import add @@ -269,7 +281,7 @@ In this example, we've used the `Annotated` type to specify a reducer function ( :::js -```typescript +```typescript Example B import * as z from "zod"; import { registry } from "@langchain/langgraph/zod"; @@ -298,13 +310,9 @@ In some cases, you may want to bypass a reducer and directly overwrite a state v #### Why use messages? -:::python -Most modern LLM providers have a chat model interface that accepts a list of messages as input. LangChain's [`ChatModel`](https://python.langchain.com/docs/concepts/#chat-models) in particular accepts a list of `Message` objects as inputs. These messages come in a variety of forms such as @[`HumanMessage`] (user input) or @[`AIMessage`] (LLM response). To read more about what message objects are, please refer to [this](https://python.langchain.com/docs/concepts/#messages) conceptual guide. -::: +Most modern LLM providers have a chat model interface that accepts a list of messages as input. LangChain's [chat model interface](/oss/langchain/models) in particular accepts a list of message objects as inputs. These messages come in a variety of forms such as @[`HumanMessage`] (user input) or @[`AIMessage`] (LLM response). -:::js -Most modern LLM providers have a chat model interface that accepts a list of messages as input. LangChain's [`ChatModel`](https://js.langchain.com/docs/concepts/#chat-models) in particular accepts a list of `Message` objects as inputs. These messages come in a variety of forms such as @[`HumanMessage`] (user input) or @[`AIMessage`] (LLM response). To read more about what message objects are, please refer to [this](https://js.langchain.com/docs/concepts/#messages) conceptual guide. -::: +To read more about what message objects are, please refer to the [Messages conceptual guide](/oss/langchain/messages). #### Using Messages in your Graph @@ -323,7 +331,9 @@ However, you might also want to manually update messages in your graph state (e. #### Serialization :::python -In addition to keeping track of message IDs, the @[`add_messages`] function will also try to deserialize messages into LangChain `Message` objects whenever a state update is received on the `messages` channel. See more information on LangChain serialization/deserialization [here](https://python.langchain.com/docs/how_to/serialization/). This allows sending graph inputs / state updates in the following format: +In addition to keeping track of message IDs, the @[`add_messages`] function will also try to deserialize messages into LangChain `Message` objects whenever a state update is received on the `messages` channel. + +See more information on LangChain serialization/deserialization [here](https://python.langchain.com/docs/how_to/serialization/). This allows sending graph inputs / state updates in the following format: ```python # this is supported @@ -333,7 +343,9 @@ In addition to keeping track of message IDs, the @[`add_messages`] function will {"messages": [{"type": "human", "content": "message"}]} ``` -Since the state updates are always deserialized into LangChain `Messages` when using @[`add_messages`], you should use dot notation to access message attributes, like `state["messages"][-1].content`. Below is an example of a graph that uses @[`add_messages`] as its reducer function. +Since the state updates are always deserialized into LangChain `Messages` when using @[`add_messages`], you should use dot notation to access message attributes, like `state["messages"][-1].content`. + +Below is an example of a graph that uses @[`add_messages`] as its reducer function. ```python from langchain.messages import AnyMessage @@ -413,9 +425,9 @@ class State(MessagesState): In LangGraph, nodes are Python functions (either synchronous or asynchronous) that accept the following arguments: -1. `state`: The [state](#state) of the graph -2. `config`: A @[`RunnableConfig`] object that contains configuration information like `thread_id` and tracing information like `tags` -3. `runtime`: A `Runtime` object that contains [runtime `context`](#runtime-context) and other information like `store` and `stream_writer` +1. `state` – The [state](#state) of the graph +2. `config` – A @[`RunnableConfig`] object that contains configuration information like `thread_id` and tracing information like `tags` +3. `runtime` – A `Runtime` object that contains [runtime `context`](#runtime-context) and other information like `store` and `stream_writer` Similar to `NetworkX`, you add these nodes to a graph using the @[`add_node`] method: @@ -461,8 +473,8 @@ builder.add_node("node_with_config", node_with_config) In LangGraph, nodes are typically functions (sync or async) that accept the following arguments: -1. `state`: The [state](#state) of the graph -2. `config`: A @[`RunnableConfig`] object that contains configuration information like `thread_id` and tracing information like `tags` +1. `state` – The [state](#state) of the graph +2. `config` – A @[`RunnableConfig`] object that contains configuration information like `thread_id` and tracing information like `tags` You can add nodes to a graph using the `addNode` method. @@ -489,7 +501,7 @@ const builder = new StateGraph(State); ::: -Behind the scenes, functions are converted to [RunnableLambda](https://python.langchain.com/api_reference/core/runnables/langchain_core.runnables.base.RunnableLambda.html)s, which add batch and async support to your function, along with native tracing and debugging. +Behind the scenes, functions are converted to [`RunnableLambda`](https://python.langchain.com/api_reference/core/runnables/langchain_core.runnables.base.RunnableLambda.html), which add batch and async support to your function, along with native tracing and debugging. If you add a node to a graph without specifying a name, it will be given a default name equivalent to the function name. @@ -659,7 +671,7 @@ Edges define how the logic is routed and how the graph decides to stop. This is - Entry Point: Which node to call first when user input arrives. - Conditional Entry Point: Call a function to determine which node(s) to call first when user input arrives. -A node can have MULTIPLE outgoing edges. If a node has multiple out-going edges, **all** of those destination nodes will be executed in parallel as a part of the next superstep. +A node can have multiple outgoing edges. If a node has multiple outgoing edges, **all** of those destination nodes will be executed in parallel as a part of the next superstep. ### Normal Edges @@ -730,7 +742,7 @@ Use [`Command`](#command) instead of conditional edges if you want to combine st -### Entry Point +### Entry point :::python The entry point is the first node(s) that are run when the graph starts. You can use the @[`add_edge`] method from the virtual @[`START`][START] node to the first node to execute to specify where to enter the graph. @@ -754,7 +766,7 @@ graph.addEdge(START, "nodeA"); ::: -### Conditional Entry Point +### Conditional entry point :::python A conditional entry point lets you start at different nodes depending on custom logic. You can use @[`add_conditional_edges`] from the virtual @[`START`] node to accomplish this. @@ -996,7 +1008,7 @@ Refer to [this guide](/oss/langgraph/use-graph-api#use-inside-tools) for detail. @[`Command`] is an important part of human-in-the-loop workflows: when using `interrupt()` to collect user input, @[`Command`] is then used to supply the input and resume execution via `new Command({ resume: "User input" })`. Check out the [human-in-the-loop conceptual guide](/oss/langgraph/interrupts) for more information. ::: -## Graph Migrations +## Graph migrations LangGraph can easily handle migrations of graph definitions (nodes, edges, and state) even when using a checkpointer to track state. @@ -1006,7 +1018,7 @@ LangGraph can easily handle migrations of graph definitions (nodes, edges, and s - State keys that are renamed lose their saved state in existing threads - State keys whose types change in incompatible ways could currently cause issues in threads with state from before the change -- if this is a blocker please reach out and we can prioritize a solution. -## Runtime Context +## Runtime context :::python @@ -1097,7 +1109,7 @@ graph.addNode("myNode", (state, runtime) => { ::: -### Recursion Limit +### Recursion limit :::python The recursion limit sets the maximum number of [super-steps](#graphs) the graph can execute during a single execution. Once the limit is reached, LangGraph will raise `GraphRecursionError`. By default this value is set to 25 steps. The recursion limit can be set on any graph at runtime, and is passed to `invoke`/`stream` via the config dictionary. Importantly, `recursion_limit` is a standalone `config` key and should not be passed inside the `configurable` key as all other user-defined configuration. See the example below: diff --git a/src/oss/langgraph/use-graph-api.mdx b/src/oss/langgraph/use-graph-api.mdx index 9795e16585..26f853f16e 100644 --- a/src/oss/langgraph/use-graph-api.mdx +++ b/src/oss/langgraph/use-graph-api.mdx @@ -35,7 +35,8 @@ npm install @langchain/langgraph **Set up LangSmith for better debugging** -Sign up for [LangSmith](https://smith.langchain.com) to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph β€” read more about how to get started in the [docs](https://docs.smith.langchain.com). + +Sign up for [LangSmith](https://smith.langchain.com) to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph β€” read more about how to get started in the [docs](/langsmith/observability). ## Define and update state diff --git a/src/oss/python/integrations/chat/google_generative_ai.mdx b/src/oss/python/integrations/chat/google_generative_ai.mdx index c79d27e205..be39234cbc 100644 --- a/src/oss/python/integrations/chat/google_generative_ai.mdx +++ b/src/oss/python/integrations/chat/google_generative_ai.mdx @@ -209,14 +209,17 @@ print(f"Response for video: {response.content}") ### Image generation -Certain models (such as `gemini-2.5-flash-image`) can generate text and images inline. You need to specify the desired `response_modalities`. See more information on the [Gemini API docs](https://ai.google.dev/gemini-api/docs/image-generation) for details. +Certain models (such as `gemini-2.5-flash-image`) can generate text and images inline. You need to specify the desired `response_modalities`. + +See more information on the [Gemini API docs](https://ai.google.dev/gemini-api/docs/image-generation) for details. ```python +# Running in a Jupyter notebook environment import base64 from IPython.display import Image, display from langchain.messages import AIMessage -from langchain_google_genai import ChatGoogleGenerativeAI +from langchain_google_genai import ChatGoogleGenerativeAI, Modality llm = ChatGoogleGenerativeAI(model="models/gemini-2.5-flash-image") @@ -227,7 +230,7 @@ message = { response = llm.invoke( [message], - generation_config=dict(response_modalities=["TEXT", "IMAGE"]), + response_modalities=[Modality.TEXT, Modality.IMAGE], ) diff --git a/src/oss/python/integrations/chat/index.mdx b/src/oss/python/integrations/chat/index.mdx index 11928ce92b..65d27f9ca1 100644 --- a/src/oss/python/integrations/chat/index.mdx +++ b/src/oss/python/integrations/chat/index.mdx @@ -3,35 +3,35 @@ title: "Chat models" mode: wide --- -[Chat models](/oss/langchain/models) are language models that use a sequence of [messages](/oss/langchain/messages) as inputs and return messages as outputs (as opposed to traditional, plaintext LLMs). +[Chat models](/oss/langchain/models) are language models that use a sequence of [messages](/oss/langchain/messages) as inputs and return messages as outputs (as opposed to traditional, plaintext LLMs). ## Featured providers - **While all these LangChain classes support the indicated advanced feature**, you may have to open the provider-specific documentation to learn which hosted models or backends support the feature. + **While these LangChain classes support the indicated advanced feature**, you may need to refer to provider-specific documentation to learn which hosted models or backends support the feature. -| Provider | [Tool calling](/oss/langchain/tools) | [Structured output](/oss/langchain/structured-output/) | JSON mode | Local | [Multimodal](/oss/langchain/messages#multimodal) | Package | -|----------|------------|-------------------|-----------|-------|------------|---------| -| [`ChatAnthropic`](/oss/integrations/chat/anthropic) | βœ… | βœ… | ❌ | ❌ | βœ… | [`langchain-anthropic`](https://reference.langchain.com/python/integrations/langchain_anthropic/) | -| [`ChatOpenAI`](/oss/integrations/chat/openai) | βœ… | βœ… | βœ… | ❌ | βœ… | [`langchain-openai`](https://reference.langchain.com/python/integrations/langchain_openai/ChatOpenAI/) | -| [`AzureChatOpenAI`](/oss/integrations/chat/azure_chat_openai) | βœ… | βœ… | βœ… | ❌ | βœ… | [`langchain-openai`](https://reference.langchain.com/python/integrations/langchain_openai/AzureChatOpenAI/) | -| [`ChatVertexAI`](/oss/integrations/chat/google_vertex_ai_palm) | βœ… | βœ… | ❌ | ❌ | βœ… | [`langchain-google-vertexai`](https://reference.langchain.com/python/integrations/langchain_google_vertexai/) | -| [`ChatGoogleGenerativeAI`](/oss/integrations/chat/google_generative_ai) | βœ… | βœ… | ❌ | ❌ | βœ… | [`langchain-google-genai`](https://reference.langchain.com/python/integrations/langchain_google_genai/) | -| [`ChatGroq`](/oss/integrations/chat/groq) | βœ… | βœ… | βœ… | ❌ | ❌ | [`langchain-groq`](https://reference.langchain.com/python/integrations/langchain_groq/) | -| [`ChatBedrock`](/oss/integrations/chat/bedrock) | βœ… | βœ… | ❌ | ❌ | ❌ | [`langchain-aws`](https://reference.langchain.com/python/integrations/langchain_aws/) | -| [`ChatHuggingFace`](/oss/integrations/chat/huggingface) | βœ… | βœ… | ❌ | βœ… | ❌ | [`langchain-huggingface`](https://reference.langchain.com/python/integrations/langchain_huggingface/) | -| [`ChatOllama`](/oss/integrations/chat/ollama) | βœ… | βœ… | βœ… | βœ… | ❌ | [`langchain-ollama`](https://reference.langchain.com/python/integrations/langchain_ollama/) | -| [`ChatWatsonx`](/oss/integrations/chat/ibm_watsonx) | βœ… | βœ… | βœ… | ❌ | βœ… | [`langchain-ibm`](https://reference.langchain.com/python/integrations/langchain_ibm/) | -| [`ChatXAI`](/oss/integrations/chat/xai) | βœ… | βœ… | ❌ | ❌ | ❌ | [`langchain-xai`](https://reference.langchain.com/python/integrations/langchain_xai/) | -| [`ChatNVIDIA`](/oss/integrations/chat/nvidia_ai_endpoints) | βœ… | βœ… | βœ… | βœ… | βœ… | [`langchain-nvidia-ai-endpoints`](https://reference.langchain.com/python/integrations/langchain_nvidia_ai_endpoints/) | -| [`ChatCohere`](/oss/integrations/chat/cohere) | βœ… | βœ… | ❌ | ❌ | ❌ | [`langchain-cohere`](https://reference.langchain.com/python/integrations/langchain_cohere/) | -| [`ChatMistralAI`](/oss/integrations/chat/mistralai) | βœ… | βœ… | ❌ | ❌ | ❌ | [`langchain-mistralai`](https://reference.langchain.com/python/integrations/langchain_mistralai/) | -| [`ChatTogether`](/oss/integrations/chat/together) | βœ… | βœ… | βœ… | ❌ | ❌ | [`langchain-together`](https://reference.langchain.com/python/integrations/langchain_together/) | -| [`ChatFireworks`](/oss/integrations/chat/fireworks) | βœ… | βœ… | βœ… | ❌ | ❌ | [`langchain-fireworks`](https://reference.langchain.com/python/integrations/langchain_fireworks/) | -| [`ChatLlamaCpp`](/oss/integrations/chat/llamacpp) | βœ… | βœ… | ❌ | βœ… | ❌ | [`langchain-community`](https://python.langchain.com/api_reference/community/chat_models/langchain_community.chat_models.llamacpp.ChatLlamaCpp.html) | -| [`ChatDatabricks`](/oss/integrations/chat/databricks) | βœ… | βœ… | ❌ | ❌ | ❌ | [`databricks-langchain`](https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_langchain.html#databricks_langchain.ChatDatabricks) | -| [`ChatPerplexity`](/oss/integrations/chat/perplexity) | ❌ | βœ… | βœ… | ❌ | βœ… | [`langchain-perplexity`](https://reference.langchain.com/python/integrations/langchain_perplexity/) | +| Model | [Tool calling](/oss/langchain/tools) | [Structured output](/oss/langchain/structured-output/) | JSON mode | Local | [Multimodal](/oss/langchain/messages#multimodal) | +|-|-|-|-|-|-| +| [`ChatAnthropic`](/oss/integrations/chat/anthropic) | βœ… | βœ… | ❌ | ❌ | βœ… | +| [`ChatOpenAI`](/oss/integrations/chat/openai) | βœ… | βœ… | βœ… | ❌ | βœ… | +| [`AzureChatOpenAI`](/oss/integrations/chat/azure_chat_openai) | βœ… | βœ… | βœ… | ❌ | βœ… | +| [`ChatVertexAI`](/oss/integrations/chat/google_vertex_ai_palm) | βœ… | βœ… | ❌ | ❌ | βœ… | +| [`ChatGoogleGenerativeAI`](/oss/integrations/chat/google_generative_ai) | βœ… | βœ… | ❌ | ❌ | βœ… | +| [`ChatGroq`](/oss/integrations/chat/groq) | βœ… | βœ… | βœ… | ❌ | ❌ | +| [`ChatBedrock`](/oss/integrations/chat/bedrock) | βœ… | βœ… | ❌ | ❌ | ❌ | +| [`ChatHuggingFace`](/oss/integrations/chat/huggingface) | βœ… | βœ… | ❌ | βœ… | ❌ | +| [`ChatOllama`](/oss/integrations/chat/ollama) | βœ… | βœ… | βœ… | βœ… | ❌ | +| [`ChatWatsonx`](/oss/integrations/chat/ibm_watsonx) | βœ… | βœ… | βœ… | ❌ | βœ… | +| [`ChatXAI`](/oss/integrations/chat/xai) | βœ… | βœ… | ❌ | ❌ | ❌ | +| [`ChatNVIDIA`](/oss/integrations/chat/nvidia_ai_endpoints) | βœ… | βœ… | βœ… | βœ… | βœ… | +| [`ChatCohere`](/oss/integrations/chat/cohere) | βœ… | βœ… | ❌ | ❌ | ❌ | +| [`ChatMistralAI`](/oss/integrations/chat/mistralai) | βœ… | βœ… | ❌ | ❌ | ❌ | +| [`ChatTogether`](/oss/integrations/chat/together) | βœ… | βœ… | βœ… | ❌ | ❌ | +| [`ChatFireworks`](/oss/integrations/chat/fireworks) | βœ… | βœ… | βœ… | ❌ | ❌ | +| [`ChatLlamaCpp`](/oss/integrations/chat/llamacpp) | βœ… | βœ… | ❌ | βœ… | ❌ | +| [`ChatDatabricks`](/oss/integrations/chat/databricks) | βœ… | βœ… | ❌ | ❌ | ❌ | +| [`ChatPerplexity`](/oss/integrations/chat/perplexity) | ❌ | βœ… | βœ… | ❌ | βœ… | ## Chat Completions API diff --git a/src/oss/python/integrations/text_embedding/fake.mdx b/src/oss/python/integrations/text_embedding/fake.mdx index 324d7d0a70..6c64a212c8 100644 --- a/src/oss/python/integrations/text_embedding/fake.mdx +++ b/src/oss/python/integrations/text_embedding/fake.mdx @@ -1,5 +1,5 @@ --- -title: Fake Embeddings +title: FakeEmbeddings --- LangChain also provides a fake embedding class. You can use this to test your pipelines. diff --git a/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx b/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx index 703b0e7f25..ea025d1dc3 100644 --- a/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx +++ b/src/oss/python/integrations/text_embedding/ibm_watsonx.mdx @@ -1,5 +1,5 @@ --- -title: IBM watsonx.ai +title: WatsonxEmbeddings --- >`WatsonxEmbeddings` is a wrapper for IBM [watsonx.ai](https://www.ibm.com/products/watsonx-ai) foundation models. diff --git a/src/oss/python/integrations/text_embedding/index.mdx b/src/oss/python/integrations/text_embedding/index.mdx index 339fabf474..15dc7fcf12 100644 --- a/src/oss/python/integrations/text_embedding/index.mdx +++ b/src/oss/python/integrations/text_embedding/index.mdx @@ -6,6 +6,8 @@ title: "Embedding models" This overview covers **text-based embedding models**. LangChain does not currently support multimodal embeddings. + +See [top embedding models](#top-integrations). Embedding models transform raw textβ€”such as a sentence, paragraph, or tweetβ€”into a fixed-length vector of numbers that captures its **semantic meaning**. These vectors allow machines to compare and search text based on meaning rather than exact words. @@ -53,22 +55,22 @@ The interface allows queries and documents to be embedded with different strateg ## Top integrations -| Provider | Package | +| Model | Package | |------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [OpenAI](/oss/integrations/text_embedding/openai) | [`langchain-openai`](https://python.langchain.com/api_reference/openai/chat_models/langchain_openai.chat_models.base.ChatOpenAI.html) | -| [OpenAI on Azure](/oss/integrations/text_embedding/azure_openai) | [`langchain-openai`](https://python.langchain.com/api_reference/openai/embeddings/langchain_openai.embeddings.azure.AzureOpenAIEmbeddings.html) | -| [Google Gemini](/oss/integrations/text_embedding/google_generative_ai) | [`langchain-google-genai`](https://python.langchain.com/api_reference/google_genai/embeddings/langchain_google_genai.embeddings.GoogleGenerativeAIEmbeddings.html) | -| [Ollama](/oss/integrations/text_embedding/ollama) | [`langchain-ollama`](https://python.langchain.com/api_reference/ollama/embeddings/langchain_ollama.embeddings.OllamaEmbeddings.html) | -| [Together](/oss/integrations/text_embedding/together) | [`langchain-together`](https://python.langchain.com/api_reference/together/embeddings/langchain_together.embeddings.TogetherEmbeddings.html) | -| [Fireworks](/oss/integrations/text_embedding/fireworks) | [`langchain-fireworks`](https://python.langchain.com/api_reference/fireworks/embeddings/langchain_fireworks.embeddings.FireworksEmbeddings.html) | -| [MistralAI](/oss/integrations/text_embedding/mistralai) | [`langchain-mistralai`](https://python.langchain.com/api_reference/mistralai/embeddings/langchain_mistralai.embeddings.MistralAIEmbeddings.html) | -| [Cohere](/oss/integrations/text_embedding/cohere) | [`langchain-cohere`](https://python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html) | -| [Nomic](/oss/integrations/text_embedding/nomic) | [`langchain-nomic`](https://python.langchain.com/api_reference/nomic/embeddings/langchain_nomic.embeddings.NomicEmbeddings.html) | -| [Fake](/oss/integrations/text_embedding/fake) | [`langchain-core`](https://python.langchain.com/api_reference/core/embeddings/langchain_core.embeddings.fake.FakeEmbeddings.html) | -| [Databricks](/oss/integrations/text_embedding/databricks) | [`databricks-langchain`](https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_langchain.html#databricks_langchain.DatabricksEmbeddings) | -| [IBM](/oss/integrations/text_embedding/ibm_watsonx) | [`langchain-ibm`](https://python.langchain.com/api_reference/ibm/embeddings/langchain_ibm.embeddings.WatsonxEmbeddings.html) | -| [NVIDIA](/oss/integrations/text_embedding/nvidia_ai_endpoints) | [`langchain-nvidia`](https://python.langchain.com/api_reference/nvidia_ai_endpoints/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html) | -| [AI/ML API](/oss/integrations/text_embedding/aimlapi) | [`langchain-aimlapi`](https://python.langchain.com/api_reference/aimlapi/embeddings/langchain_aimlapi.embeddings.AimlapiEmbeddings.html) | +| [`OpenAIEmbeddings`](/oss/integrations/text_embedding/openai) | [`langchain-openai`](https://python.langchain.com/api_reference/openai/chat_models/langchain_openai.chat_models.base.ChatOpenAI.html) | +| [`AzureOpenAIEmbeddings`](/oss/integrations/text_embedding/azure_openai) | [`langchain-openai`](https://python.langchain.com/api_reference/openai/embeddings/langchain_openai.embeddings.azure.AzureOpenAIEmbeddings.html) | +| [`GoogleGenerativeAIEmbeddings`](/oss/integrations/text_embedding/google_generative_ai) | [`langchain-google-genai`](https://python.langchain.com/api_reference/google_genai/embeddings/langchain_google_genai.embeddings.GoogleGenerativeAIEmbeddings.html) | +| [`OllamaEmbeddings`](/oss/integrations/text_embedding/ollama) | [`langchain-ollama`](https://python.langchain.com/api_reference/ollama/embeddings/langchain_ollama.embeddings.OllamaEmbeddings.html) | +| [`TogetherEmbeddings`](/oss/integrations/text_embedding/together) | [`langchain-together`](https://python.langchain.com/api_reference/together/embeddings/langchain_together.embeddings.TogetherEmbeddings.html) | +| [`FireworksEmbeddings`](/oss/integrations/text_embedding/fireworks) | [`langchain-fireworks`](https://python.langchain.com/api_reference/fireworks/embeddings/langchain_fireworks.embeddings.FireworksEmbeddings.html) | +| [`MistralAIEmbeddings`](/oss/integrations/text_embedding/mistralai) | [`langchain-mistralai`](https://python.langchain.com/api_reference/mistralai/embeddings/langchain_mistralai.embeddings.MistralAIEmbeddings.html) | +| [`CohereEmbeddings`](/oss/integrations/text_embedding/cohere) | [`langchain-cohere`](https://python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html) | +| [`NomicEmbeddings`](/oss/integrations/text_embedding/nomic) | [`langchain-nomic`](https://python.langchain.com/api_reference/nomic/embeddings/langchain_nomic.embeddings.NomicEmbeddings.html) | +| [`FakeEmbeddings`](/oss/integrations/text_embedding/fake) | [`langchain-core`](https://python.langchain.com/api_reference/core/embeddings/langchain_core.embeddings.fake.FakeEmbeddings.html) | +| [`DatabricksEmbeddings`](/oss/integrations/text_embedding/databricks) | [`databricks-langchain`](https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_langchain.html#databricks_langchain.DatabricksEmbeddings) | +| [`WatsonxEmbeddings`](/oss/integrations/text_embedding/ibm_watsonx) | [`langchain-ibm`](https://python.langchain.com/api_reference/ibm/embeddings/langchain_ibm.embeddings.WatsonxEmbeddings.html) | +| [`NVIDIAEmbeddings`](/oss/integrations/text_embedding/nvidia_ai_endpoints) | [`langchain-nvidia`](https://python.langchain.com/api_reference/nvidia_ai_endpoints/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html) | +| [`AimlapiEmbeddings`](/oss/integrations/text_embedding/aimlapi) | [`langchain-aimlapi`](https://python.langchain.com/api_reference/aimlapi/embeddings/langchain_aimlapi.embeddings.AimlapiEmbeddings.html) | ## Caching diff --git a/src/oss/python/integrations/text_embedding/mistralai.mdx b/src/oss/python/integrations/text_embedding/mistralai.mdx index 899dede853..da434d9d73 100644 --- a/src/oss/python/integrations/text_embedding/mistralai.mdx +++ b/src/oss/python/integrations/text_embedding/mistralai.mdx @@ -1,5 +1,5 @@ --- -title: MistralAI +title: MistralAIEmbeddings --- This will help you get started with MistralAI embedding models using LangChain. For detailed documentation on `MistralAIEmbeddings` features and configuration options, please refer to the [API reference](https://python.langchain.com/api_reference/mistralai/embeddings/langchain_mistralai.embeddings.MistralAIEmbeddings.html). diff --git a/src/oss/python/integrations/text_embedding/nomic.mdx b/src/oss/python/integrations/text_embedding/nomic.mdx index 0c007d8dbd..dd511861f8 100644 --- a/src/oss/python/integrations/text_embedding/nomic.mdx +++ b/src/oss/python/integrations/text_embedding/nomic.mdx @@ -1,5 +1,5 @@ --- -title: Nomic +title: NomicEmbeddings --- This will help you get started with Nomic embedding models using LangChain. For detailed documentation on `NomicEmbeddings` features and configuration options, please refer to the [API reference](https://python.langchain.com/api_reference/nomic/embeddings/langchain_nomic.embeddings.NomicEmbeddings.html). diff --git a/src/oss/python/integrations/text_embedding/nvidia_ai_endpoints.mdx b/src/oss/python/integrations/text_embedding/nvidia_ai_endpoints.mdx index 240e72f8c2..1a0780956f 100644 --- a/src/oss/python/integrations/text_embedding/nvidia_ai_endpoints.mdx +++ b/src/oss/python/integrations/text_embedding/nvidia_ai_endpoints.mdx @@ -1,5 +1,5 @@ --- -title: NVIDIA NIMs +title: NVIDIAEmbeddings --- The `langchain-nvidia-ai-endpoints` package contains LangChain integrations building applications with models on