mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 02:17:46 +08:00
feat(usage): surface Gemini thinkingConfig as reasoning effort
Usage records show a reasoning badge next to the model name for OpenAI and Claude requests, but Gemini requests never got one. The extraction only read the OpenAI/Claude shapes (`reasoning_effort`, `reasoning.effort`, `output_config.effort`), while Gemini states its reasoning depth inside `generationConfig.thinkingConfig` — so nothing was written to the usage metadata and the list and detail views had no badge to render. Read the Gemini shape too, as a fallback after the existing three so the OpenAI and Claude paths are untouched: - `thinkingLevel` / `thinking_level` wins when present, trimmed and lowercased, with the protobuf enum prefix stripped so `THINKING_LEVEL_HIGH` resolves like `high`. - Otherwise `thinkingBudget` / `thinking_budget` goes through the existing shared budget ladder, yielding the same `low|medium|high|xhigh` vocabulary the badge already understands. - Both camelCase and snake_case spellings are read, so a captured client body and a converted provider body resolve to the same label. - `includeThoughts` alone is a visibility flag, not a depth, and produces no badge. Two cases are handled explicitly rather than through the shared ladder: - `thinkingBudget: 0` disables reasoning outright. The shared ladder maps `0..=1664` to `low`, which would report an explicitly disabled request as a shallow one, so it reports `none` instead. - `THINKING_LEVEL_UNSPECIFIED` is the enum's "no explicit level" member, not a depth; it is rejected rather than surfaced as an `unspecified` badge. The frontend needs no change: `UsageModelDisplay` already renders the badge whenever the fields are present, and keeps the `high -> xhigh` mapping format when the requested and upstream efforts differ.
This commit is contained in:
@@ -1905,6 +1905,29 @@ mod tests {
|
||||
assert_eq!(active["reasoning_effort"], "max");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn user_usage_payloads_expose_gemini_thinking_config_reasoning_mapping() {
|
||||
let item = StoredRequestUsageAudit {
|
||||
request_body: Some(json!({
|
||||
"generationConfig": {
|
||||
"thinkingConfig": { "includeThoughts": true, "thinkingLevel": "HIGH" }
|
||||
}
|
||||
})),
|
||||
provider_request_body: Some(json!({
|
||||
"generationConfig": { "thinkingConfig": { "thinkingBudget": 8192 } }
|
||||
})),
|
||||
..sample_usage("completed")
|
||||
};
|
||||
|
||||
let record = build_users_me_usage_record_payload(&item, false, &BTreeMap::new(), false);
|
||||
let active = build_users_me_usage_active_payload(&item);
|
||||
|
||||
assert_eq!(record["requested_reasoning_effort"], "high");
|
||||
assert_eq!(active["requested_reasoning_effort"], "high");
|
||||
assert_eq!(record["reasoning_effort"], "xhigh");
|
||||
assert_eq!(active["reasoning_effort"], "xhigh");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn user_usage_payloads_expose_websocket_transport() {
|
||||
let item = StoredRequestUsageAudit {
|
||||
|
||||
Reference in New Issue
Block a user