You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extraction_stream = client.chat.completions.create_partial(
model="gpt-4",
response_model=MeetingInfo,
messages=[
{
"role": "user",
"content": f"Get the information about the meeting and the users {text_block}",
},
],
stream=True,
)
console = Console()
for extraction in extraction_stream:
obj = extraction.model_dump()
console.clear()
console.print(obj)
It's clear from the docs that
When specifying a create_partial and setting stream=True, the response from instructor becomes a Generator[T]. As the generator yields results, you can iterate over these incremental updates. The last value yielded by the generator represents the completed extraction!
this is supposed to return a Generator rather than an AsyncGenerator. The async for needs to be used OUTSIDE of the agent with the above fixes:
e.g.
async for partial in agent.run_async(user_input):
console.clear()
console.print(partial )
The text was updated successfully, but these errors were encountered:
Note: Running python3.12 on Ubuntu (WSL)
Problem:
Attempting to use the run_async method gives me the following error:
After digging around for a bit, here's what I found in the instructor documentation:
https://python.useinstructor.com/concepts/partial/?h=partial#understanding-partial-responses
It's clear from the docs that
this is supposed to return a Generator rather than an AsyncGenerator. The async for needs to be used OUTSIDE of the agent with the above fixes:
e.g.
The text was updated successfully, but these errors were encountered: