API Reference
Welcome to the AI Sentinel API reference documentation. This page provides detailed information about the public classes, methods, and functions available in the package. The API is organized into three main modules: core components, guard systems, and LLM clients.
Note
All examples assume you have already installed AI Sentinel.
Core Components
The core module provides fundamental data structures and utilities used throughout AI Sentinel.
|
Response from an LLM Provider |
Example Usage:
from ai_sentinel.core import LLMResponse
# Create a response object
response = LLMResponse(
content="Sample response",
model="gpt-4"
)
Guard Systems
The guards module contains the toxicity detection and analysis components, which are the primary tools for content moderation.
Structured output from LLM toxicity assessment |
|
Specify Toxicity Categories |
|
Toxicity severity levels |
Example Usage:
from ai_sentinel.guards import ToxicityGuard
from ai_sentinel.guards.toxicity_guard import ToxicityCategories
# Initialize the guard
sample_client = "your_client_here" # Replace with actual client
guard = ToxicityGuard(client=sample_client)
# Analyze text
result = guard.analyze("Your text here")
# Access results
print(result.is_toxic)
print(result.categories)
print(result.scores)
LLM Clients
The LLM module provides interfaces to various Language Model providers. Each client implements a common interface while handling provider-specific requirements.
|
Abstract Base Class for LLM Clients |
|
Client implementation for Azure OpenAI LLM |
|
Client implementation for Google Gemini LLM |
|
Client implementation for Open Source LLM using a local server that offers compatibility with the OpenAI SDK |
Example Usage
See Also
Usage Guide - For more detailed usage examples
Module Overview - For high-level package concepts