Skip to content

Commit 7d31282

Browse files
feat(usage): add requested model usage metadata helpers
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 1b3e5c6 commit 7d31282

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

backend/internal/service/usage_log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ type UsageLog struct {
9898
AccountID int64
9999
RequestID string
100100
Model string
101+
// RequestedModel is the client-requested model name recorded for stable user/admin display.
102+
// Empty should be treated as Model for backward compatibility with historical rows.
103+
RequestedModel string
101104
// UpstreamModel is the actual model sent to the upstream provider after mapping.
102105
// Nil means no mapping was applied (requested model was used as-is).
103106
UpstreamModel *string

backend/internal/service/usage_log_helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ func optionalNonEqualStringPtr(value, compare string) *string {
1919
}
2020
return &value
2121
}
22+
23+
func forwardResultBillingModel(requestedModel, upstreamModel string) string {
24+
if trimmedUpstream := strings.TrimSpace(upstreamModel); trimmedUpstream != "" {
25+
return trimmedUpstream
26+
}
27+
return strings.TrimSpace(requestedModel)
28+
}

0 commit comments

Comments
 (0)