mirror of
https://github.com/katanemo/plano.git
synced 2026-04-25 00:36:34 +02:00
cargo fmt
This commit is contained in:
parent
edf782f07a
commit
54b15d6c08
2 changed files with 44 additions and 51 deletions
|
|
@ -272,55 +272,50 @@ async fn llm_chat_inner(
|
|||
let mut pipeline_processor = PipelineProcessor::default();
|
||||
let messages = client_request.get_messages();
|
||||
match pipeline_processor
|
||||
.process_filter_chain(
|
||||
&messages,
|
||||
&temp_filter_chain,
|
||||
&mfc.agents,
|
||||
&request_headers,
|
||||
)
|
||||
.process_filter_chain(&messages, &temp_filter_chain, &mfc.agents, &request_headers)
|
||||
.await
|
||||
{
|
||||
Ok(filtered_messages) => {
|
||||
client_request.set_messages(&filtered_messages);
|
||||
info!(
|
||||
original_count = messages.len(),
|
||||
filtered_count = filtered_messages.len(),
|
||||
"filter chain processed successfully"
|
||||
);
|
||||
}
|
||||
Err(super::pipeline_processor::PipelineError::ClientError {
|
||||
agent,
|
||||
status,
|
||||
body,
|
||||
}) => {
|
||||
warn!(
|
||||
agent = %agent,
|
||||
status = %status,
|
||||
body = %body,
|
||||
"client error from filter chain"
|
||||
);
|
||||
let error_json = serde_json::json!({
|
||||
"error": "FilterChainError",
|
||||
"agent": agent,
|
||||
"status": status,
|
||||
"agent_response": body
|
||||
});
|
||||
let mut error_response = Response::new(full(error_json.to_string()));
|
||||
*error_response.status_mut() =
|
||||
StatusCode::from_u16(status).unwrap_or(StatusCode::BAD_REQUEST);
|
||||
error_response.headers_mut().insert(
|
||||
hyper::header::CONTENT_TYPE,
|
||||
"application/json".parse().unwrap(),
|
||||
);
|
||||
return Ok(error_response);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(error = %err, "filter chain processing failed");
|
||||
let err_msg = format!("Filter chain processing failed: {}", err);
|
||||
let mut internal_error = Response::new(full(err_msg));
|
||||
*internal_error.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||
return Ok(internal_error);
|
||||
}
|
||||
{
|
||||
Ok(filtered_messages) => {
|
||||
client_request.set_messages(&filtered_messages);
|
||||
info!(
|
||||
original_count = messages.len(),
|
||||
filtered_count = filtered_messages.len(),
|
||||
"filter chain processed successfully"
|
||||
);
|
||||
}
|
||||
Err(super::pipeline_processor::PipelineError::ClientError {
|
||||
agent,
|
||||
status,
|
||||
body,
|
||||
}) => {
|
||||
warn!(
|
||||
agent = %agent,
|
||||
status = %status,
|
||||
body = %body,
|
||||
"client error from filter chain"
|
||||
);
|
||||
let error_json = serde_json::json!({
|
||||
"error": "FilterChainError",
|
||||
"agent": agent,
|
||||
"status": status,
|
||||
"agent_response": body
|
||||
});
|
||||
let mut error_response = Response::new(full(error_json.to_string()));
|
||||
*error_response.status_mut() =
|
||||
StatusCode::from_u16(status).unwrap_or(StatusCode::BAD_REQUEST);
|
||||
error_response.headers_mut().insert(
|
||||
hyper::header::CONTENT_TYPE,
|
||||
"application/json".parse().unwrap(),
|
||||
);
|
||||
return Ok(error_response);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(error = %err, "filter chain processing failed");
|
||||
let err_msg = format!("Filter chain processing failed: {}", err);
|
||||
let mut internal_error = Response::new(full(err_msg));
|
||||
*internal_error.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||
return Ok(internal_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,9 +105,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||
.map(|fc| {
|
||||
let agents = fc
|
||||
.iter()
|
||||
.filter_map(|id| {
|
||||
global_agent_map.get(id).map(|a| (id.clone(), a.clone()))
|
||||
})
|
||||
.filter_map(|id| global_agent_map.get(id).map(|a| (id.clone(), a.clone())))
|
||||
.collect();
|
||||
ModelFilterChain {
|
||||
filter_ids: fc,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue