Skip to content

Commit 74f8e60

Browse files
authored
Addresses GPT4All wrapper model_type attribute issues langchain-ai#5720. (langchain-ai#5743)
Fixes langchain-ai#5720. A more in-depth discussion is in my comment here: langchain-ai#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.
1 parent d0d89d3 commit 74f8e60

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

langchain/llms/gpt4all.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ def validate_environment(cls, values: Dict) -> Dict:
153153
if values["n_threads"] is not None:
154154
# set n_threads
155155
values["client"].model.set_thread_count(values["n_threads"])
156-
values["backend"] = values["client"].model_type
156+
157+
try:
158+
values["backend"] = values["client"].model_type
159+
except AttributeError:
160+
# The below is for compatibility with GPT4All Python bindings <= 0.2.3.
161+
values["backend"] = values["client"].model.model_type
157162

158163
return values
159164

0 commit comments

Comments
 (0)