Conversation
Contributor
There was a problem hiding this comment.
Additional Comments (1)
-
pyproject.toml, line 37-38 (link)logic:
langchaindependency removed from[tool.poetry.dependencies]but[tool.poetry.extras]still references it. Users installing withpip install langfuse[langchain]will fail.Add
langchainback as optional dependency:
9 files reviewed, 1 comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Adds Langchain v1.0+ support with version detection and import updates, but has a critical dependency issue in
pyproject.toml.CallbackHandler.pyto support Langchain v1.0+ and v0.x.langchain_core.*instead oflangchain.schema.*andlangchain.callbacks.base.Serializableimport path inserializer.py..invoke()API.pyproject.tomlto requirelangchain >= 1andlanggraph >= 1.langchainremoved from optional dependencies but still referenced in extras, causingpip install langfuse[langchain]to fail.This description was created by
for 85d411b. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Updated On: 2025-10-20 10:03:22 UTC
Summary
Adds Langchain v1.0+ support to the Langfuse Python SDK by implementing version detection and conditional imports in the CallbackHandler, maintaining backward compatibility with Langchain v0.x.
Key Changes
langchain.__version__.startswith("1")check to conditionally import from appropriate moduleslangchain_core.agents,langchain_core.callbacks,langchain_core.documentsinstead oflangchain.schema.*andlangchain.callbacks.baseSerializableimport fromlangchain.load.serializabletolangchain_core.load.serializablelangchain_core.prompts,langchain.messages) and modern API (.invoke()instead of direct call)pyproject.tomlto requirelangchain >= 1andlanggraph >= 1in dev dependencies; bumped minimum Python version to 3.10+Critical Issue Found
BLOCKING BUG:
langchainwas removed from optional dependencies in[tool.poetry.dependencies]but is still referenced in[tool.poetry.extras]. This will causepip install langfuse[langchain]to fail. The dependency must be added back aslangchain = { version = ">=1", optional = true }.Confidence Score: 0/5
langchaindependency was removed from optional dependencies but still referenced in extras, causingpip install langfuse[langchain]to fail. While the code changes for v1 support are well-implemented, this packaging bug is a blocker that will break user installations.Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User participant LangfuseSDK participant CallbackHandler participant Langchain participant LangchainCore User->>LangfuseSDK: pip install langfuse[langchain] LangfuseSDK->>User: Install with langchain dependency User->>CallbackHandler: Import CallbackHandler CallbackHandler->>Langchain: Check langchain.__version__ alt Langchain v1.x Langchain-->>CallbackHandler: Version starts with "1" CallbackHandler->>LangchainCore: Import from langchain_core.agents CallbackHandler->>LangchainCore: Import from langchain_core.callbacks CallbackHandler->>LangchainCore: Import from langchain_core.documents CallbackHandler->>LangchainCore: Import from langchain_core.messages CallbackHandler->>LangchainCore: Import from langchain_core.outputs else Langchain v0.x Langchain-->>CallbackHandler: Version starts with "0" CallbackHandler->>Langchain: Import from langchain.callbacks.base CallbackHandler->>Langchain: Import from langchain.schema.agent CallbackHandler->>Langchain: Import from langchain.schema.document CallbackHandler->>LangchainCore: Import from langchain_core.messages CallbackHandler->>LangchainCore: Import from langchain_core.outputs end CallbackHandler-->>User: Handler ready User->>Langchain: chat.invoke(messages, callbacks=[handler]) Langchain->>CallbackHandler: Trigger callback methods CallbackHandler->>LangfuseSDK: Create spans/generations via OTel LangfuseSDK-->>User: Track LLM operations