Skip to main content

LangChain integration with OmegaEngine governance - callbacks, tools, and safety chains

Project description

OmegaEngine Logo

langchain-omega

LangChain Integration for OmegaEngine

PyPI CI License

DocumentationPlaygroundIssues


✨ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_omega-0.1.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_omega-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_omega-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dff639a2b9424a1460e36ac66c66bff5b0bf58d0ae8a7da0831587fae4bc705
MD5 522cfcba6e197ff1e6e6108669547d1f
BLAKE2b-256 8c3392f9d1e0c66de5a9d9174961e000298337c79eacdef7b29825f346ee8ec0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page