fix clippy

This commit is contained in:
Adil Hafeez 2025-04-07 01:43:35 -07:00
parent 48d058ce5c
commit 00afcb7307
No known key found for this signature in database
GPG key ID: 9B18EF7691369645

View file

@ -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));
}
}