2024-03-04 06:39:21 +01:00
|
|
|
use jrest::expect;
|
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
|
|
|
use mistralai_client::v1::{client::Client, constants::Model};
|
2024-03-04 06:39:21 +01:00
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
|
async fn test_client_embeddings_async() {
|
|
|
|
|
let client: Client = Client::new(None, None, None, None).unwrap();
|
|
|
|
|
|
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
|
|
|
let model = Model::mistral_embed();
|
2024-03-04 06:39:21 +01:00
|
|
|
let input = vec!["Embed this sentence.", "As well as this one."]
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|s| s.to_string())
|
|
|
|
|
.collect();
|
|
|
|
|
let options = None;
|
|
|
|
|
|
|
|
|
|
let response = client
|
|
|
|
|
.embeddings_async(model, input, options)
|
|
|
|
|
.await
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
expect!(response.object).to_be("list".to_string());
|
|
|
|
|
expect!(response.data.len()).to_be(2);
|
|
|
|
|
expect!(response.data[0].index).to_be(0);
|
|
|
|
|
expect!(response.data[0].object.clone()).to_be("embedding".to_string());
|
|
|
|
|
expect!(response.data[0].embedding.len()).to_be_greater_than(0);
|
|
|
|
|
expect!(response.usage.prompt_tokens).to_be_greater_than(0);
|
|
|
|
|
expect!(response.usage.completion_tokens).to_be(0);
|
|
|
|
|
expect!(response.usage.total_tokens).to_be_greater_than(0);
|
|
|
|
|
}
|