2024-06-22 13:22:57 +02:00
|
|
|
use jrest::expect;
|
|
|
|
|
use mistralai_client::v1::{
|
|
|
|
|
chat::{ChatMessage, ChatParams},
|
|
|
|
|
client::Client,
|
|
|
|
|
constants::Model,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[test]
|
Update to latest Mistral AI API (v1.0.0)
- Replace closed Model enum with flexible string-based Model type
with constructor methods for all current models (Mistral Large 3,
Small 4, Magistral, Codestral, Devstral, Pixtral, Voxtral, etc.)
- Add new API endpoints: FIM completions, Files, Fine-tuning, Batch
jobs, OCR, Audio transcription, Moderations/Classifications, and
Agent completions (sync + async for all)
- Add new chat fields: frequency_penalty, presence_penalty, stop,
n, parallel_tool_calls, reasoning_effort, min_tokens, json_schema
response format
- Add embedding fields: output_dimension, output_dtype
- Tool parameters now accept raw JSON Schema (serde_json::Value)
instead of limited enum types
- Add tool call IDs and Required tool choice variant
- Add DELETE HTTP method support and multipart file upload
- Bump thiserror to v2, add reqwest multipart feature
- Remove strum dependency (no longer needed)
- Update all tests and examples for new API
2026-03-20 17:16:26 +00:00
|
|
|
fn test_model_constants() {
|
2024-06-22 13:22:57 +02:00
|
|
|
let models = vec![
|
Update to latest Mistral AI API (v1.0.0)
- Replace closed Model enum with flexible string-based Model type
with constructor methods for all current models (Mistral Large 3,
Small 4, Magistral, Codestral, Devstral, Pixtral, Voxtral, etc.)
- Add new API endpoints: FIM completions, Files, Fine-tuning, Batch
jobs, OCR, Audio transcription, Moderations/Classifications, and
Agent completions (sync + async for all)
- Add new chat fields: frequency_penalty, presence_penalty, stop,
n, parallel_tool_calls, reasoning_effort, min_tokens, json_schema
response format
- Add embedding fields: output_dimension, output_dtype
- Tool parameters now accept raw JSON Schema (serde_json::Value)
instead of limited enum types
- Add tool call IDs and Required tool choice variant
- Add DELETE HTTP method support and multipart file upload
- Bump thiserror to v2, add reqwest multipart feature
- Remove strum dependency (no longer needed)
- Update all tests and examples for new API
2026-03-20 17:16:26 +00:00
|
|
|
Model::mistral_small_latest(),
|
|
|
|
|
Model::mistral_large_latest(),
|
|
|
|
|
Model::open_mistral_nemo(),
|
|
|
|
|
Model::codestral_latest(),
|
2024-06-22 13:22:57 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
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 {
|
Update to latest Mistral AI API (v1.0.0)
- Replace closed Model enum with flexible string-based Model type
with constructor methods for all current models (Mistral Large 3,
Small 4, Magistral, Codestral, Devstral, Pixtral, Voxtral, etc.)
- Add new API endpoints: FIM completions, Files, Fine-tuning, Batch
jobs, OCR, Audio transcription, Moderations/Classifications, and
Agent completions (sync + async for all)
- Add new chat fields: frequency_penalty, presence_penalty, stop,
n, parallel_tool_calls, reasoning_effort, min_tokens, json_schema
response format
- Add embedding fields: output_dimension, output_dtype
- Tool parameters now accept raw JSON Schema (serde_json::Value)
instead of limited enum types
- Add tool call IDs and Required tool choice variant
- Add DELETE HTTP method support and multipart file upload
- Bump thiserror to v2, add reqwest multipart feature
- Remove strum dependency (no longer needed)
- Update all tests and examples for new API
2026-03-20 17:16:26 +00:00
|
|
|
temperature: Some(0.0),
|
2024-06-22 13:22:57 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|