-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
area/apibugSomething isn't workingSomething isn't workingup for grabsTickets that no-one is currently working onTickets that no-one is currently working on
Description
LocalAI version:
274ace2
Describe the bug
When enabling the stream API each choice completion object is missing the finish_reason property except for the last message
To Reproduce:
Example response from LocalAI:
data: {"object":"chat.completion.chunk","model":"ggml-gpt4all-j","choices":[{"delta":{"role":"assistant"}}],"usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}
data: {"object":"chat.completion.chunk","model":"ggml-gpt4all-j","choices":[{"delta":{"content":"1"}}],"usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}
data: {"object":"chat.completion.chunk","model":"ggml-gpt4all-j","choices":[{"delta":{"content":" 2"}}],"usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}
data: {"object":"chat.completion.chunk","model":"ggml-gpt4all-j","choices":[{"delta":{"content":" 3"}}],"usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}
Expected behavior
Each message should contain the finish_reason property set to null instead of omitting it entirely
Example:
data: {"id":"chatcmpl-blablabla","object":"chat.completion.chunk","created":1684665888,"model":"gpt-4-0314","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-blablabla","object":"chat.completion.chunk","created":1684665888,"model":"gpt-4-0314","choices":[{"delta":{"content":"1"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-blablabla","object":"chat.completion.chunk","created":1684665888,"model":"gpt-4-0314","choices":[{"delta":{"content":" "},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-blablabla","object":"chat.completion.chunk","created":1684665888,"model":"gpt-4-0314","choices":[{"delta":{"content":"2"},"index":0,"finish_reason":null}]}
Additional context
Previously partially addressed by #341
Metadata
Metadata
Assignees
Labels
area/apibugSomething isn't workingSomething isn't workingup for grabsTickets that no-one is currently working onTickets that no-one is currently working on