Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added n_threads functionality for gpt4all #5427

Merged
merged 2 commits into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions langchain/llms/gpt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,27 @@ def validate_environment(cls, values: Dict) -> Dict:
"""Validate that the python package exists in the environment."""
try:
from gpt4all import GPT4All as GPT4AllModel

full_path = values["model"]
model_path, delimiter, model_name = full_path.rpartition("/")
model_path += delimiter

values["client"] = GPT4AllModel(
model_name=model_name,
model_path=model_path or None,
model_type=values["backend"],
allow_download=False,
)
values["backend"] = values["client"].model.model_type

except ImportError:
raise ValueError(
raise ImportError(
"Could not import gpt4all python package. "
"Please install it with `pip install gpt4all`."
)

full_path = values["model"]
model_path, delimiter, model_name = full_path.rpartition("/")
model_path += delimiter

values["client"] = GPT4AllModel(
model_name,
model_path=model_path or None,
model_type=values["backend"],
allow_download=False,
)
if values["n_threads"] is not None:
# set n_threads
values["client"].model.set_thread_count(values["n_threads"])
values["backend"] = values["client"].model.model_type

return values

@property
Expand Down