-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from CerebriumAI/michael/cer-2466-write-examp…
…le-on-streaming-documentation Michael/cer 2466 write example on streaming documentation
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: "Streaming Endpoints" | ||
--- | ||
|
||
Streaming allows users to stream live output from their models using server-sent event (SSE) streams. This works for Python objects which implement the | ||
iterator protocol which is anything that essentially uses the 'yield' command in Python. You can return any content types as long as it is returned as a string | ||
|
||
<Note> | ||
This feature is currently in beta and so if you would like to stream output, | ||
please replace '**predict**' in your endpoint url with '**stream**' | ||
</Note> | ||
|
||
Let us see how we can implement a simple example below: | ||
|
||
```python | ||
def predict(item, run_id, logger): | ||
for i in range(10): | ||
yield f"Number {i} " | ||
time.sleep(1) | ||
``` | ||
|
||
Once you deploy this code snippet and hit the stream endpoint, you will see the SSE events progressively appear. The latest Postman has great functionality to show this. | ||
|
||
![Streaming](/images/cortex/streaming-postman.png) | ||
|
||
If you want to see an example of implementing this with Falcon-7b, please check out the example [here](https://github.com/CerebriumAI/examples/tree/master/7-streaming-endpoint) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters