langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.97k stars 14.93k forks source link

The gradient option in SemanticChunker (langchain_experimental) is not available when installing from pip #23340

Closed da7a90-backup closed 1 day ago

da7a90-backup commented 3 months ago

Checked other resources

Example Code

text_splitter = SemanticChunker(HuggingFaceEmbeddings(), breakpoint_threshold_type="gradient")

Error Message and Stack Trace (if applicable)

 File "/Users/guertethiaf/Documents/jamstack/muniai/anabondsbackend/main.py", line 33, in chunk_text_semantically
    text_splitter = SemanticChunker(HuggingFaceEmbeddings(), breakpoint_threshold_type="gradient")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_experimental/text_splitter.py", line 124, in __init__
    self.breakpoint_threshold_amount = BREAKPOINT_DEFAULTS[
                                       ^^^^^^^^^^^^^^^^^^^^
KeyError: 'gradient'

Description

When trying to use the SemanticChunker with 'gradient' as a breakpoint_threshold_type I noticed it always gave me a key error. 

After checking /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_experimental/text_splitter.py I noticed the option wasn't present.

It's present in the repository and was merged I think a week ago.

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:27 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8103 Python Version: 3.12.4 (v3.12.4:8e8a4baf65, Jun 6 2024, 17:33:18) [Clang 13.0.0 (clang-1300.0.29.30)]

Package Information

langchain_core: 0.2.9 langchain: 0.2.5 langchain_community: 0.2.5 langsmith: 0.1.81 langchain_experimental: 0.0.61 langchain_huggingface: 0.0.3 langchain_openai: 0.1.9 langchain_text_splitters: 0.2.1

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langgraph langserve

keenborder786 commented 3 months ago

Please update to latest version as this issue has been resolved. See this line