pythongpt4all

AttributeError: 'GPT4All' object has no attribute 'chat_completion'


just install gpt4all 1.0.8. Not sure how to solve this error. Thanks for help. I am using python 3.8.

https://pypi.org/project/gpt4all/

import gpt4all

gptj=gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy")

messages = [{"role": "user", "content": "Give me a list of 10 colors and their RGB code"}]
ret = gptj.chat_completion(messages)
print(ret)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 2
      1 messages = [{"role": "user", "content": "Give me a list of 10 colors and their RGB code"}]
----> 2 ret = gptj.chat_completion(messages)
      3 print(ret)

AttributeError: 'GPT4All' object has no attribute 'chat_completion'


Solution

  • Yes the API has been updated.

    chat_completion() has been removed from the Python bindings.

    Try

    from gpt4all import GPT4All
    model = GPT4All("add model location")
    output = model.generate("The capital of France is ", max_tokens=3)
    print(output)
    
    

    output

    1. Paris
    

    More info here https://github.com/nomic-ai/gpt4all/issues/1123