Skip to main content

OpenTelemetry instrumentation for Instructor

Project description

Instructor OpenTelemetry Integration

Overview

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

Installation

  1. Install traceAI Instructor
pip install traceAI-instructor

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="instructor_app"
)

Configure Instructor Instrumentation

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

from traceai_instructor import InstructorInstrumentor

InstructorInstrumentor().instrument(tracer_provider=trace_provider)

Create Instructor Components

Set up your Instructor client with built-in observability.

import instructor
from openai import OpenAI
from pydantic import BaseModel

# Define the output structure
class UserInfo(BaseModel):
    name: str
    age: int

# Patch the OpenAI client
client = instructor.patch(client=OpenAI())

user_info = client.chat.completions.create(
    model="gpt-3.5-turbo",
    response_model=UserInfo,
    messages=[
        {
            "role": "system",
            "content": "Extract the name and age from the text and return them in a structured format.",
        },
        {"role": "user", "content": "John Doe is nine years old."},
    ],
)

print(user_info, type(user_info))

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_instructor-0.2.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

traceai_instructor-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_instructor-0.2.0.tar.gz
  • Upload date:
  • Size: 4.2 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_instructor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 16a2eff79367b131cdbf3e0c511973ef88d3b4fe6492b030d8d8830b056c092d
MD5 5553eddb95d9386af37305d778269369
BLAKE2b-256 18315d4a77debcc157ff4bc9e5e9f19572dfbd2a9c8965bee7b19545b4ac2ac4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_instructor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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_instructor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40518e03b234617c7fe8519c8c2fecc1eb51624e2026da351b0bef0e56a9b83c
MD5 00e873c7c96eae8572e984d77765319c
BLAKE2b-256 7417ca535266a908025016277c0093d6005a47872191d759eae3946b86924bdd

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