langchain.llms.opaqueprompts.OpaquePrompts¶
class langchain.llms.opaqueprompts.OpaquePrompts[source]¶
Bases: LLM
An LLM wrapper that uses OpaquePrompts to sanitize prompts.
Wraps another LLM and sanitizes prompts before passing it to the LLM, thende-sanitizes the response.
To use, you should have the opaqueprompts python package installed,
and the environment variable OPAQUEPROMPTS_API_KEY set with
your API key, or pass it as a named parameter to the constructor.
Example
from langchain.llms import OpaquePrompts
from langchain.chat_models import ChatOpenAI
op_llm = OpaquePrompts(base_llm=ChatOpenAI())
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param base_llm: langchain.schema.language_model.BaseLanguageModel [Required]¶
The base LLM to use.
param cache: Optional[bool] = None¶
param callback_manager: Optional[BaseCallbackManager] = None¶
param callbacks: Callbacks = None¶
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
Check Cache and run the LLM on the given prompt and input.