chore: fix all clippy warnings and add Cargo.toml metadata
This commit is contained in:
@@ -401,7 +401,7 @@ pub(crate) async fn handle_completions(
|
||||
);
|
||||
}
|
||||
|
||||
let n = (body.n.max(1)).min(5); // Cap at 5 to prevent abuse
|
||||
let n = body.n.clamp(1, 5); // Cap at 5 to prevent abuse
|
||||
if n > 1 && body.stream {
|
||||
warn!("n={n} requested with streaming — streaming only supports n=1, ignoring n");
|
||||
}
|
||||
@@ -594,31 +594,25 @@ pub(crate) async fn handle_completions(
|
||||
// n > 1: fire additional (n-1) parallel cascades
|
||||
let mut extra_cascade_ids = Vec::with_capacity((n - 1) as usize);
|
||||
for _ in 1..n {
|
||||
match state.backend.create_cascade().await {
|
||||
Ok(cid) => {
|
||||
// Send the same message on each extra cascade
|
||||
match state
|
||||
.backend
|
||||
.send_message_with_image(
|
||||
&cid,
|
||||
&format!(".<cid:{}>", cid),
|
||||
model.model_enum,
|
||||
image.as_ref(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok((200, _)) => {
|
||||
let bg = Arc::clone(&state.backend);
|
||||
let cid2 = cid.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = bg.update_annotations(&cid2).await;
|
||||
});
|
||||
extra_cascade_ids.push(cid);
|
||||
}
|
||||
_ => {} // Skip failed cascades
|
||||
}
|
||||
if let Ok(cid) = state.backend.create_cascade().await {
|
||||
// Send the same message on each extra cascade
|
||||
if let Ok((200, _)) = state
|
||||
.backend
|
||||
.send_message_with_image(
|
||||
&cid,
|
||||
&format!(".<cid:{}>", cid),
|
||||
model.model_enum,
|
||||
image.as_ref(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
let bg = Arc::clone(&state.backend);
|
||||
let cid2 = cid.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = bg.update_annotations(&cid2).await;
|
||||
});
|
||||
extra_cascade_ids.push(cid);
|
||||
}
|
||||
Err(_) => {} // Skip failed cascade creation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,6 +708,7 @@ pub(crate) async fn handle_completions(
|
||||
// ─── Streaming ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// Streaming output in Chat Completions format.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn chat_completions_stream(
|
||||
state: Arc<AppState>,
|
||||
completion_id: String,
|
||||
|
||||
Reference in New Issue
Block a user