Skip to content

Commit c125ae2

Browse files
authored
Fix for removing usage in every stream chunk response. (#1022)
* Fix for #1021: 1. Make Usage field in completions Response to pointer. * Fix for #1021: 1. Make Usage field in completions Response to pointer. 2. Add omitempty to json tag Signed-off-by: Hritik003 <hritik.raj@nutanix.com> --------- Signed-off-by: Hritik003 <hritik.raj@nutanix.com>
1 parent a931bf7 commit c125ae2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ type CompletionResponse struct {
242242
Created int64 `json:"created"`
243243
Model string `json:"model"`
244244
Choices []CompletionChoice `json:"choices"`
245-
Usage Usage `json:"usage"`
245+
Usage *Usage `json:"usage,omitempty"`
246246

247247
httpHeader
248248
}

completion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func handleCompletionEndpoint(w http.ResponseWriter, r *http.Request) {
192192
}
193193
inputTokens *= n
194194
completionTokens := completionReq.MaxTokens * len(prompts) * n
195-
res.Usage = openai.Usage{
195+
res.Usage = &openai.Usage{
196196
PromptTokens: inputTokens,
197197
CompletionTokens: completionTokens,
198198
TotalTokens: inputTokens + completionTokens,

0 commit comments

Comments
 (0)