Request a Call Back

What is the best way to stream partial structured data using Instructor?


I'm building a real-time dashboard and I want to show the LLM's progress as it generates a large list of items. I’m using Instructor, but I'm not sure how to handle partial objects. Is there a specific way to iterate over a response so that the UI updates as each field is filled in, rather than waiting for the entire JSON block to finish?


   2025-05-25 in Software Development by Matthew Wilson | 9841 Views


All answers to this question.


You should look into the Partial type provided by the library. When you wrap your model in Partial[MyModel], the library uses a specialized parser that can handle incomplete JSON strings. You then use stream=True in your completion call and iterate through the generator. Each iteration yields a Pydantic object with whatever fields have been populated so far. I used this for a travel itinerary generator where the flight details appeared instantly while the hotel descriptions were still being "typed" by the model. It makes the app feel incredibly fast.

   Answered 2025-05-26 by Cynthia Roberts


Can we use this streaming feature with local models like Llama 3 running through Ollama, or is it restricted to the OpenAI API?

   Answered 2025-05-27 by Patrick Harris

  • Patrick, it definitely works with local models! As long as the provider supports the OpenAI-compatible streaming protocol, the library can patch it. I’ve personally tested it with Ollama and it works great for extracting structured data from local inference without the latency of a full round-trip.

       Commented 2025-05-28 by Matthew Wilson


The user experience improvement is massive when you aren't staring at a loading spinner for ten seconds.

   Answered 2025-05-29 by Brian Anderson

  • Spot on, Brian. For long extractions, streaming partial results is the only way to keep users engaged.

       Commented 2025-05-30 by Cynthia Roberts



Write a Comment

Your email address will not be published. Required fields are marked (*)




Suggested Questions

Introduction to Project Management..
Posted 2026-07-07 by learnersera.
Balancing Link Metrics With Structural Entity Maps..
Posted 2025-05-12 by learnersera.
Balancing Link Metrics With Structural Entity Maps..
Posted 2025-05-12 by learnersera.
Impact of Entity Authority on Organic Competitive..
Posted 2025-01-04 by learnersera.
Backlinks vs Entity Authority for SEO Rankings..
Posted 2025-04-14 by learnersera.
How are modern agile organizations evaluating scrum..
Posted 2025-07-19 by learnersera.
Is a specialized technical degree required to..
Posted 2025-10-05 by learnersera.
How heavily do hiring managers weigh professional..
Posted 2025-09-12 by learnersera.

Disclaimer

  • "PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc.
  • "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA.
  • COBIT® is a trademark of ISACA® registered in the United States and other countries.
  • CBAP® and IIBA® are registered trademarks of International Institute of Business Analysis™.

We Accept

We Accept

Follow Us

 facebook icon
 twitter
linkedin

Instagram
twitter
Youtube

Quick Enquiry Form

WhatsApp Us  /      +1 (713)-287-1187