代码之家  ›  专栏  ›  技术社区  ›  Dhruva Kumar

没有名为verbose[closed]的属性

  •  0
  • Dhruva Kumar  · 技术社区  · 9 月前

    这是我的代码:

    from langchain_core.prompts import ChatPromptTemplate
    from langchain_ollama import ChatOllama
    
    llm = ChatOllama(
        model = 'llama3.2',
        temperature = 0
    )
    
    chat_template = ChatPromptTemplate.from_messages(
        [
            ('system', "you have to give two line definition of the word given by user"),
            ('human', 'the word is {user_input}')
        ]
    )
    
    message = chat_template.format_messages(user_input = 'backlog')
    print(message)
    
    response = llm.invoke(message)
    print(message)
    

    显示属性错误:

    AttributeError: partially initialized module 'langchain' has no attribute 'verbose' (most likely due to a circular import)
    

    我该怎么解决这个问题? 我试图使用langchain创建基本的单词含义聊天机器人。

    1 回复  |  直到 9 月前
        1
  •  1
  •   Free Palestine    9 月前

    您收到此错误是因为您有一个名为的文件 langchain.py

    请将您的文件名更改为其他名称。

    此外,请避免将文件名命名为模块名、关键字等。

    https://github.com/langchain-ai/langchain/discussions/23071