mirror of
https://github.com/katanemo/plano.git
synced 2026-05-11 08:42:48 +02:00
add output filter chain (#822)
This commit is contained in:
parent
de2d8847f3
commit
1f23c573bf
59 changed files with 2961 additions and 2621 deletions
|
|
@ -17,7 +17,7 @@ use hyper::StatusCode;
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use common::configuration::{Agent, AgentFilterChain, Listener};
|
||||
use common::configuration::{Agent, AgentFilterChain, Listener, ListenerType};
|
||||
|
||||
fn create_test_orchestrator_service() -> Arc<OrchestratorService> {
|
||||
Arc::new(OrchestratorService::new(
|
||||
|
|
@ -64,7 +64,7 @@ mod tests {
|
|||
|
||||
let agent_pipeline = AgentFilterChain {
|
||||
id: "terminal-agent".to_string(),
|
||||
filter_chain: Some(vec![
|
||||
input_filters: Some(vec![
|
||||
"filter-agent".to_string(),
|
||||
"terminal-agent".to_string(),
|
||||
]),
|
||||
|
|
@ -73,8 +73,11 @@ mod tests {
|
|||
};
|
||||
|
||||
let listener = Listener {
|
||||
listener_type: ListenerType::Agent,
|
||||
name: "test-listener".to_string(),
|
||||
agents: Some(vec![agent_pipeline.clone()]),
|
||||
input_filters: None,
|
||||
output_filters: None,
|
||||
port: 8080,
|
||||
router: None,
|
||||
};
|
||||
|
|
@ -107,23 +110,32 @@ mod tests {
|
|||
// Create a pipeline with empty filter chain to avoid network calls
|
||||
let test_pipeline = AgentFilterChain {
|
||||
id: "terminal-agent".to_string(),
|
||||
filter_chain: Some(vec![]), // Empty filter chain - no network calls needed
|
||||
input_filters: Some(vec![]), // Empty filter chain - no network calls needed
|
||||
description: None,
|
||||
default: None,
|
||||
};
|
||||
|
||||
let headers = HeaderMap::new();
|
||||
let request_bytes = serde_json::to_vec(&request).expect("failed to serialize request");
|
||||
let result = pipeline_processor
|
||||
.process_filter_chain(&request.messages, &test_pipeline, &agent_map, &headers)
|
||||
.process_raw_filter_chain(
|
||||
&request_bytes,
|
||||
&test_pipeline,
|
||||
&agent_map,
|
||||
&headers,
|
||||
"/v1/chat/completions",
|
||||
)
|
||||
.await;
|
||||
|
||||
println!("Pipeline processing result: {:?}", result);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let processed_messages = result.unwrap();
|
||||
// With empty filter chain, should return the original messages unchanged
|
||||
assert_eq!(processed_messages.len(), 1);
|
||||
if let Some(MessageContent::Text(content)) = &processed_messages[0].content {
|
||||
let processed_bytes = result.unwrap();
|
||||
// With empty filter chain, should return the original bytes unchanged
|
||||
let processed_request: ChatCompletionsRequest =
|
||||
serde_json::from_slice(&processed_bytes).expect("failed to deserialize response");
|
||||
assert_eq!(processed_request.messages.len(), 1);
|
||||
if let Some(MessageContent::Text(content)) = &processed_request.messages[0].content {
|
||||
assert_eq!(content, "Hello world!");
|
||||
} else {
|
||||
panic!("Expected text content");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue