Skip to main content

OpenInference Instructor Instrumentation

Project description

OpenInference Instructor Instrumentation

pypi

Python auto-instrumentation library for the (Instructor)[https://github.com/jxnl/instructor] library

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

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

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.17.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_instructor-0.1.17.tar.gz
Algorithm Hash digest
SHA256 30e004c5ce99fae8c34ecbd1c5117c4a1aa5c2621360b64911f59e922e17010f
MD5 43d2ff11880750f7d5e96cec16990732
BLAKE2b-256 3c20ddc36e1f2b9dcf45f2047256011d4a9e961db604be815179105b1d1e5126

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_instructor-0.1.17.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.17-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_instructor-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 07697a4482018febd58edb0aabce96db846e3a4b71c8b1849b2aafc2b4452fd5
MD5 c82fac1541950b83d0fb54a5779d040c
BLAKE2b-256 0a952d368fd1c96fbca2b83966552713eb7105db0a5626d2fe09b73d9daf43b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_instructor-0.1.17-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.

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