feat: implement reasoning_tokens tracking and enhanced usage logging
This commit is contained in:
@@ -722,6 +722,10 @@ impl super::Provider for GeminiProvider {
|
||||
let reasoning_content = candidate
|
||||
.and_then(|c| c.content.parts.iter().find_map(|p| p.thought.clone()));
|
||||
|
||||
let reasoning_tokens = reasoning_content.as_ref()
|
||||
.map(|r| crate::utils::tokens::estimate_completion_tokens(r, &model))
|
||||
.unwrap_or(0);
|
||||
|
||||
// Extract function calls → OpenAI tool_calls
|
||||
let tool_calls = candidate.and_then(|c| Self::extract_tool_calls(&c.content.parts));
|
||||
|
||||
@@ -752,6 +756,7 @@ impl super::Provider for GeminiProvider {
|
||||
tool_calls,
|
||||
prompt_tokens,
|
||||
completion_tokens,
|
||||
reasoning_tokens,
|
||||
total_tokens,
|
||||
cache_read_tokens,
|
||||
cache_write_tokens: 0, // Gemini doesn't report cache writes separately
|
||||
@@ -902,6 +907,7 @@ impl super::Provider for GeminiProvider {
|
||||
super::StreamUsage {
|
||||
prompt_tokens: u.prompt_token_count,
|
||||
completion_tokens: u.candidates_token_count,
|
||||
reasoning_tokens: 0,
|
||||
total_tokens: u.total_token_count,
|
||||
cache_read_tokens: u.cached_content_token_count,
|
||||
cache_write_tokens: 0,
|
||||
|
||||
Reference in New Issue
Block a user