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.3.0.tar.gz (15.2 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.3.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for openai_omega-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a4ec8e6b982ccdaa1b266c3abf550f2eac5affa8e769b3e3a8a5aeb67eda4335
MD5 505a408534317b4558371610b3814841
BLAKE2b-256 6141328929bea2a39ea6fb059e035ae558c5454f80d0d4cbe56d18cd7bbb8e36

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for openai_omega-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f8e28b6a789b96b46bdb5148a9c9068176ed9a0a22f296e2e17d3629a143a73
MD5 0fcd8ec2463ceb52da18bc2a7a671bef
BLAKE2b-256 b11614eda49ca132c433cd2abbb0b54d560bdda463d6038349325ee76346b7eb

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