test(chat): simplify chat response message content check to cover variations

This commit is contained in:
Ivan Gabriele
2024-06-07 14:36:18 +02:00
parent 64034402ca
commit e61ace9a18
2 changed files with 4 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ async fn test_client_chat_async() {
let model = Model::OpenMistral7b;
let messages = vec![ChatMessage::new_user_message(
"Just guess the next word: \"Eiffel ...\"?",
"Guess the next word: \"Eiffel ...\"?",
)];
let options = ChatParams {
temperature: Some(0.0),
@@ -37,8 +37,7 @@ async fn test_client_chat_async() {
expect!(response.choices[0].finish_reason.clone()).to_be(ChatResponseChoiceFinishReason::Stop);
expect!(response.choices[0].message.role.clone()).to_be(ChatMessageRole::Assistant);
expect!(response.choices[0].message.content.clone())
.to_be("Tower. The Eiffel Tower is a famous landmark in Paris, France.".to_string());
expect!(response.choices[0].message.content.clone()).to_start_with("Tower".to_string());
expect!(response.usage.prompt_tokens).to_be_greater_than(0);
expect!(response.usage.completion_tokens).to_be_greater_than(0);

View File

@@ -16,7 +16,7 @@ fn test_client_chat() {
let model = Model::OpenMistral7b;
let messages = vec![ChatMessage::new_user_message(
"Just guess the next word: \"Eiffel ...\"?",
"Guess the next word: \"Eiffel ...\"?",
)];
let options = ChatParams {
temperature: Some(0.0),
@@ -31,8 +31,7 @@ fn test_client_chat() {
expect!(response.choices.len()).to_be(1);
expect!(response.choices[0].index).to_be(0);
expect!(response.choices[0].message.role.clone()).to_be(ChatMessageRole::Assistant);
expect!(response.choices[0].message.content.clone())
.to_be("Tower. The Eiffel Tower is a famous landmark in Paris, France.".to_string());
expect!(response.choices[0].message.content.clone()).to_start_with("Tower".to_string());
expect!(response.choices[0].finish_reason.clone()).to_be(ChatResponseChoiceFinishReason::Stop);
expect!(response.usage.prompt_tokens).to_be_greater_than(0);
expect!(response.usage.completion_tokens).to_be_greater_than(0);