Skip to main content

OpenInference Instructor Instrumentation

pypi

Python auto-instrumentation library for the Instructor library.

These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix or Arize AX.

Installation

pip install openinference-instrumentation-instructor

Quickstart

This quickstart shows you how to instrument Instructor

Install required packages.

pip install instructor arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp

Start Phoenix in the background as a collector. By default, it listens on http://localhost:6006. You can visit the app via a browser at the same address. (Phoenix does not send data over the internet. It only operates locally on your machine.)

python -m phoenix.server.main serve

Set up InstructorInstrumentor to trace your application and send the traces to Phoenix at the endpoint defined below.

from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
from openinference.instrumentation.instructor import InstructorInstrumentor
from openinference.instrumentation.openai import OpenAIInstrumentor

InstructorInstrumentor().instrument(tracer_provider=tracer_provider)

# Optionally instrument the OpenAI SDK to get additional observability
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)

Simple Instructor example

import instructor
from pydantic import BaseModel
from openai import OpenAI


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


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

# Extract structured data from natural language
user_info = client.chat.completions.create(
    model="gpt-3.5-turbo",
    response_model=UserInfo,
    messages=[{"role": "user", "content": "John Doe is 30 years old."}],
)

More Info

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

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

File details

Details for the file openinference_instrumentation_instructor-0.1.19.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_instructor-0.1.19.tar.gz
Algorithm Hash digest
SHA256 2dfe6b21e9ea6891353f6a4ffe50c223bee8c5522772891bb9c8c9ea908e0472
MD5 75ea9749a81ba92eb555a7ffdc7e2b97
BLAKE2b-256 19658b858cad01a9ea2180056c06e79a57703a3d060efcede53aac6c60f013d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_instructor-0.1.19.tar.gz:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openinference_instrumentation_instructor-0.1.19-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_instructor-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 638d7ce8a4b6ee3e639ea08b7087bcad73eb6b7df1ab4f9fdf8b0a1bb2bbbda6
MD5 7a2cd72685b505c517152729522e2635
BLAKE2b-256 0826ea4fdbffbbb5bdf6662ea0f0dd57de749987339a0dc4efe72cfd3c7630e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_instructor-0.1.19-py3-none-any.whl:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

This release

0.1.19 This release

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page