Skip to content

Commit 7d51f5a

Browse files
set LLM balUpdate status to ReceivedChange to calculate overpayment credit
1 parent b97e791 commit 7d51f5a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

server/ai_process.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,12 @@ func submitLLM(ctx context.Context, params aiRequestParams, sess *AISession, req
11671167
return nil, fmt.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(body))
11681168
}
11691169

1170+
// We treat a response as "receiving change" where the change is the difference between the credit and debit for the update
1171+
// TODO: move to after receive stream response in handleSSEStream and handleNonStreamingResponse to count input tokens
1172+
if balUpdate != nil {
1173+
balUpdate.Status = ReceivedChange
1174+
}
1175+
11701176
if req.Stream != nil && *req.Stream {
11711177
return handleSSEStream(ctx, resp.Body, sess, req, start)
11721178
}

0 commit comments

Comments
 (0)