+
95
-

为啥我在python中调用ollama报错:AttributeError: partially initialized module 'ollama' has no attribute 'chat'

为啥我在python中调用ollama报错:AttributeError: partially initialized module 'ollama' has no attribute 'chat' (most likely due to a circular import)

import ollama
response = ollama.chat(
    model="llama3.1",
    messages=[
        {
            "role": "user",
            "content": "Why is the sky blue?",
        },
    ],
)
print(response["message"]["content"])


网友回复

+
15
-

这个是你的python文件名为ollama.py导致的,改成其他的名字就好了。

我知道答案,我要回答