Use the Instructor Instrumentor to instrument your project.
from traceai_instructor import InstructorInstrumentorInstructorInstrumentor().instrument(tracer_provider=trace_provider)
5. Run your Instructor application.
Run your Instructor application as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.
import instructorfrom openai import OpenAIfrom pydantic import BaseModel# Define the output structureclass UserInfo(BaseModel): name: str age: int# Patch the OpenAI clientclient = 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))