- Use Model::mistral_small_latest() instead of enum variants - Use Model::mistral_embed() instead of EmbedModel::MistralEmbed - Use serde_json::json!() for tool parameter schemas - Update ChatParams for Option<f32> temperature field - Update streaming test comments for new delta.content type
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use jrest::expect;
|
|
use mistralai_client::v1::{
|
|
chat::{ChatMessage, ChatParams},
|
|
client::Client,
|
|
constants::Model,
|
|
};
|
|
|
|
#[test]
|
|
fn test_model_constants() {
|
|
let models = vec![
|
|
Model::mistral_small_latest(),
|
|
Model::mistral_large_latest(),
|
|
Model::open_mistral_nemo(),
|
|
Model::codestral_latest(),
|
|
];
|
|
|
|
let client = Client::new(None, None, None, None).unwrap();
|
|
|
|
let messages = vec![ChatMessage::new_user_message("A number between 0 and 100?")];
|
|
let options = ChatParams {
|
|
temperature: Some(0.0),
|
|
random_seed: Some(42),
|
|
..Default::default()
|
|
};
|
|
|
|
for model in models {
|
|
let response = client
|
|
.chat(model.clone(), messages.clone(), Some(options.clone()))
|
|
.unwrap();
|
|
|
|
expect!(response.model).to_be(model);
|
|
expect!(response.object).to_be("chat.completion".to_string());
|
|
expect!(response.choices.len()).to_be(1);
|
|
expect!(response.choices[0].index).to_be(0);
|
|
expect!(response.choices[0].message.content.len()).to_be_greater_than(0);
|
|
}
|
|
}
|