pythonversion-controlopenai-apilangchainpy-langchain

What does the error 'module 'langchain' has no attribute 'verbose' refer to?


Kind of new to Langchain/Qdrant but I'm building a recommendation engine to recommend users based on the contents of their associated PDF files, and I need to process PDFs and store their chunks in a vector database (I'm using Qdrant) for establishing context for the RAG agent. I don't exactly understand if this error is pertaining to some sort of version requirement, since the only prior error I found had to do with Langchain versions before 0.1.x:

Found this prior issue

However that issue was closed, and downgrading to versions below 0.1.x given the current releases of langchain doesn't seem feasible given what most of my current environment has recent dependencies.

I tried different versions of langchain and different versions all of the corresponding langchain third-party libraries. Currently, these are the important parts of my requirements file (I think):

langchain==0.2.1
langchain-community==0.2.1
langchain-core==0.2.1
langchain-experimental==0.0.59
langchain-openai==0.1.7
langchain-text-splitters==0.2.0
langcodes==3.4.0
langsmith==0.1.57

openai==1.28.1 
python==3.12.3

Looking for some sort of workaround, or a diagnosis as to what may package may be causing the problem. My current program output:

Traceback (most recent call last):
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/main.py", line 28, in <module>
    main()
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/main.py", line 17, in main
    processor = PDFResumeProcessor(openai_api_key)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/gpt_class.py", line 16, in __init__
    self.model = ChatOpenAI(api_key=openai_api_key, temperature=0, model_name='gpt-3.5-turbo-16k-0613')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/.venv/lib/python3.12/site-packages/pydantic/v1/main.py", line 339, in __init__
    values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/.venv/lib/python3.12/site-packages/pydantic/v1/main.py", line 1064, in validate_model
    value = field.get_default()
            ^^^^^^^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/.venv/lib/python3.12/site-packages/pydantic/v1/fields.py", line 437, in get_default
    return smart_deepcopy(self.default) if self.default_factory is None else self.default_factory()
                                                                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/.venv/lib/python3.12/site-packages/langchain_core/language_models/base.py", line 72, in _get_verbosity
    return get_verbose()
           ^^^^^^^^^^^^^
  File "/Users/danielperlov/dperlov/JobsMatch/backend/ml_model/resume_preprocessor/.venv/lib/python3.12/site-packages/langchain_core/globals.py", line 72, in get_verbose
    old_verbose = langchain.verbose
                  ^^^^^^^^^^^^^^^^^
AttributeError: module 'langchain' has no attribute 'verbose'

Solution

  • in my case, the code can fix the problem:

    import langchain
    langchain.verbose = False
    langchain.debug = False
    langchain.llm_cache = False