langchain icon indicating copy to clipboard operation
langchain copied to clipboard

AttributeError: module 'langchain' has no attribute 'verbose'

Open MoAmrYehia opened this issue 1 year ago • 9 comments

System Info

langchain==0.0.157

Who can help?

No response

Information

  • [X] The official example notebooks/scripts
  • [ ] My own modified scripts

Related Components

  • [X] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [X] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

When I try to run llm = OpenAI(temperature=0)

AttributeError                            Traceback (most recent call last)
Cell In[11], line 1
----> 1 llm = OpenAI(temperature=0)
      3 # Initialize a ConversationBufferMemory object to store the chat history
      4 memory = ConversationBufferMemory(memory_key="chat_history") 

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/main.py:339, in pydantic.main.BaseModel.__init__()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/main.py:1066, in pydantic.main.validate_model()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/fields.py:439, in pydantic.fields.ModelField.get_default()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/langchain/llms/base.py:26, in _get_verbosity()
     25 def _get_verbosity() -> bool:
---> 26     return langchain.verbose

AttributeError: module 'langchain' has no attribute 'verbose'

Expected behavior

Don't get the error

MoAmrYehia avatar May 05 '23 09:05 MoAmrYehia

Same issue here with Anaconda in a jupyter notebook on sagemaker, langchain==0.0.158, python3.9, with this simple custom LLM example: https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html

clauslang avatar May 05 '23 13:05 clauslang

Same error here with langchain==0.0.158, python3.9. need to fix it asap.

yinyijie avatar May 05 '23 14:05 yinyijie

Hello, same error with langchain==0.0.159, python 3.9.12

marcelocerchiKiron avatar May 05 '23 17:05 marcelocerchiKiron

Hello, same error with langchain==0.0.158, python 3.9.11

yetilfx avatar May 05 '23 23:05 yetilfx

same , langchain==0.0.160

fjun99 avatar May 06 '23 04:05 fjun99

call with azure openai broken(RetrievalQA, resource not found). when use langchain==0.0.150, everything is ok.

fjun99 avatar May 06 '23 05:05 fjun99

same, langchain ==0.0.160 with python 3.8.10

vamsiramakrishnan avatar May 06 '23 05:05 vamsiramakrishnan

Hello, same error with langchain==0.0.160, python 3.10.11

cjflanagan avatar May 06 '23 10:05 cjflanagan

Some kind of race condition bug?

Seems to be fixable by explicitly

import langchain
langchain.verbose = False

before trying to initialize llm.

wafflecomposite avatar May 07 '23 15:05 wafflecomposite

@wafflecomposite This solution worked for me. Thanks!

MoAmrYehia avatar May 08 '23 06:05 MoAmrYehia

This issue seems to have resurfaced in version 0.0.234 of langchain. The suggested solution in the issue works only temporarily, meaning the issue popped up after some time again.

iamulya avatar Jul 21 '23 11:07 iamulya

Some kind of race condition bug?

Seems to be fixable by explicitly

import langchain
langchain.verbose = False

before trying to initialize llm.

this did not work for me.

urbanscribe avatar Aug 28 '23 12:08 urbanscribe

Getting this error in 0.0.299 as well

ryanholtschneider2 avatar Sep 22 '23 15:09 ryanholtschneider2

Just in case someone gets this error now, the only thing that worked for me was updating langchain's version. In my case I'm using poetry as my package manager and did:

poetry update langchain

If you're using pip just use:

pip install --upgrade langchain

I tried using the langchain.verbose = False workaround that was mentioned here but it ended up triggering the same error later.

jorrgme avatar Oct 06 '23 14:10 jorrgme

This issue still appears in the latest version (0.0.332). Is there a known solution?

fabilix avatar Nov 09 '23 09:11 fabilix

My langchain.verbose = False "solution" is no longer relevant since https://github.com/langchain-ai/langchain/pull/11311

@fabilix check out a suggestions on this issue https://github.com/langchain-ai/langchain/issues/9854 If that doesn't help, add a comment there too. Apparently it's still an unsolved problem.

wafflecomposite avatar Nov 09 '23 10:11 wafflecomposite

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

Lakmal-Fernando avatar Mar 14 '24 15:03 Lakmal-Fernando

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

great!rename can solve

lestat2023 avatar Mar 19 '24 08:03 lestat2023

我也遇到过这个问题。就我而言,是我的文件夹结构弄乱了导入。我在我的项目中有一个文件夹。重命名后,它工作正常。langchain

good job bro, i have solved the question due to your reply

WANGHEMING-BUPT avatar Apr 13 '24 06:04 WANGHEMING-BUPT

I also faced this issue. In my case it was my folder structure messing with the imports. I had a folder called langchain within my project. After I renamed it it worked fine.

it works, I can't belive the reason is this stupid LOL.

Hardy0611 avatar May 09 '24 10:05 Hardy0611

For me, I had a file named langchain.py make this error.

change the name it seems ok -__-

jy1989 avatar May 11 '24 06:05 jy1989

I named my python file "langchain.py". When I ran it using "python langchain.py", I get this error. After I renamed the "langchain.py" to some other name, the error is gone.

cauchycai avatar Jun 06 '24 03:06 cauchycai

Quote reply Reference in new https://github.com/langchain-ai/langchain/issues/4164?ref=gettingstarted.ai#issuecomment-1997698152 Deleting the duplicate venv/.venv can solve this issue.

BBplayer2021 avatar Jun 10 '24 04:06 BBplayer2021