Skip to main content

OpenAI SDK with OmegaEngine governance - AI safety and compliance

Project description

OmegaEngine Logo

openai-omega

OpenAI Integration with OmegaEngine Governance

PyPI License

DocumentationPlaygroundIssues


✨ Features

  • 🤖 Drop-in Replacement — Same API as official OpenAI SDK
  • 🛡️ Pre-flight Validation — Block unsafe prompts before sending
  • 📊 Response Governance — Filter outputs against policies
  • 📈 Full Audit Trail — Log every GPT-4/GPT-5 interaction
  • Streaming Support — Governed streaming responses
  • 🔧 Function Call Validation — Validate tool calls before execution
  • 🎯 Assistants API — Govern OpenAI Assistants

📦 Installation

Python

pip install openai-omega

🚀 Quick Start (Python)

from openai_omega import OpenAI

# Drop-in replacement for OpenAI client
client = OpenAI(
    openai_api_key="your-openai-key",
    omega_api_key="your-omega-key",
    policy_id="gpt_policy",
)

# Same API, but governed
response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
        {"role": "user", "content": "Help me with marketing"}
    ]
)

print(response.choices[0].message.content)

# Access governance metadata
print(response.omega_decision)      # "ALLOW" | "BLOCK" | "ESCALATE"
print(response.omega_audit_id)      # "aud_abc123"
print(response.omega_risk_score)    # 15


🛡️ Pre-flight Validation

Block unsafe prompts before they reach OpenAI:

client = OpenAI(
    openai_api_key="...",
    omega_api_key="...",
    preflight_check=True,
    block_on_deny=True,
)

try:
    response = client.chat.completions.create(
        model="gpt-4-turbo",
        messages=[{"role": "user", "content": "...jailbreak attempt..."}]
    )
except OmegaBlockedError as e:
    print(f"Blocked: {e.reason}")
    print(f"Risk score: {e.risk_score}")

🔧 Function Call Governance

Validate function/tool calls before execution:

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[...],
    tools=[...],
    omega_validate_tools=True,  # Validate tool calls
)

for tool_call in response.choices[0].message.tool_calls:
    if tool_call.omega_approved:
        execute_tool(tool_call)
    else:
        print(f"Tool blocked: {tool_call.omega_reason}")

📡 Governed Streaming

with client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[{"role": "user", "content": "Write a story"}],
    stream=True,
) as stream:
    for chunk in stream:
        print(chunk.choices[0].delta.content, end="")

print(f"\nDecision: {stream.omega_decision}")

🤖 Assistants API Support

# Governed Assistants
assistant = client.beta.assistants.create(
    name="Analyst",
    model="gpt-4-turbo",
    omega_policy_id="assistant_policy",
)

# All threads are governed
thread = client.beta.threads.create()
message = client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content="Analyze this data..."
)

run = client.beta.threads.runs.create(
    thread_id=thread.id,
    assistant_id=assistant.id,
)

# Access governance metadata
print(run.omega_audit_id)

📊 What Gets Logged

Field Logged
Input messages
Output response
Token usage
Model used
Latency
Policy evaluation
Risk score
Function calls
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 Distribution

openai_omega-0.2.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

openai_omega-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file openai_omega-0.2.0.tar.gz.

File metadata

  • Download URL: openai_omega-0.2.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for openai_omega-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c10a510a81022704484e60a210b6152100f765505caa28226c500747e7150c2e
MD5 52a2ab14c4e443c4745d1857511c4067
BLAKE2b-256 59454b64da5fbfd6c357b2d7537fdc32389de473034d796946b6398413c59a64

See more details on using hashes here.

File details

Details for the file openai_omega-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: openai_omega-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for openai_omega-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b27c639fc262a89cd35e5fa6260f0812216cfa02a50980615c37bfc316e1f6ea
MD5 fc6fb460b704e2f3fd801bb43f8a1ee6
BLAKE2b-256 42387643475e3a6a7c63f40d92545958ff7ebd672fbf6a4daa3afd6fc58b6074

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