instructor icon indicating copy to clipboard operation
instructor copied to clipboard

Async completions type checking error

Open chrisgoddard opened this issue 6 months ago • 2 comments

Instructor 1.3.7 Python 3.12.3

Here's my example code:

client = instructor.from_litellm(litellm.acompletion, mode=instructor.mode.Mode.PARALLEL_TOOLS)

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

class Company(BaseModel):
    name: str
    location: str


r = await client.chat.completions.create( 
    model="gpt-4o-mini",
    messages=[
        {
           
            "role": "user",
            "content": """
            John Smith, 29, works for Acme Corporation in San Francisco.
            """
           
        }
    ],
    response_model=typing.Iterable[Person | Company],
)

for obj in r:
    print(obj)
    

Pylance gives me these errors: Screenshot 2024-07-30 at 2 35 00 PM

However this seems to happen even without the parallel tools option Screenshot 2024-07-30 at 2 37 36 PM

Is there something different I'm supposed to do to get async type hints working correctly?

chrisgoddard avatar Jul 30 '24 21:07 chrisgoddard