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.3.0.tar.gz
(565.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.3.0.tar.gz.
File metadata
- Download URL: langchain_omega-0.3.0.tar.gz
- Upload date:
- Size: 565.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5e43ee317105766b6209c18fd5242658e7f468cd4d8b67a36f634917834834
|
|
| MD5 |
167586605e0dde4b70b84d7e7162afb2
|
|
| BLAKE2b-256 |
3047e15a516463612eae9060df846c0bd26dd1987cd162ea546ad9cab77b03d2
|
File details
Details for the file langchain_omega-0.3.0-py3-none-any.whl.
File metadata
- Download URL: langchain_omega-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57fda7e0e26bd4b9a5c829a387aef43fa422e7257baa98cc006b0fc7765abe69
|
|
| MD5 |
5802c8681487b76ef95dfbb4847da824
|
|
| BLAKE2b-256 |
efd6a5036db9ac3bed0d7df70f9c6e75caca8928e1b094746b68ca530a946980
|