feat: add client.list_models() method

This commit is contained in:
Ivan Gabriele
2024-03-03 19:38:34 +01:00
parent 7de2b19b98
commit 814b9918b3
6 changed files with 100 additions and 65 deletions

View File

@@ -27,7 +27,7 @@ Rust client for the Mistral AI API.
- [x] Chat without streaming
- [ ] Chat with streaming
- [ ] Embedding
- [ ] List models
- [x] List models
- [ ] Function Calling
## Installation
@@ -63,11 +63,8 @@ fn main() {
### Chat without streaming
```rs
use mistralai::v1::{
chat_completion::{
ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionRequest,
ChatCompletionRequestOptions,
},
use mistralai_client::v1::{
chat_completion::{ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionRequestOptions},
client::Client,
constants::OPEN_MISTRAL_7B,
};
@@ -103,4 +100,15 @@ _In progress._
### List models
_In progress._
```rs
use mistralai_client::v1::client::Client;
fn main() {
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
let client = Client::new(None, None, None, None);
let result = client.list_models(model, messages, Some(options)).unwrap();
println!("First Model ID: {:?}", result.data[0].id);
// => "First Model ID: open-mistral-7b"
}
```