Skip to content

Commit

Permalink
set LLM balUpdate status to ReceivedChange to calculate overpayment c…
Browse files Browse the repository at this point in the history
…redit
  • Loading branch information
ad-astra-video authored and rickstaa committed Jan 27, 2025
1 parent bb145c7 commit 29a291f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,12 @@ func submitLLM(ctx context.Context, params aiRequestParams, sess *AISession, req
return nil, fmt.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(body))
}

// We treat a response as "receiving change" where the change is the difference between the credit and debit for the update
// TODO: move to after receive stream response in handleSSEStream and handleNonStreamingResponse to count input tokens
if balUpdate != nil {
balUpdate.Status = ReceivedChange
}

Check warning on line 1174 in server/ai_process.go

View check run for this annotation

Codecov / codecov/patch

server/ai_process.go#L1172-L1174

Added lines #L1172 - L1174 were not covered by tests

if req.Stream != nil && *req.Stream {
return handleSSEStream(ctx, resp.Body, sess, req, start)
}
Expand Down

0 comments on commit 29a291f

Please sign in to comment.