- 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
22 lines
645 B
Rust
22 lines
645 B
Rust
use mistralai_client::v1::{
|
|
client::Client,
|
|
constants::Model,
|
|
fim::FimParams,
|
|
};
|
|
|
|
fn main() {
|
|
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
|
|
let client = Client::new(None, None, None, None).unwrap();
|
|
|
|
let model = Model::codestral_latest();
|
|
let prompt = "def fibonacci(n):".to_string();
|
|
let options = FimParams {
|
|
suffix: Some("\n return result".to_string()),
|
|
temperature: Some(0.0),
|
|
..Default::default()
|
|
};
|
|
|
|
let response = client.fim(model, prompt, Some(options)).unwrap();
|
|
println!("Completion: {}", response.choices[0].message.content);
|
|
}
|