Skip to content

Commit 8d3c457

Browse files
RoyBAhayescode
andauthored
fix: Update LangChain imports for v1.x compatibility (#2700)
Fixes #2607 - Replace deprecated `langchain.*` imports with `langchain_core.*` - Updates imports for Run, dumps, and BaseMessage - Resolves ModuleNotFoundError when using LangchainCallbackHandler with LangChain v1.x **Note:** This PR uses the correct `langchain_core.tracers.schemas.Run` import, which is part of LangChain's core tracer interface. Another PR (#2695) uses `langsmith.schemas.Run`, but `langchain_core` is the proper source as it contains the base abstractions that LangChain's callback system is built on, while `langsmith` is specifically for the LangSmith monitoring service integration. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Updated LangChain imports to use langchain_core so the LangchainCallbackHandler works with LangChain v1.x. Fixes #2607 by resolving ModuleNotFoundError from deprecated langchain.* imports (dumps, BaseMessage, Run). <sup>Written for commit 7fed064. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> Co-authored-by: Josh Hayes <[email protected]>
1 parent 5b0abea commit 8d3c457

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

backend/chainlit/langchain/callbacks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from uuid import UUID
44

55
import pydantic
6-
from langchain.callbacks.tracers.schemas import Run
7-
from langchain.load.dump import dumps
8-
from langchain.schema import BaseMessage
6+
from langchain_core.load import dumps
7+
from langchain_core.messages import BaseMessage
98
from langchain_core.outputs import ChatGenerationChunk, GenerationChunk
109
from langchain_core.tracers.base import AsyncBaseTracer
10+
from langchain_core.tracers.schemas import Run
1111
from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
1212
from literalai.observability.step import TrueStepType
1313

0 commit comments

Comments
 (0)