langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Error running GPT4ALL model: TypeError: Model.generate() got an unexpected keyword argument 'new_text_callback'

Open ooo27 opened this issue 1 year ago • 5 comments

Sample code:

from langchain.llms import GPT4All
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

gpt4all_model_path = "./models/ggml-gpt4all-l13b-snoozy.bin"

template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate(template=template, input_variables=["question"])
callbacks = [StreamingStdOutCallbackHandler()]
llm = GPT4All(model=gpt4all_model_path, callbacks=callbacks, verbose=True)
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What is your quest?"
llm_chain.run(question)

Error during initialization:

  File "e:\src\lgtest\game_actor.py", line 27, in <module>
    llm_chain.run(question)
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\chains\base.py", line 236, in run
    return self(args[0], callbacks=callbacks)[self.output_keys[0]]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\chains\base.py", line 140, in __call__
    raise e
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\chains\base.py", line 134, in __call__
    self._call(inputs, run_manager=run_manager)
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\chains\llm.py", line 69, in _call
    response = self.generate([inputs], run_manager=run_manager)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\chains\llm.py", line 79, in generate
    return self.llm.generate_prompt(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\llms\base.py", line 127, in generate_prompt
    return self.generate(prompt_strings, stop=stop, callbacks=callbacks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\llms\base.py", line 176, in generate
    raise e
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\llms\base.py", line 170, in generate
    self._generate(prompts, stop=stop, run_manager=run_manager)
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\llms\base.py", line 377, in _generate
    self._call(prompt, stop=stop, run_manager=run_manager)
  File "e:\src\lgtest\.venv\Lib\site-packages\langchain\llms\gpt4all.py", line 186, in _call
    text = self.client.generate(
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: Model.generate() got an unexpected keyword argument 'new_text_callback'```

ooo27 avatar May 04 '23 18:05 ooo27

I was able to fix it, PR here. https://github.com/hwchase17/langchain/pull/4136

ooo27 avatar May 04 '23 21:05 ooo27

Is not working yet. Some suggestion maybe using previous releases?

alanredmaiar avatar May 05 '23 07:05 alanredmaiar

i still get this error on langChain==0.0.160. opened issue# https://github.com/hwchase17/langchain/issues/4220 @ooo27

jackxwu avatar May 06 '23 06:05 jackxwu

Temporary workaround is to downgrade pygpt4all pip install --upgrade pygpt4all==1.0.1

rafaeldelrey avatar May 06 '23 20:05 rafaeldelrey

I was able to fix it, PR here. #4136

That works!

g0dEngineer avatar May 07 '23 21:05 g0dEngineer

Hi, @ooo27! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you encountered a TypeError during the initialization of the GPT4ALL model, specifically "Model.generate() got an unexpected keyword argument 'new_text_callback'". You were able to fix the issue and submitted a pull request. TatanParker suggested using previous releases as a temporary solution, while rafaeldelrey recommended downgrading pygpt4all to version 1.0.1. Another user, jackxwu, also opened a new issue with the same error.

Before we close this issue, we wanted to check if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution and for bringing this issue to our attention. Let us know if there's anything else we can assist you with!

dosubot[bot] avatar Sep 15 '23 16:09 dosubot[bot]