Skip to main content

OpenTelemetry instrumentation for Guardrails

Project description

Guardrails OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the Guardrails framework. It enables tracing and monitoring of applications built with Guardrails.

Installation

  1. Install traceAI Guardrails
pip install traceAI-guardrails

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="guardrails_app"
)

Configure Guardrails Instrumentation

Instrument the Guardrails client to enable telemetry collection. This step ensures that all interactions with the Guardrails SDK are tracked and monitored.

from traceai_guardrails import GuardrailsInstrumentor

GuardrailsInstrumentor().instrument(tracer_provider=trace_provider)

Create Guardrails Components

Set up your Guardrails client with built-in observability.

from guardrails import Guard

guard = Guard()
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current temperature for a given location.",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "City and country e.g. Bogotá, Colombia"
                }
            },
            "required": [
                "location"
            ],
            "additionalProperties": False
        },
        "strict": True
    }
}]

result = guard(
    messages=[
            {
                "role": "user",
                "content": "What is the weather in Delhi?",
            },
        ],
    model="gpt-4o",
    tools=tools

)

print(f"{result}")

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

traceai_guardrails-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

traceai_guardrails-0.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_guardrails-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for traceai_guardrails-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7d97ca04f66d87e6bf50e70a94a838d78dad90d401c099851ebf017209027a2c
MD5 f29b71d87be2d7bc6a8156e8567aaaaf
BLAKE2b-256 11dcf34e6e0d91b3afc089ec306b4c1af42ea9438ed2b7f13ac3cab8c6032bae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_guardrails-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for traceai_guardrails-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a918020215b9e49bcfd8a779641ede163e7f00811d023e090bd7df4a6a2925b
MD5 72a4709852b63b47378b8ebf17f14e3f
BLAKE2b-256 70cb02d7a5066cf08e3c15c56d77de99625d241d4748daa9073cc8df887b4113

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