[router] Fix all unused_qualifications (#11341)
This commit is contained in:
@@ -827,8 +827,7 @@ impl StreamingProcessor {
|
||||
|
||||
// Store latest output logprobs (cumulative from proto, convert to SGLang format)
|
||||
if let Some(ref output_logprobs) = chunk.output_logprobs {
|
||||
let converted =
|
||||
super::utils::convert_generate_output_logprobs(output_logprobs);
|
||||
let converted = utils::convert_generate_output_logprobs(output_logprobs);
|
||||
accumulated_output_logprobs.insert(index, Some(converted));
|
||||
}
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ pub fn parse_json_schema_response(
|
||||
match serde_json::from_str::<Value>(processed_text) {
|
||||
Ok(params) => {
|
||||
let tool_call = ToolCall {
|
||||
id: format!("call_{}", uuid::Uuid::new_v4()),
|
||||
id: format!("call_{}", Uuid::new_v4()),
|
||||
tool_type: "function".to_string(),
|
||||
function: FunctionCallResponse {
|
||||
name: function.name.clone(),
|
||||
@@ -553,7 +553,7 @@ pub fn parse_json_schema_response(
|
||||
let parameters = obj.get("parameters")?;
|
||||
|
||||
Some(ToolCall {
|
||||
id: format!("call_{}_{}", i, uuid::Uuid::new_v4()),
|
||||
id: format!("call_{}_{}", i, Uuid::new_v4()),
|
||||
tool_type: "function".to_string(),
|
||||
function: FunctionCallResponse {
|
||||
name,
|
||||
|
||||
@@ -2016,7 +2016,7 @@ impl OpenAIRouter {
|
||||
///
|
||||
/// Returns borrowed strings when possible to avoid allocations in hot paths.
|
||||
/// Only allocates when multiple data lines need to be joined.
|
||||
fn parse_sse_block(block: &str) -> (Option<&str>, std::borrow::Cow<'_, str>) {
|
||||
fn parse_sse_block(block: &str) -> (Option<&str>, Cow<'_, str>) {
|
||||
let mut event_name: Option<&str> = None;
|
||||
let mut data_lines: Vec<&str> = Vec::new();
|
||||
|
||||
@@ -2029,9 +2029,9 @@ impl OpenAIRouter {
|
||||
}
|
||||
|
||||
let data = if data_lines.len() == 1 {
|
||||
std::borrow::Cow::Borrowed(data_lines[0])
|
||||
Cow::Borrowed(data_lines[0])
|
||||
} else {
|
||||
std::borrow::Cow::Owned(data_lines.join("\n"))
|
||||
Cow::Owned(data_lines.join("\n"))
|
||||
};
|
||||
|
||||
(event_name, data)
|
||||
@@ -2714,7 +2714,7 @@ impl OpenAIRouter {
|
||||
}
|
||||
ResponseInput::Items(items) => {
|
||||
// Items are already structured ResponseInputOutputItem, convert to JSON
|
||||
if let Ok(items_value) = serde_json::to_value(items) {
|
||||
if let Ok(items_value) = to_value(items) {
|
||||
if let Some(items_arr) = items_value.as_array() {
|
||||
input_array.extend_from_slice(items_arr);
|
||||
}
|
||||
@@ -2773,7 +2773,7 @@ impl OpenAIRouter {
|
||||
.unwrap_or("{}");
|
||||
|
||||
// Check if output contains error by parsing JSON
|
||||
let is_error = serde_json::from_str::<serde_json::Value>(output_str)
|
||||
let is_error = serde_json::from_str::<Value>(output_str)
|
||||
.map(|v| v.get("error").is_some())
|
||||
.unwrap_or(false);
|
||||
|
||||
@@ -3189,7 +3189,7 @@ impl super::super::RouterTrait for OpenAIRouter {
|
||||
let content_type = res.headers().get(CONTENT_TYPE).cloned();
|
||||
match res.bytes().await {
|
||||
Ok(body) => {
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = status;
|
||||
if let Some(ct) = content_type {
|
||||
response.headers_mut().insert(CONTENT_TYPE, ct);
|
||||
@@ -3316,7 +3316,7 @@ impl super::super::RouterTrait for OpenAIRouter {
|
||||
match resp.bytes().await {
|
||||
Ok(body) => {
|
||||
self.circuit_breaker.record_success();
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = status;
|
||||
if let Some(ct) = content_type {
|
||||
response.headers_mut().insert(CONTENT_TYPE, ct);
|
||||
|
||||
@@ -88,7 +88,7 @@ impl PDRouter {
|
||||
|
||||
match res.bytes().await {
|
||||
Ok(body) => {
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = StatusCode::OK;
|
||||
*response.headers_mut() = response_headers;
|
||||
response
|
||||
@@ -201,7 +201,7 @@ impl PDRouter {
|
||||
}
|
||||
obj.insert(
|
||||
"bootstrap_host".to_string(),
|
||||
Value::Array(hosts.into_iter().map(serde_json::Value::from).collect()),
|
||||
Value::Array(hosts.into_iter().map(Value::from).collect()),
|
||||
);
|
||||
obj.insert(
|
||||
"bootstrap_port".to_string(),
|
||||
@@ -209,7 +209,7 @@ impl PDRouter {
|
||||
ports
|
||||
.into_iter()
|
||||
.map(|p| match p {
|
||||
Some(v) => serde_json::Value::from(v),
|
||||
Some(v) => Value::from(v),
|
||||
None => Value::Null,
|
||||
})
|
||||
.collect(),
|
||||
@@ -217,23 +217,23 @@ impl PDRouter {
|
||||
);
|
||||
obj.insert(
|
||||
"bootstrap_room".to_string(),
|
||||
Value::Array(rooms.into_iter().map(serde_json::Value::from).collect()),
|
||||
Value::Array(rooms.into_iter().map(Value::from).collect()),
|
||||
);
|
||||
} else {
|
||||
obj.insert(
|
||||
"bootstrap_host".to_string(),
|
||||
serde_json::Value::from(prefill_worker.bootstrap_host()),
|
||||
Value::from(prefill_worker.bootstrap_host()),
|
||||
);
|
||||
obj.insert(
|
||||
"bootstrap_port".to_string(),
|
||||
match prefill_worker.bootstrap_port() {
|
||||
Some(v) => serde_json::Value::from(v),
|
||||
Some(v) => Value::from(v),
|
||||
None => Value::Null,
|
||||
},
|
||||
);
|
||||
obj.insert(
|
||||
"bootstrap_room".to_string(),
|
||||
serde_json::Value::from(super::pd_types::generate_room_id()),
|
||||
Value::from(super::pd_types::generate_room_id()),
|
||||
);
|
||||
}
|
||||
Ok(original)
|
||||
@@ -508,8 +508,7 @@ impl PDRouter {
|
||||
|
||||
match res.bytes().await {
|
||||
Ok(decode_body) => {
|
||||
let mut response =
|
||||
Response::new(axum::body::Body::from(decode_body));
|
||||
let mut response = Response::new(Body::from(decode_body));
|
||||
*response.status_mut() = status;
|
||||
*response.headers_mut() = response_headers;
|
||||
response
|
||||
@@ -1365,7 +1364,7 @@ mod tests {
|
||||
assert_eq!(decode_ref.load(), 0);
|
||||
|
||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let stream = tokio_stream::wrappers::UnboundedReceiverStream::new(rx);
|
||||
let stream = UnboundedReceiverStream::new(rx);
|
||||
|
||||
let _response = router.create_streaming_response(
|
||||
stream.map(Ok),
|
||||
|
||||
@@ -95,7 +95,7 @@ impl Router {
|
||||
|
||||
match res.bytes().await {
|
||||
Ok(body) => {
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = status;
|
||||
*response.headers_mut() = response_headers;
|
||||
response
|
||||
@@ -315,7 +315,7 @@ impl Router {
|
||||
let response_headers = header_utils::preserve_response_headers(res.headers());
|
||||
match res.bytes().await {
|
||||
Ok(body) => {
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = status;
|
||||
*response.headers_mut() = response_headers;
|
||||
if status.is_success() {
|
||||
@@ -496,7 +496,7 @@ impl Router {
|
||||
|
||||
let response = match res.bytes().await {
|
||||
Ok(body) => {
|
||||
let mut response = Response::new(axum::body::Body::from(body));
|
||||
let mut response = Response::new(Body::from(body));
|
||||
*response.status_mut() = status;
|
||||
*response.headers_mut() = response_headers;
|
||||
response
|
||||
|
||||
Reference in New Issue
Block a user