题意:错误 'module 'langchain' has no attribute 'verbose'
指的是什么意思?
问题背景:
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:
我对Langchain和Qdrant还算是新手,但我正在构建一个推荐引擎,该引擎基于用户关联的PDF文件内容来推荐用户。我需要处理这些PDF文件并将它们的内容块存储在向量数据库中(我使用的是Qdrant),以便为RAG代理建立上下文。我不确定这个错误是否与某种版本要求有关,因为我之前发现的唯一错误与Langchain 0.1.x之前的版本有关
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.
然而,那个问题已经被关闭了,并且鉴于当前langchain的发布情况,将版本降级到0.1.x以下似乎不太可行,因为我当前环境的大部分依赖都是最新的。
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以及所有对应的langchain第三方库的不同版本。目前,这些是我需求文件(我认为)中的重要部分:
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'
问题解决:
in my case, the code can fix the problem: 在我的情况下,以下代码可以修复问题:
import langchain
langchain.verbose = False
langchain.debug = False
langchain.llm_cache = False