Skip to content

Commit 5bf6f6f

Browse files
authored
oss(ps): import from langchain instead of langchain_core where possible (#1442)
These are re-exports In attempt to keep it consistent & following community feedback https://www.reddit.com/r/LangChain/comments/1oxtc9o/comment/nozrimm/
1 parent 4de7234 commit 5bf6f6f

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

src/oss/deepagents/human-in-the-loop.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The `interrupt_on` parameter accepts a dictionary mapping tool names to interrup
1515

1616
:::python
1717
```python
18-
from langchain_core.tools import tool
18+
from langchain.tools import tool
1919
from deepagents import create_deep_agent
2020
from langgraph.checkpoint.memory import MemorySaver
2121

src/oss/deepagents/middleware.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ The subagents middleware allows you to supply subagents through a `task` tool.
186186

187187
:::python
188188
```python
189-
from langchain_core.tools import tool
189+
from langchain.tools import tool
190190
from langchain.agents import create_agent
191191
from deepagents.middleware.subagents import SubAgentMiddleware
192192

src/oss/langchain/agents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ To customize how tool errors are handled, use the @[`@wrap_tool_call`] decorator
303303
```python wrap
304304
from langchain.agents import create_agent
305305
from langchain.agents.middleware import wrap_tool_call
306-
from langchain_core.messages import ToolMessage
306+
from langchain.messages import ToolMessage
307307

308308

309309
@wrap_tool_call

src/oss/langchain/guardrails.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ Use "after agent" hooks to validate final outputs once before returning to the u
454454
```python title="Class syntax"
455455
from langchain.agents.middleware import AgentMiddleware, AgentState, hook_config
456456
from langgraph.runtime import Runtime
457-
from langchain_core.messages import AIMessage
457+
from langchain.messages import AIMessage
458458
from langchain.chat_models import init_chat_model
459459
from typing import Any
460460

@@ -511,7 +511,7 @@ result = agent.invoke({
511511
```python title="Decorator syntax"
512512
from langchain.agents.middleware import after_agent, AgentState, hook_config
513513
from langgraph.runtime import Runtime
514-
from langchain_core.messages import AIMessage
514+
from langchain.messages import AIMessage
515515
from langchain.chat_models import init_chat_model
516516
from typing import Any
517517

src/oss/langchain/middleware/built-in.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ The middleware uses an LLM to generate plausible responses for tool calls instea
14731473
```python
14741474
from langchain.agents import create_agent
14751475
from langchain.agents.middleware import LLMToolEmulator
1476-
from langchain_core.tools import tool
1476+
from langchain.tools import tool
14771477

14781478

14791479
@tool
@@ -1974,7 +1974,7 @@ The middleware adds two search tools to agents:
19741974
```python
19751975
from langchain.agents import create_agent
19761976
from langchain.agents.middleware import FilesystemFileSearchMiddleware
1977-
from langchain_core.messages import HumanMessage
1977+
from langchain.messages import HumanMessage
19781978

19791979

19801980
agent = create_agent(
@@ -2113,7 +2113,7 @@ The middleware caches content up to and including the latest message in each req
21132113
from langchain_anthropic import ChatAnthropic
21142114
from langchain_anthropic.middleware import AnthropicPromptCachingMiddleware
21152115
from langchain.agents import create_agent
2116-
from langchain_core.messages import HumanMessage
2116+
from langchain.messages import HumanMessage
21172117

21182118

21192119
LONG_PROMPT = """

src/oss/langchain/middleware/custom.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ const dynamicModelMiddleware = createMiddleware({
736736
```python
737737
from langchain.agents.middleware import wrap_tool_call
738738
from langchain.tools.tool_node import ToolCallRequest
739-
from langchain_core.messages import ToolMessage
739+
from langchain.messages import ToolMessage
740740
from langgraph.types import Command
741741
from typing import Callable
742742

@@ -764,7 +764,7 @@ def monitor_tool(
764764
```python
765765
from langchain.tools.tool_node import ToolCallRequest
766766
from langchain.agents.middleware import AgentMiddleware
767-
from langchain_core.messages import ToolMessage
767+
from langchain.messages import ToolMessage
768768
from langgraph.types import Command
769769
from typing import Callable
770770

src/oss/langchain/models.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ response = model.invoke(conversation)
187187
print(response) # AIMessage("J'adore créer des applications.")
188188
```
189189
```python Message objects
190-
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
190+
from langchain.messages import HumanMessage, AIMessage, SystemMessage
191191

192192
conversation = [
193193
SystemMessage("You are a helpful assistant that translates English to French."),

src/oss/langchain/supervisor.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Start by defining the tools that require structured inputs. In real applications
112112

113113
:::python
114114
```python
115-
from langchain_core.tools import tool
115+
from langchain.tools import tool
116116

117117
@tool
118118
def create_calendar_event(
@@ -708,7 +708,7 @@ A supervisor agent coordinates specialized sub-agents (calendar and email)
708708
that are wrapped as tools.
709709
"""
710710

711-
from langchain_core.tools import tool
711+
from langchain.tools import tool
712712
from langchain.agents import create_agent
713713
from langchain.chat_models import init_chat_model
714714

src/oss/langgraph/thinking-in-langgraph.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ We'll implement each node as a simple function. Remember: nodes take state, do w
478478
from langgraph.graph import StateGraph, START, END
479479
from langgraph.types import interrupt, Command, RetryPolicy
480480
from langchain_openai import ChatOpenAI
481-
from langchain_core.messages import HumanMessage
481+
from langchain.messages import HumanMessage
482482

483483
llm = ChatOpenAI(model="gpt-4")
484484

src/oss/python/migrate/langchain-v1.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ from typing_extensions import Annotated
458458
from pydantic import BaseModel
459459
from langgraph.graph import StateGraph
460460
from langgraph.graph.messages import add_messages
461-
from langchain_core.messages import AnyMessage
461+
from langchain.messages import AnyMessage
462462

463463

464464
class AgentState(BaseModel): # [!code highlight]

0 commit comments

Comments
 (0)