Skip to content

Commit

Permalink
Document response stream chunk delimiter. (#632)
Browse files Browse the repository at this point in the history
Document response stream chunk delimiter.
  • Loading branch information
JayNakrani committed Sep 30, 2023
1 parent a1b2d95 commit 1d0ebe6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` a

All durations are returned in nanoseconds.

### Streaming responses

Certain endpoints stream responses as JSON objects delineated with the newline (`\n`) character.

## Generate a completion

```shell
Expand Down
1 change: 1 addition & 0 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func streamResponse(c *gin.Context, ch chan any) {
return false
}

// Delineate chunks with new-line delimiter
bts = append(bts, '\n')
if _, err := w.Write(bts); err != nil {
log.Printf("streamResponse: w.Write failed with %s", err)
Expand Down

0 comments on commit 1d0ebe6

Please sign in to comment.