Result Mappers¶
Map raw supervisor responses to normalized Result objects.
bells_o.result_mappers ¶
Module structure for mappers.
anthropic_one ¶
Map the output format of Anthropic API to Result for classification.
Parses text output["content"][0]["text"] from Anthropic API looking for "1" (harmful) or "0" (benign).
The model is instructed to output 1 if harmful, 0 if benign.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor (Anthropic format). |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on parsed output. |
Source code in src/bells_o/result_mappers/anthropic_one_mapper.py
azure_analyze_text ¶
Map the output format of Azure's Analyze Text to Result.
Only maps to content_moderation. Assumes that 2 is the severity threshold.
See https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-text?pivots=programming-language-rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, str]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Source code in src/bells_o/result_mappers/azure_analyze_text_mapper.py
azure_prompt_shield ¶
Map the output format of Azure's Prompt Shield to Result.
Only maps to jailbreak.
See https://ai.azure.com/doc/azure/ai-services/content-safety/quickstart-jailbreak.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, str]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Source code in src/bells_o/result_mappers/azure_prompt_shield_mapper.py
bedrock_guardrail ¶
Map the output format of AWS Bedrock Guardrail to Result.
AWS Bedrock Guardrail returns an action field that indicates if content was blocked. The action can be "GUARDRAIL_INTERVENED", "INTERVENED", "1" (blocked) or "NONE", "0" (allowed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
The usage types to map to. Defaults to all usage types. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with the mapped values. |
Source code in src/bells_o/result_mappers/bedrock_guardrail_mapper.py
gemini_moderation ¶
Map the output format of Vertex Gemini moderation to Result.
Only maps to content_moderation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on block decision. |
Source code in src/bells_o/result_mappers/gemini_moderation_mapper.py
gemini_one ¶
Map the output format of Gemini classification to Result.
Parses Gemini's output["candidates"][0]["content"]["parts"][0]["text"] looking for "1" (harmful) or "0" (benign).
The model is instructed to output 1 if harmful, 0 if benign.
Additionally, handles scenario where output contains a blockReason (treat as "1"/harmful).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on parsed output. |
Source code in src/bells_o/result_mappers/gemini_one_mapper.py
gpt_oss_local_one ¶
Map the output format of ibm-granite/granite-guardian-3.3-{variant} to Result.
Only maps to content_moderation. Checks for content after
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/gpt_oss_local_one_mapper.py
granite_33 ¶
Map the output format of ibm-granite/granite-guardian-3.3-{variant} to Result.
Only maps to content_moderation. Checks for content between
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/granite_33_mapper.py
harmful_request ¶
Map the output format of ibm-granite/granite-guardian-3.3-{variant} to Result.
Only maps to content_moderation. Checks for content between
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/harmful_request_mapper.py
lakeraguard ¶
Map the output format of LakeraGuard to Result.
LakeraGuard supports different policies, so usage needs to be passed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, str]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
The usage types to map to. |
required |
Source code in src/bells_o/result_mappers/lakeraguard_mapper.py
lionguard ¶
Map the output format of saillab/x-guard to Result.
Only maps to content_moderation. Checks for content between
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/lionguard_mapper.py
logit_compare ¶
Map the output format of leolee99/PIGuard to Result.
Only maps to jailbreak. Compares passed logits of format [
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
list[float]
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/logit_compare_mapper.py
nemotron ¶
Map the output format of nvidia/Llama-3.1-Nemotron-Safety-Guard-8B-v3 to Result.
Maps a json string for "User Safety" and "Response Safety" with "unsafe" and "safe as values to True and False.
E.g.: { "User Safety": "unsafe", "Response Safety": "safe", "Safety Categories": "guns and illegal weapons" }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string of a JSON representation. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on parsed output. |
Source code in src/bells_o/result_mappers/nemotron_mapper.py
neuraltrust ¶
Map the output format of a NeuralTrustTrustGateSupervisor to Result.
NeuralTrust supports different policies, so usage needs to be passed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, str]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
The usage types to map to. |
required |
Source code in src/bells_o/result_mappers/neuraltrust_trustgate_mapper.py
one_map ¶
Map "1" to harmful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string (raw model output) or dict that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/one_mapper.py
openai_compatible_one ¶
Map the output format of OpenAI-compatible models with "1" as a harmful flag to Result.
The response structure is: output["choices"][0]["message"]["content"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor (OpenAI-compatible format). |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on parsed output. |
Source code in src/bells_o/result_mappers/openai_compatible_one_mapper.py
openai_compatible_unsafe ¶
Map the output format of OpenAI-compatible models with "unsafe" as a harmful flag to Result.
Maps output "safe" or "unsafe" in the OpenAI-compatible chat completion format.
The response structure is: output["choices"][0]["message"]["content"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of a supervisor (OpenAI-compatible format). |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with content_moderation flag set based on parsed output. |
Source code in src/bells_o/result_mappers/openai_compatible_unsafe_mapper.py
openai_moderation ¶
Map the output format of OpenAI Moderation to Result.
Only maps to content_moderation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, str]
|
A dict that is the raw response of a supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Source code in src/bells_o/result_mappers/openai_moderation_mapper.py
opencc ¶
Map the output format of OpenCC to Result.
OpenCC returns a single terminal decision. Any decision other than "allow"
(i.e. "block" or "annotate") is treated as a detection. The resulting flag is
applied to every declared usage type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any]
|
A dict that is the raw response of the supervisor. |
required |
usage
|
Usage
|
The usage types to map to. |
Usage()
|
Source code in src/bells_o/result_mappers/opencc_mapper.py
protectai ¶
Map the output format of ProtectAI LLM Guard to Result.
Takes the inverse of the passed boolean in the tuple. Only maps to jailbreak usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
tuple[str, bool, float]
|
The output tuple of the supervisor. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
A Result object with jailbreak flag set based on parsed output. |
Source code in src/bells_o/result_mappers/protectai_llm_guard_mapper.py
qwen3guard ¶
Map the output format of Qwen3Guard to Result.
Qwen3Guard outputs text that contains a safety label (Safe, Unsafe, or Controversial) and potentially a list of categories. "Unsafe" or "Controversial" means harmful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str | dict[str, Any]
|
A string (raw model output) or dict that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/qwen3guard_mapper.py
unsafe_map ¶
Map "unsafe" to harmful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string (raw model output) or dict that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/unsafe_mapper.py
xguard ¶
Map the output format of saillab/x-guard to Result.
Only maps to content_moderation. Checks for content between
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string or list of strings that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |
Source code in src/bells_o/result_mappers/xguard_mapper.py
yes_map ¶
Map "yes" to harmful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
A string (raw model output) or dict that should be mapped. |
required |
usage
|
Usage
|
Conformity with ResultMapper type. Argument is ignored as usage type is static. |
Usage()
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
The result that the output maps to. |