Skip to content

Commit cf0e4ed

Browse files
committed
fixup
1 parent 42a7af4 commit cf0e4ed

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

codex-rs/core/src/chat_completions.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,27 +495,27 @@ async fn append_reasoning_text(
495495
fn parse_openai_usage(usage: &serde_json::Value) -> Option<TokenUsage> {
496496
let prompt_tokens = usage
497497
.get("prompt_tokens")
498-
.and_then(|v| v.as_i64())
498+
.and_then(serde_json::Value::as_i64)
499499
.unwrap_or(0);
500500
let completion_tokens = usage
501501
.get("completion_tokens")
502-
.and_then(|v| v.as_i64())
502+
.and_then(serde_json::Value::as_i64)
503503
.unwrap_or(0);
504504
let total_tokens = usage
505505
.get("total_tokens")
506-
.and_then(|v| v.as_i64())
506+
.and_then(serde_json::Value::as_i64)
507507
.unwrap_or(0);
508508

509509
let cached_input_tokens = usage
510510
.get("prompt_tokens_details")
511511
.and_then(|d| d.get("cached_tokens"))
512-
.and_then(|v| v.as_i64())
512+
.and_then(serde_json::Value::as_i64)
513513
.unwrap_or(0);
514514

515515
let reasoning_output_tokens = usage
516516
.get("completion_tokens_details")
517517
.and_then(|d| d.get("reasoning_tokens"))
518-
.and_then(|v| v.as_i64())
518+
.and_then(serde_json::Value::as_i64)
519519
.unwrap_or(0);
520520

521521
Some(TokenUsage {
@@ -622,10 +622,10 @@ async fn process_chat_sse<S>(
622622
};
623623
trace!("chat_completions received SSE chunk: {chunk:?}");
624624

625-
if let Some(id) = chunk.get("id").and_then(|s| s.as_str()) {
626-
if response_id.is_empty() {
627-
response_id = id.to_string();
628-
}
625+
if let Some(id) = chunk.get("id").and_then(|s| s.as_str())
626+
&& response_id.is_empty()
627+
{
628+
response_id = id.to_string();
629629
}
630630

631631
if let Some(usage) = chunk.get("usage") {

0 commit comments

Comments
 (0)