nemoguardrails.library.autoalign.actions

View as Markdown

Module Contents

Functions

NameDescription
autoalign_factcheck_infer-
autoalign_factcheck_output_apiCalls Autoalign Factchecker API and checks if the user message is factually answered by the bot message
autoalign_factcheck_output_api_mappingMapping for autoalign_factcheck_output_api.
autoalign_groundedness_inferChecks the groundedness for the text using the given documents and provides a fact-checking score
autoalign_groundedness_output_apiCalls AutoAlign groundedness check API and checks whether the bot message is factually grounded according to given
autoalign_groundedness_output_api_mappingMapping for autoalign_groundedness_output_api.
autoalign_inferChecks whether the given text passes through the applied guardrails.
autoalign_input_apiCalls AutoAlign API for the user message and guardrail configuration provided
autoalign_output_apiCalls AutoAlign API for the bot message and guardrail configuration provided
autoalign_output_api_mappingMapping for autoalign_output_api.
process_autoalign_outputProcesses the output provided AutoAlign API

Data

DEFAULT_CONFIG

GUARDRAIL_RESPONSE_TEXT

default_groundedness_config

log

API

nemoguardrails.library.autoalign.actions.autoalign_factcheck_infer(
request_url: str,
user_message: str,
bot_message: str,
guardrails_config: typing.Optional[typing.Dict[str, typing.Any]] = None,
multi_language: bool = False
)
async
nemoguardrails.library.autoalign.actions.autoalign_factcheck_output_api(
llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
context: typing.Optional[dict] = None,
factcheck_threshold: float = 0.0,
show_autoalign_message: bool = True
)
async

Calls Autoalign Factchecker API and checks if the user message is factually answered by the bot message

nemoguardrails.library.autoalign.actions.autoalign_factcheck_output_api_mapping(
result: float
) -> bool

Mapping for autoalign_factcheck_output_api.

Expects result to be a numeric score. Returns True (block) if the score is below the default factcheck threshold.

nemoguardrails.library.autoalign.actions.autoalign_groundedness_infer(
request_url: str,
text: str,
documents: typing.List[str],
guardrails_config: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None
)
async

Checks the groundedness for the text using the given documents and provides a fact-checking score

nemoguardrails.library.autoalign.actions.autoalign_groundedness_output_api(
llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
context: typing.Optional[dict] = None,
factcheck_threshold: float = 0.0,
show_autoalign_message: bool = True,
kwargs = {}
)
async

Calls AutoAlign groundedness check API and checks whether the bot message is factually grounded according to given documents

nemoguardrails.library.autoalign.actions.autoalign_groundedness_output_api_mapping(
result: float
) -> bool

Mapping for autoalign_groundedness_output_api.

Expects result to be a numeric score. Returns True (block) if the score is below the default groundedness threshold.

nemoguardrails.library.autoalign.actions.autoalign_infer(
request_url: str,
text: str,
task_config: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
show_toxic_phrases: bool = False,
multi_language: bool = False
)
async

Checks whether the given text passes through the applied guardrails.

nemoguardrails.library.autoalign.actions.autoalign_input_api(
llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
context: typing.Optional[dict] = None,
show_autoalign_message: bool = True,
show_toxic_phrases: bool = False,
kwargs = {}
)
async

Calls AutoAlign API for the user message and guardrail configuration provided

nemoguardrails.library.autoalign.actions.autoalign_output_api(
llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
context: typing.Optional[dict] = None,
show_autoalign_message: bool = True,
show_toxic_phrases: bool = False,
kwargs = {}
)
async

Calls AutoAlign API for the bot message and guardrail configuration provided

nemoguardrails.library.autoalign.actions.autoalign_output_api_mapping(
result: dict
) -> bool

Mapping for autoalign_output_api.

Expects result to be a dict with a key “guardrails_triggered” (a boolean). Returns True (block) if guardrails were triggered.

nemoguardrails.library.autoalign.actions.process_autoalign_output(
responses: typing.List[typing.Any],
show_toxic_phrases: bool = False
)

Processes the output provided AutoAlign API

nemoguardrails.library.autoalign.actions.DEFAULT_CONFIG = {'pii': {'mode': 'OFF', 'mask': False, 'enabled_types': ['[BANK ACCOUNT NUMBER]'...
nemoguardrails.library.autoalign.actions.GUARDRAIL_RESPONSE_TEXT = {'confidential_info_detection': 'Confidential Information violation', 'gender_bi...
nemoguardrails.library.autoalign.actions.default_groundedness_config = {'groundedness_checker': {'verify_response': False}}
nemoguardrails.library.autoalign.actions.log = logging.getLogger(__name__)