LangChain integration with OmegaEngine governance - callbacks, tools, and safety chains
Project description
langchain-omega
LangChain Integration for OmegaEngine
Documentation • Playground • Issues
✨ Features
- 🔗 Callback Handler — Log all LLM decisions to OmegaEngine
- 🤖 Agent Wrapper — Enforce policies on LangChain agents
- 📊 Decision Logging — Automatic audit trail for all interactions
- 🛡️ Safety Guards — Pre/post-processing safety filters
- ⚡ Async Support — Full async/await compatibility
📦 Installation
pip install langchain-omega
🚀 Quick Start
Callback Handler
from langchain_openai import ChatOpenAI
from langchain_omega import OmegaCallbackHandler
# Create callback handler
omega_handler = OmegaCallbackHandler(
api_key="your-omega-api-key",
policy_id="pol_abc123",
)
# Use with any LangChain LLM
llm = ChatOpenAI(callbacks=[omega_handler])
# All invocations are now logged to OmegaEngine
response = llm.invoke("What is the capital of France?")
Decision Tool
from langchain.agents import create_openai_functions_agent
from langchain_omega import OmegaDecisionTool
# Add decision tool to your agent
decision_tool = OmegaDecisionTool(
api_key="your-omega-api-key",
domain="finance",
)
tools = [decision_tool, ...other_tools]
agent = create_openai_functions_agent(llm, tools, prompt)
# Agent can now make governed decisions
result = agent.invoke({
"input": "Should we approve this loan application?"
})
Safety Guard Chain
from langchain_omega import GovernedLLMChain
# Wrap any chain with safety guards
safe_chain = GovernedLLMChain(
chain=your_chain,
api_key="your-omega-api-key",
policy_id="safety_policy",
block_on_deny=True,
)
# Chain will block unsafe outputs
result = safe_chain.invoke({"input": "..."})
📊 What Gets Logged
Every LLM interaction logs:
- ✅ Input prompt
- ✅ Output response
- ✅ Token usage
- ✅ Latency
- ✅ Model name
- ✅ Policy evaluation result
- ✅ Risk assessment
- ✅ Audit trail ID
📄 License
Licensed under the Apache License 2.0.
Built with ❤️ by the OmegaEngine team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
langchain_omega-0.2.0.tar.gz
(564.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_omega-0.2.0.tar.gz.
File metadata
- Download URL: langchain_omega-0.2.0.tar.gz
- Upload date:
- Size: 564.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa66206b346e4d2a5cfc73a88e6ef27b190092060b936d2601f30f8bd541e3ab
|
|
| MD5 |
9608d81718df9e74013e24f9614dcd19
|
|
| BLAKE2b-256 |
42305b3d6a3f6b4c10818a9545e7061522160a4b4c1d69b1f2ed7fb58b0476c9
|
File details
Details for the file langchain_omega-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_omega-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2092aed18bb2e0ea83ead8ad1b706b33b237150f2da14a32a96432e025a27c63
|
|
| MD5 |
218fe2c4bf8159da57c0b6212237cacf
|
|
| BLAKE2b-256 |
61d878efef971eb561bc1ad7ca1be3376f66f290a5128c937b575e069f9f7ff1
|