Skip to content

Installation Guide

This guide will help you install Elsai Guardrails and set up your development environment.

Prerequisites

  • Python 3.10 or higher
  • pip package manager

Installation

Basic Installation

bash
pip install --extra-index-url https://elsai-core-package.optisolbusiness.com/root/elsai-guardrails/ elsai-guardrails==0.1.0

Optional Environment Variables

For semantic content classification (jailbreak detection, prompt injection, etc.), you can configure an embedding encoder. The encoder type is configured via the ENCODER_TYPE environment variable.

If encoder environment variables are not provided, the system will automatically use HuggingFace encoder as the default (local, no API key required).

Encoder Configuration

Set the encoder type:

bash
export ENCODER_TYPE="openai"  # or any supported encoder from the table below

Supported Encoder Types

Encoder TypeAPI Key RequiredSpeedQualityExample Environment Variables
huggingfaceNo (default)MediumGoodNo configuration needed
openaiYesFastExcellentOPENAI_API_KEY
azure_openaiYesFastExcellentAZURE_OPENAI_EMBEDDING_DEPLOYMENT
AZURE_OPENAI_EMBEDDING_ENDPOINT
AZURE_OPENAI_EMBEDDING_API_KEY
AZURE_OPENAI_EMBEDDING_API_VERSION
cohereYesFastExcellentCOHERE_API_KEY
googleYesFastExcellentGOOGLE_API_KEY
fastembedNoVery FastGoodNo configuration needed
ollamaNoMediumGoodOLLAMA_BASE_URL (optional)
mistralYesFastExcellentMISTRAL_API_KEY
voyageYesFastExcellentVOYAGE_API_KEY
jinaYesFastExcellentJINA_API_KEY
bedrockYesFastExcellentAWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
bm25NoVery FastFairNo configuration needed
tfidfNoVery FastFairNo configuration needed
localNoMediumVariableLOCAL_MODEL (model name)

Example: Using Azure OpenAI Encoder

bash
export ENCODER_TYPE="azure_openai"
export AZURE_OPENAI_EMBEDDING_DEPLOYMENT="text-embedding-ada-002"
export AZURE_OPENAI_EMBEDDING_ENDPOINT="https://your-endpoint.openai.azure.com"
export AZURE_OPENAI_EMBEDDING_API_KEY="your-azure-api-key"
export AZURE_OPENAI_EMBEDDING_API_VERSION="2024-02-15-preview"

For complete encoder configuration details, see the Semantic Classification documentation.

Verify Installation

Check that the package is installed correctly:

bash
pip show elsai-guardrails

Next Steps

Released under the MIT License.