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
- 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))
Metadata
Release files for traceAI-instructor 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_instructor-0.2.0.tar.gz | 4.2 kB | Without provenance | Details for traceai_instructor-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_instructor-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for traceai_instructor-0.2.0-py3-none-any.whl |
Total release size: 9.4 kB
Release files / traceai_instructor-0.2.0.tar.gz
| Download URL | traceai_instructor-0.2.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16a2eff79367b131cdbf3e0c511973ef88d3b4fe6492b030d8d8830b056c092d
|
|
BLAKE2b-256 checksum How to use checksums |
18315d4a77debcc157ff4bc9e5e9f19572dfbd2a9c8965bee7b19545b4ac2ac4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / traceai_instructor-0.2.0-py3-none-any.whl
| Download URL | traceai_instructor-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40518e03b234617c7fe8519c8c2fecc1eb51624e2026da351b0bef0e56a9b83c
|
|
BLAKE2b-256 checksum How to use checksums |
7417ca535266a908025016277c0093d6005a47872191d759eae3946b86924bdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for traceAI-instructor 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.