Streaming
By default, when you request a completion from Empower, the entire completion is generated and sent back in a single response. For longer completions, the wait for a response can extend over several seconds.
To receive responses more promptly, you can ‘stream’ the completion as it’s being generated. This approach allows you to begin printing or processing the beginning of the completion before it is completely finished. This is particularly useful in chat experiences where providing users with the best experience involves delivering responses as soon as they are ready.
How to use
To stream completions, set stream=true
when calling the chat completions api.
This returns an object that streams the response as data-only server-sent events. To extract chunks,
use the delta field instead of the message field.
Empower supports the streaming in both message and tool use responses.
Code Example
The Empower API is fully compatible with the OpenAI API. Below, we will provide a few code examples demonstrating how to utilize this compatibility using the OpenAI SDK:
Output