Enable streaming UI updates for chat responses

This commit is contained in:
2025-10-01 20:09:40 +02:00
parent 4271ee3d73
commit a3e6b105d0
5 changed files with 375 additions and 162 deletions

View File

@@ -37,6 +37,19 @@ type ChatCompletionResponse struct {
Usage Usage `json:"usage"`
}
// ChatCompletionStreamEvent represents a single chunk in a streaming chat completion.
type ChatCompletionStreamEvent struct {
ID string `json:"-"`
Role string `json:"-"`
Content string `json:"-"`
FinishReason string `json:"-"`
Usage *Usage `json:"-"`
Done bool `json:"-"`
}
// ChatCompletionStreamHandler consumes streaming completion events.
type ChatCompletionStreamHandler func(ChatCompletionStreamEvent) error
// APIError captures structured error responses returned by the API.
type APIError struct {
Message string `json:"message"`