Metadata-Version: 2.4
Name: llamaindex-omega
Version: 0.1.0
Summary: LlamaIndex integration with OmegaEngine governance - RAG safety and compliance
Project-URL: Homepage, https://omegaengine.ai
Project-URL: Documentation, https://omegaengine.ai/docs
Project-URL: Repository, https://github.com/TheArkhitect/Omegaengine/tree/main/open-source-repos/llamaindex-omega
Author-email: OmegaEngine <team@omegaengine.ai>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-safety,audit,compliance,governance,llamaindex,omegaengine,rag,retrieval
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Requires-Dist: llama-index-core>=0.10.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Description-Content-Type: text/markdown

<p align="center">
  <img src="logo.png" alt="OmegaEngine Logo" width="200" height="200">
</p>

<h1 align="center">llamaindex-omega</h1>

<p align="center">
  <strong>LlamaIndex Integration for OmegaEngine</strong>
</p>

<p align="center">
  <a href="https://pypi.org/project/llamaindex-omega/"><img src="https://img.shields.io/pypi/v/llamaindex-omega?color=blue&label=PyPI" alt="PyPI"></a>
  <a href="https://github.com/TheArkhitect/Omegaengine/actions"><img src="https://img.shields.io/github/actions/workflow/status/TheArkhitect/Omegaengine/ci.yml?branch=main" alt="CI"></a>
  <a href="https://github.com/TheArkhitect/Omegaengine/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License"></a>
</p>

<p align="center">
  <a href="https://omegaengine.ai/docs">Documentation</a> •
  <a href="https://omegaengine.ai/playground">Playground</a> •
  <a href="https://github.com/TheArkhitect/Omegaengine/issues">Issues</a>
</p>

---

## ✨ Features

- 🔗 **Query Engine Wrapper** — Add governance to any LlamaIndex query
- 📊 **Retrieval Guard** — Validate retrieved context before synthesis
- 🛡️ **Response Validator** — Check LLM outputs against policies
- 📈 **Observability** — Full audit trail for RAG pipelines
- ⚡ **Async Support** — Native async/await compatibility

---

## 📦 Installation

```bash
pip install llamaindex-omega
```

---

## 🚀 Quick Start

### Governed Query Engine

```python
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llamaindex_omega import GovernedQueryEngine

# Load your documents
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)

# Wrap with OmegaEngine governance
query_engine = GovernedQueryEngine(
    index.as_query_engine(),
    api_key="your-omega-api-key",
    policy_id="rag_policy",
)

# All queries are now governed
response = query_engine.query("What are the quarterly results?")
print(response)
```

### Response Callback

```python
from llamaindex_omega import OmegaCallbackHandler

callback = OmegaCallbackHandler(
    api_key="your-omega-api-key",
    log_retrievals=True,
    log_responses=True,
)

# Attach to your service context
from llama_index.core import Settings
Settings.callback_manager.add_handler(callback)
```

---

## 🛡️ Retrieval Guard

Validate retrieved context before it's sent to the LLM:

```python
from llamaindex_omega import GovernedRetriever

guard = GovernedRetriever(
    api_key="your-omega-api-key",
    block_pii=True,
    block_sensitive_topics=["financial", "medical"],
)

# Wrap your retriever
safe_retriever = guard.wrap(index.as_retriever())

# Retrieved nodes are validated before synthesis
nodes = safe_retriever.retrieve("Tell me about the patient")
```

---

## 📊 Audit Trail

Every query is logged with:
- ✅ Original query
- ✅ Retrieved context (optionally)
- ✅ Generated response
- ✅ Policy evaluation result
- ✅ Risk score
- ✅ Latency metrics

```python
# Access audit data
print(response.metadata["omega_audit_id"])
print(response.metadata["omega_decision"])
```

---

## 🔌 Works With All LlamaIndex Features

- ✅ VectorStoreIndex
- ✅ KnowledgeGraphIndex
- ✅ DocumentSummaryIndex
- ✅ Chat Engine
- ✅ Agents
- ✅ SubQuestionQueryEngine

---

## 📄 License

Licensed under the [Apache License 2.0](LICENSE).

---

<p align="center">
  Built with ❤️ by the <a href="https://omegaengine.ai">OmegaEngine</a> team
</p>
