Alinia
any_guardrail.guardrails.alinia.alinia
Alinia
Bases: Guardrail[bool, dict[str, dict[str, float | bool | str]], dict[str, dict[str, float]]]
Wraps the Alinia API for content moderation and safety detection.
This wrapper allows you to send conversations or text inputs to the Alinia API. You must get an API key from Alinia and either set it to the ALINIA_API_KEY environment variable or pass it directly to the constructor. From Alinia, you'll also be able to get the proper endpoint URL as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The Alinia API endpoint URL. |
None
|
detection_config
|
str | dict
|
The detection configuration ID or a dictionary specifying detection parameters. |
required |
api_key
|
str | None
|
The API key for authenticating with the Alinia API. If not provided, it will be read from the ALINIA_API_KEY environment variable. |
None
|
metadata
|
dict | None
|
Optional metadata to include with the request. |
None
|
blocked_response
|
dict | None
|
Optional response to return if content is blocked. |
None
|
stream
|
bool
|
Whether to use streaming for the API response. |
False
|
Source code in src/any_guardrail/guardrails/alinia/alinia.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
__init__(detection_config, api_key=None, endpoint=None, metadata=None, blocked_response=None, stream=False)
Initialize the Alinia guardrail with the provided configuration.
Source code in src/any_guardrail/guardrails/alinia/alinia.py
validate(conversation, output=None, context_documents=None)
Validate conversation or text input using the Alinia API.
This can be used for validation using any of the API endpoints provided by Alinia. If using sensitive information endpoint, use the explanation from the GuardrailOutput to grab the recommended action text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation
|
str | list[dict[str, str]]
|
The conversation or text input to validate. |
required |
output
|
str | None
|
Optional expected output to validate against. |
None
|
context_documents
|
list[str] | None
|
Optional context documents to provide additional context for validation |
None
|