feat: add wallet settlement audit flow
This commit is contained in:
@@ -21,6 +21,13 @@ func (s *Service) Estimate(ctx context.Context, kind string, model string, body
|
||||
return EstimateResult{}, err
|
||||
}
|
||||
candidate := candidates[0]
|
||||
return EstimateResult{
|
||||
Items: s.estimatedBillings(ctx, user, kind, body, candidate),
|
||||
Resolver: "effective-pricing-v1",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) estimatedBillings(ctx context.Context, user *auth.User, kind string, body map[string]any, candidate store.RuntimeModelCandidate) []any {
|
||||
usage := clients.Usage{InputTokens: estimateRequestTokens(body), OutputTokens: int(floatFromAny(body["max_tokens"]))}
|
||||
if usage.OutputTokens == 0 {
|
||||
usage.OutputTokens = 64
|
||||
@@ -31,10 +38,7 @@ func (s *Service) Estimate(ctx context.Context, kind string, model string, body
|
||||
"completion_tokens": usage.OutputTokens,
|
||||
"total_tokens": usage.TotalTokens,
|
||||
}}}
|
||||
return EstimateResult{
|
||||
Items: s.billings(ctx, user, kind, body, candidate, response, true),
|
||||
Resolver: "effective-pricing-v1",
|
||||
}, nil
|
||||
return s.billings(ctx, user, kind, body, candidate, response, true)
|
||||
}
|
||||
|
||||
func (s *Service) billings(ctx context.Context, user *auth.User, kind string, body map[string]any, candidate store.RuntimeModelCandidate, response clients.Response, simulated bool) []any {
|
||||
|
||||
Reference in New Issue
Block a user