diff --git a/crates/prompt_gateway/src/stream_context.rs b/crates/prompt_gateway/src/stream_context.rs index fbbc49de..5bfc6d5e 100644 --- a/crates/prompt_gateway/src/stream_context.rs +++ b/crates/prompt_gateway/src/stream_context.rs @@ -777,22 +777,19 @@ impl StreamContext { fn check_intent_matched(model_server_response: &ChatCompletionsResponse) -> bool { let content = model_server_response - .choices - .get(0) + .choices.first() .and_then(|choice| choice.message.content.as_ref()); let content_has_value = content.is_some() && !content.unwrap().is_empty(); let tool_calls = model_server_response - .choices - .get(0) + .choices.first() .and_then(|choice| choice.message.tool_calls.as_ref()); // intent was matched if content has some value or tool_calls is empty - let intent_matched = - content_has_value || (tool_calls.is_some() && !tool_calls.unwrap().is_empty()); - return intent_matched; + + content_has_value || (tool_calls.is_some() && !tool_calls.unwrap().is_empty()) } impl Client for StreamContext { @@ -832,7 +829,7 @@ mod test { metadata: None, }; - assert_eq!(check_intent_matched(&model_server_response), false); + assert!(!check_intent_matched(&model_server_response)); let model_server_response = ChatCompletionsResponse { choices: vec![Choice { @@ -851,7 +848,7 @@ mod test { metadata: None, }; - assert_eq!(check_intent_matched(&model_server_response), true); + assert!(check_intent_matched(&model_server_response)); let model_server_response = ChatCompletionsResponse { choices: vec![Choice { @@ -877,6 +874,6 @@ mod test { metadata: None, }; - assert_eq!(check_intent_matched(&model_server_response), true); + assert!(check_intent_matched(&model_server_response)); } }