docs: update README and examples for v1.0.0

- 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
This commit is contained in:
2026-03-20 18:00:51 +00:00
parent ce96bcfeeb
commit 63f0edf574
11 changed files with 229 additions and 358 deletions

View File

@@ -1,6 +1,6 @@
use futures::stream::StreamExt;
use mistralai_client::v1::{
chat::{ChatMessage, ChatMessageRole, ChatParams},
chat::{ChatMessage, ChatParams},
client::Client,
constants::Model,
};
@@ -11,14 +11,10 @@ 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::OpenMistral7b;
let messages = vec![ChatMessage {
role: ChatMessageRole::User,
content: "Tell me a short happy story.".to_string(),
tool_calls: None,
}];
let model = Model::mistral_small_latest();
let messages = vec![ChatMessage::new_user_message("Tell me a short happy story.")];
let options = ChatParams {
temperature: 0.0,
temperature: Some(0.0),
random_seed: Some(42),
..Default::default()
};
@@ -31,9 +27,10 @@ async fn main() {
.for_each(|chunk_result| async {
match chunk_result {
Ok(chunks) => chunks.iter().for_each(|chunk| {
print!("{}", chunk.choices[0].delta.content);
io::stdout().flush().unwrap();
// => "Once upon a time, [...]"
if let Some(content) = &chunk.choices[0].delta.content {
print!("{}", content);
io::stdout().flush().unwrap();
}
}),
Err(error) => {
eprintln!("Error processing chunk: {:?}", error)
@@ -41,5 +38,5 @@ async fn main() {
}
})
.await;
print!("\n") // To persist the last chunk output.
println!();
}