fix: resolve clippy warnings (matches!, map_or, redundant guard, unnecessary allocations)
This commit is contained in:
@@ -233,7 +233,7 @@ async fn chat_completions_stream(
|
||||
"finish_reason": "stop",
|
||||
}],
|
||||
})).unwrap_or_default()));
|
||||
yield Ok(Event::default().data("[DONE]".to_string()));
|
||||
yield Ok(Event::default().data("[DONE]"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ async fn chat_completions_stream(
|
||||
"finish_reason": "stop",
|
||||
}],
|
||||
})).unwrap_or_default()));
|
||||
yield Ok(Event::default().data("[DONE]".to_string()));
|
||||
yield Ok(Event::default().data("[DONE]"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ async fn chat_completions_stream(
|
||||
"finish_reason": "stop",
|
||||
}],
|
||||
})).unwrap_or_default()));
|
||||
yield Ok(Event::default().data("[DONE]".to_string()));
|
||||
yield Ok(Event::default().data("[DONE]"));
|
||||
};
|
||||
|
||||
Sse::new(stream)
|
||||
|
||||
@@ -237,14 +237,14 @@ pub(crate) async fn poll_for_response(
|
||||
info!(
|
||||
"Response done ({short_id}), {:.1}s, {} chars, tokens: {}in/{}out ({}){}{}",
|
||||
elapsed, text.len(), u.input_tokens, u.output_tokens, u.model,
|
||||
if thinking.is_some() { format!(", thinking: {} chars", thinking.as_ref().unwrap().len()) } else { String::new() },
|
||||
thinking.as_ref().map_or(String::new(), |t| format!(", thinking: {} chars", t.len())),
|
||||
if thinking_signature.is_some() { ", has sig" } else { "" }
|
||||
);
|
||||
} else {
|
||||
info!(
|
||||
"Response done ({short_id}), {:.1}s, {} chars (no usage){}{}",
|
||||
elapsed, text.len(),
|
||||
if thinking.is_some() { format!(", thinking: {} chars", thinking.as_ref().unwrap().len()) } else { String::new() },
|
||||
thinking.as_ref().map_or(String::new(), |t| format!(", thinking: {} chars", t.len())),
|
||||
if thinking_signature.is_some() { ", has sig" } else { "" }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ pub(crate) async fn handle_responses(
|
||||
.send_message(&cascade_id, &user_text, model.model_enum)
|
||||
.await
|
||||
{
|
||||
Ok((status, _)) if status == 200 => {
|
||||
Ok((200, _)) => {
|
||||
let bg = Arc::clone(&state.backend);
|
||||
let cid = cascade_id.clone();
|
||||
tokio::spawn(async move {
|
||||
|
||||
@@ -141,6 +141,7 @@ pub(crate) struct OutputTokensDetails {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Reasoning {
|
||||
pub effort: Option<String>,
|
||||
pub summary: Option<String>,
|
||||
@@ -161,8 +162,8 @@ impl Usage {
|
||||
/// Estimate token counts from actual text.
|
||||
/// Uses ~4 chars/token heuristic (standard GPT tokenizer average).
|
||||
pub fn estimate(input_text: &str, output_text: &str) -> Self {
|
||||
let input_tokens = (input_text.len() as u64 + 3) / 4;
|
||||
let output_tokens = (output_text.len() as u64 + 3) / 4;
|
||||
let input_tokens = (input_text.len() as u64).div_ceil(4);
|
||||
let output_tokens = (output_text.len() as u64).div_ceil(4);
|
||||
Self {
|
||||
input_tokens,
|
||||
input_tokens_details: InputTokensDetails { cached_tokens: 0 },
|
||||
@@ -189,14 +190,6 @@ impl Default for Usage {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Reasoning {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
effort: None,
|
||||
summary: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TextFormat {
|
||||
fn default() -> Self {
|
||||
|
||||
Reference in New Issue
Block a user