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.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

traceai_guardrails-0.1.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_guardrails-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 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.3.tar.gz
Algorithm Hash digest
SHA256 5ab8a8c46db366ce0d9aa148551d79edd4a0d25cea36cc8dd1068a2cb30369b8
MD5 b5906fcc11a3f3141b29bc02caaa8e3d
BLAKE2b-256 f67e60be159051229edef5d62cc645f628d104eda8012449ab5854ff038d7191

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_guardrails-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe807887a0db3ae70cdb8485e67e07a66299d920d4c334f44275b8385af8903
MD5 ce821f7a7e3eb564f94a72ef1a3c942c
BLAKE2b-256 72c90d0959a69794703be534036ee3075a0f723c96f5648ecbed303ce6ae3ea6

See more details on using hashes here.

Supported by

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