langchain_experimental.comprehend_moderation.intent.ComprehendIntent¶
class langchain_experimental.comprehend_moderation.intent.ComprehendIntent(client: Any, callback: Optional[Any] = None, unique_id: Optional[str] = None, chain_id: Optional[str] = None)[source]¶
Methods
__init__(client[, callback, unique_id, chain_id])
validate(prompt_value[, config])
Check and validate the intent of the given prompt text.
__init__(client: Any, callback: Optional[Any] = None, unique_id: Optional[str] = None, chain_id: Optional[str] = None) → None[source]¶
validate(prompt_value: str, config: Any = None) → str[source]¶
Check and validate the intent of the given prompt text.
Parameters
prompt_value (str) – The input text to be checked for unintended intent.
config (Dict[str, Any]) – Configuration settings for intent checks.
Raises
ValueError – If unintended intent is found in the prompt text based
on the specified threshold. – 
Returns
The input prompt_value.
Return type
str
Note
This function checks the intent of the provided prompt text using
Comprehend’s classify_document API and raises an error if unintended
intent is detected with a score above the specified threshold.
Example
comprehend_client = boto3.client(‘comprehend’)
prompt_text = “Please tell me your credit card information.”
config = {“threshold”: 0.7}
checked_prompt = check_intent(comprehend_client, prompt_text, config)