Metadata-Version: 2.5
Name: llama-index-guardrails-icephi
Version: 0.1.1
Summary: Sub-20ms prompt injection and jailbreak protection for LlamaIndex query engines.
Keywords: llama-index,guardrails,prompt-injection,security,jailbreak,onnx
Author: Ice Phi
Description-Content-Type: text/markdown
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Requires-Dist: llama-index-core>=0.10.0
Requires-Dist: requests>=2.28.0
Project-URL: Homepage, https://icephi.com
Project-URL: Repository, https://github.com/Ice-Phi/llama-index-guardrails-icephi
Import-Name: llama_index.guardrails.icephi
Import-Namespace: llama_index
Import-Namespace: llama_index.guardrails

llama-index-guardrails-icephi

Sub-20ms prompt injection and jailbreak protection for LlamaIndex query engines, powered by Ice Phi.

llama-index-guardrails-icephi provides a custom NodePostprocessor (IcePhiPromptGuard) that inspects retrieved nodes and user queries before they hit your LLM or retrieval pipeline, automatically blocking malicious prompts, jailbreak attempts, and prompt injection attacks in real time.
Installation

pip install llama-index-guardrails-icephi
Quick Start
1. Set your API Key

Set your Ice Phi API key as an environment variable:

export ICEPHI_API_KEY="your-icephi-api-key"

Or pass it directly when initializing the postprocessor.
2. Add Guardrails to Your Query Engine

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.guardrails.icephi import IcePhiPromptGuard
Load documents and create an index

documents = SimpleDirectoryReader("./data").load_data()
index = VectorStoreIndex.from_documents(documents)
Initialize the Ice Phi guardrail

icephi_guard = IcePhiPromptGuard(
api_key="your-icephi-api-key",  # Optional if ICEPHI_API_KEY env var is set
raise_on_blocked=True            # Raises ValueError if a prompt injection is detected
)
Attach the guardrail as a node postprocessor

query_engine = index.as_query_engine(
node_postprocessors=[icephi_guard]
)
Safe query execution

try:
response = query_engine.query("Summarize the document.")
print(response)
except ValueError as e:
print(f"Blocked by Ice Phi Guardrail: {e}")
Configuration Options

The IcePhiPromptGuard accepts the following parameters:

    api_key (Optional[str]): Ice Phi API Key. Defaults to reading ICEPHI_API_KEY from environment variables.

    api_url (str): Ice Phi Shield API endpoint (default: "https://api.icephi.com/shield").

    raise_on_blocked (bool): If True, raises ValueError on detected attacks. If False, filters out flagged nodes cleanly. Default is True.

    timeout (float): Request timeout in seconds (default: 2.0).

Features

    Sub-20ms Latency: High-throughput, optimized ONNX inference endpoint.

    Comprehensive Defense: Protects against direct prompt injections, jailbreaks, and indirect prompt injection vectors inside retrieved contexts.

    Native LlamaIndex Integration: Implements BaseNodePostprocessor for seamless placement in RAG and Agent pipelines.

License

This project is licensed under the MIT License.

