Skip to content

Commit

Permalink
Addresses GPT4All wrapper model_type attribute issues #5720. (#5743)
Browse files Browse the repository at this point in the history
Fixes #5720.

A more in-depth discussion is in my comment here:
#5720 (comment)

In a nutshell, there has been a subtle change in the latest version of
GPT4Alls Python bindings. The change I submitted yesterday is compatible
with this version, however, this version is as of yet unreleased and
thus the code change breaks Langchain's wrapper under the currently
released version of GPT4All.

This pull request proposes a backwards-compatible solution.
  • Loading branch information
bwv988 authored Jun 5, 2023
1 parent d0d89d3 commit 74f8e60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion langchain/llms/gpt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ def validate_environment(cls, values: Dict) -> Dict:
if values["n_threads"] is not None:
# set n_threads
values["client"].model.set_thread_count(values["n_threads"])
values["backend"] = values["client"].model_type

try:
values["backend"] = values["client"].model_type
except AttributeError:
# The below is for compatibility with GPT4All Python bindings <= 0.2.3.
values["backend"] = values["client"].model.model_type

return values

Expand Down

0 comments on commit 74f8e60

Please sign in to comment.