- Rewrite README with all new endpoints and current model names - Add available models table with constructors - Add FIM and OCR examples - Update all examples for string-based Model type - Update streaming example for Option<String> delta content - Use serde_json::json!() for tool schemas in examples - Add .envrc to .gitignore
31 lines
814 B
Rust
31 lines
814 B
Rust
use mistralai_client::v1::{
|
|
chat::{ChatMessage, ChatParams},
|
|
client::Client,
|
|
constants::Model,
|
|
};
|
|
|
|
#[tokio::main]
|
|
async 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::mistral_small_latest();
|
|
let messages = vec![ChatMessage::new_user_message(
|
|
"Just guess the next word: \"Eiffel ...\"?",
|
|
)];
|
|
let options = ChatParams {
|
|
temperature: Some(0.0),
|
|
random_seed: Some(42),
|
|
..Default::default()
|
|
};
|
|
|
|
let result = client
|
|
.chat_async(model, messages, Some(options))
|
|
.await
|
|
.unwrap();
|
|
println!(
|
|
"{:?}: {}",
|
|
result.choices[0].message.role, result.choices[0].message.content
|
|
);
|
|
}
|