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.1.4.tar.gz (5.9 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.1.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_guardrails-0.1.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_guardrails-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1d13b03ba3a3b84293deb9f69c8fb3df0a521c87cf156b20dd9f1b8a53c629b5
MD5 e01c5c016a22c35bf4a198f4643711b5
BLAKE2b-256 fbf1262f99858b1c9ea995b104e8804e56e642930f817c3f8b31635fc6098f83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceai_guardrails-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7f3ded66b8761f9b431966bb30cd7003f5f13f1d1499b8ecbd14bccbc3716e2e
MD5 2cd957ba64ef417ed0d5b29a01a854a3
BLAKE2b-256 9e2c593182c13652d0835b98b31da19dba33169acb232d296106be11bff6e0d7

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