mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-04 12:39:32 +00:00
community[major]: breaking change in some APIs to force users to opt-in for pickling (#18696)
This is a PR that adds a dangerous load parameter to force users to opt in to use pickle. This is a PR that's meant to raise user awareness that the pickling module is involved.
This commit is contained in:
@@ -137,6 +137,11 @@ class SelfHostedPipeline(LLM):
|
||||
model_reqs: List[str] = ["./", "torch"]
|
||||
"""Requirements to install on hardware to inference the model."""
|
||||
|
||||
allow_dangerous_deserialization: bool = False
|
||||
"""Allow deserialization using pickle which can be dangerous if
|
||||
loading compromised data.
|
||||
"""
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
|
||||
@@ -149,6 +154,16 @@ class SelfHostedPipeline(LLM):
|
||||
and run on the server, i.e. in a module and not a REPL or closure.
|
||||
Then, initialize the remote inference function.
|
||||
"""
|
||||
if not kwargs.get("allow_dangerous_deserialization"):
|
||||
raise ValueError(
|
||||
"SelfHostedPipeline relies on the pickle module. "
|
||||
"You will need to set allow_dangerous_deserialization=True "
|
||||
"if you want to opt-in to allow deserialization of data using pickle."
|
||||
"Data can be compromised by a malicious actor if "
|
||||
"not handled properly to include "
|
||||
"a malicious payload that when deserialized with "
|
||||
"pickle can execute arbitrary code. "
|
||||
)
|
||||
super().__init__(**kwargs)
|
||||
try:
|
||||
import runhouse as rh
|
||||
|
Reference in New Issue
Block a user