Skip to content

0.3.0

Compare
Choose a tag to compare
@jxnl jxnl released this 08 Nov 20:24
· 814 commits to main since this release

Upgrading to openai 1.1.0

Usage

from openai import OpenAI()
import instructor

# Enables `response_model`
client = instructor.patch(OpenAI())

class UserDetail(BaseModel):
    name: str
    age: int

user = client.chat.completions.create(
    model="gpt-3.5-turbo",
    response_model=UserDetail,
    messages=[
        {"role": "user", "content": "Extract Jason is 25 years old"},
    ]
)

assert isinstance(user, UserDetail)
assert user.name == "Jason"
assert user.age == 25

note "Using openai<1.0.0"

If you're using openai<1.0.0 then make sure you pip install instructor<0.3.0
where you can patch a global client like so:

import openai
import instructor

instructor.patch()

user = openai.ChatCompletion.create(
    ...,
    response_model=UserDetail,
)

What's Changed

  • Migration to OpenAI 1.1.0 by @grit-app in #152

New Contributors

  • @grit-app made their first contribution in #152

Full Changelog: 0.2.11...0.3.0