langchain-ai / langchain

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

AttributeError: C #17905

Closed rangehow closed 7 months ago

rangehow commented 7 months ago

Checked other resources

Example Code

from langchain_community.document_loaders import JSONLoader

Error Message and Stack Trace (if applicable)

When I want to use 'https://python.langchain.com/docs/integrations/retrievers/bm25', as the snippet from langchain.retrievers import BM25Retriever , an error throwed that hint user to use pip install -U langchain_community. I did it as mentioned. But I found that JSONLoader cannot be load and the error message is very short. I have to dive into the code and found that after langchian_community updated, jsonloader support c language which is a dict contained in langchian without 'c'

LANGUAGE_EXTENSIONS: Dict[str, str] = {
        "py": Language.PYTHON,
        "js": Language.JS,
        "cobol": Language.COBOL,
        "cpp": Language.CPP,
        "cs": Language.CSHARP,
        "rb": Language.RUBY,
        "scala": Language.SCALA,
        "rs": Language.RUST,
        "go": Language.GO,
        "kt": Language.KOTLIN,
        "lua": Language.LUA,
        "pl": Language.PERL,
        "ts": Language.TS,
        "java": Language.JAVA,
    }

so the title issue appear. After update langchain, this issue solved.

Description

I have two suggestion that: 1.Consider updating the outdated BM25 document. 2 The issue caused by inconsistent versions should not be addressed so briefly. Consider providing a more specific prompt or including the appropriate version of LangChain in the requirements of LangChain_Community.

System Info

The issue will appear in langchian 0.1.7 and community 0.0.21 / while 0.1.8+0.0.21 is ok

rocke2020 commented 7 months ago

the same error

urbanscribe commented 7 months ago

same

QuynhTaVo commented 7 months ago

same

gfhayworth commented 7 months ago

changing my import statements resolved the issue.

from langchain.retrievers.ensemble import EnsembleRetriever
from langchain_community.retrievers.bm25 import BM25Retriever

it seems the example https://python.langchain.com/docs/modules/data_connection/retrievers/ensemble needs to be updated with this change

yesidc commented 7 months ago

Updating the package did the trick for me