Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0386b95b7b | ||
|
|
c61f2278bb | ||
|
|
4c8e330c95 | ||
|
|
64c7f2feb5 | ||
|
|
f44d951247 | ||
|
|
4e702aa48e | ||
|
|
809af31dd0 |
@@ -1,16 +1,15 @@
|
|||||||
## [](https://github.com/ivangabriele/mistralai-client-rs/compare/v0.1.0...v) (2024-03-03)
|
## [0.3.0](https://github.com/ivangabriele/mistralai-client-rs/compare/v0.2.0...v) (2024-03-04)
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
* Chat completions must now be called directly from client.chat() without building a request in between.
|
* Models are now enforced by `Model` & `EmbedModel` enums.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add client.list_models() method ([814b991](https://github.com/ivangabriele/mistralai-client-rs/commit/814b9918b3aca78bfd606b5b9bb470b70ea2a5c6))
|
* add client.embeddings() method ([f44d951](https://github.com/ivangabriele/mistralai-client-rs/commit/f44d95124767c3a3f14c78c4be3d9c203fac49ad))
|
||||||
* simplify chat completion call ([7de2b19](https://github.com/ivangabriele/mistralai-client-rs/commit/7de2b19b981f1d65fe5c566fcaf521e4f2a9ced1))
|
|
||||||
|
|
||||||
## [](https://github.com/ivangabriele/mistralai-client-rs/compare/v0.1.0...v) (2024-03-03)
|
## [0.2.0](https://github.com/ivangabriele/mistralai-client-rs/compare/v0.1.0...v) (2024-03-03)
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
### ⚠ BREAKING CHANGES
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "mistralai-client"
|
name = "mistralai-client"
|
||||||
description = "Mistral AI API client library for Rust (unofficial)."
|
description = "Mistral AI API client library for Rust (unofficial)."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.76.0"
|
rust-version = "1.76.0"
|
||||||
|
|||||||
26
README.md
26
README.md
@@ -26,7 +26,7 @@ Rust client for the Mistral AI API.
|
|||||||
|
|
||||||
- [x] Chat without streaming
|
- [x] Chat without streaming
|
||||||
- [ ] Chat with streaming
|
- [ ] Chat with streaming
|
||||||
- [ ] Embedding
|
- [x] Embedding
|
||||||
- [x] List models
|
- [x] List models
|
||||||
- [ ] Function Calling
|
- [ ] Function Calling
|
||||||
|
|
||||||
@@ -66,14 +66,14 @@ fn main() {
|
|||||||
use mistralai_client::v1::{
|
use mistralai_client::v1::{
|
||||||
chat_completion::{ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionRequestOptions},
|
chat_completion::{ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionRequestOptions},
|
||||||
client::Client,
|
client::Client,
|
||||||
constants::OPEN_MISTRAL_7B,
|
constants::Model,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
|
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
|
||||||
let client = Client::new(None, None, None, None);
|
let client = Client::new(None, None, None, None);
|
||||||
|
|
||||||
let model = OPEN_MISTRAL_7B.to_string();
|
let model = Model::OpenMistral7b;
|
||||||
let messages = vec![ChatCompletionMessage {
|
let messages = vec![ChatCompletionMessage {
|
||||||
role: ChatCompletionMessageRole::user,
|
role: ChatCompletionMessageRole::user,
|
||||||
content: "Just guess the next word: \"Eiffel ...\"?".to_string(),
|
content: "Just guess the next word: \"Eiffel ...\"?".to_string(),
|
||||||
@@ -96,7 +96,25 @@ _In progress._
|
|||||||
|
|
||||||
### Embeddings
|
### Embeddings
|
||||||
|
|
||||||
_In progress._
|
```rs
|
||||||
|
use mistralai_client::v1::{client::Client, constants::EmbedModel};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// This example suppose you have set the `MISTRAL_API_KEY` environment variable.
|
||||||
|
let client: Client = Client::new(None, None, None, None);
|
||||||
|
|
||||||
|
let model = EmbedModel::MistralEmbed;
|
||||||
|
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(model, input, options).unwrap();
|
||||||
|
println!("Embeddings: {:?}", response.data);
|
||||||
|
// => "Embeddings: [{...}, {...}]"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### List models
|
### List models
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
allow-branch = ["main"]
|
allow-branch = ["main"]
|
||||||
|
pre-release-replacements = [{ file = "CHANGELOG.md", search = "## \\[\\]", replace = "## [{{version}}]" }]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::v1::common;
|
use crate::v1::{common, constants};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ChatCompletionParams {
|
pub struct ChatCompletionParams {
|
||||||
@@ -29,7 +29,7 @@ impl Default for ChatCompletionParams {
|
|||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct ChatCompletionRequest {
|
pub struct ChatCompletionRequest {
|
||||||
pub messages: Vec<ChatCompletionMessage>,
|
pub messages: Vec<ChatCompletionMessage>,
|
||||||
pub model: String,
|
pub model: constants::Model,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tools: Option<String>,
|
pub tools: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@@ -51,7 +51,7 @@ pub struct ChatCompletionRequest {
|
|||||||
}
|
}
|
||||||
impl ChatCompletionRequest {
|
impl ChatCompletionRequest {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
model: String,
|
model: constants::Model,
|
||||||
messages: Vec<ChatCompletionMessage>,
|
messages: Vec<ChatCompletionMessage>,
|
||||||
options: Option<ChatCompletionParams>,
|
options: Option<ChatCompletionParams>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -85,7 +85,7 @@ pub struct ChatCompletionResponse {
|
|||||||
pub object: String,
|
pub object: String,
|
||||||
/// Unix timestamp (in seconds).
|
/// Unix timestamp (in seconds).
|
||||||
pub created: u32,
|
pub created: u32,
|
||||||
pub model: String,
|
pub model: constants::Model,
|
||||||
pub choices: Vec<ChatCompletionChoice>,
|
pub choices: Vec<ChatCompletionChoice>,
|
||||||
pub usage: common::ResponseUsage,
|
pub usage: common::ResponseUsage,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ use crate::v1::{
|
|||||||
chat_completion::{
|
chat_completion::{
|
||||||
ChatCompletionMessage, ChatCompletionParams, ChatCompletionRequest, ChatCompletionResponse,
|
ChatCompletionMessage, ChatCompletionParams, ChatCompletionRequest, ChatCompletionResponse,
|
||||||
},
|
},
|
||||||
constants::API_URL_BASE,
|
constants::{EmbedModel, Model, API_URL_BASE},
|
||||||
list_models::ListModelsResponse,
|
embedding::{EmbeddingRequest, EmbeddingRequestOptions, EmbeddingResponse},
|
||||||
|
model_list::ModelListResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
@@ -59,6 +60,8 @@ impl Client {
|
|||||||
let result = request.send();
|
let result = request.send();
|
||||||
match result {
|
match result {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
print!("{:?}", response.as_str().unwrap());
|
||||||
|
|
||||||
if (200..=299).contains(&response.status_code) {
|
if (200..=299).contains(&response.status_code) {
|
||||||
Ok(response)
|
Ok(response)
|
||||||
} else {
|
} else {
|
||||||
@@ -88,7 +91,7 @@ impl Client {
|
|||||||
let result = request.with_json(params).unwrap().send();
|
let result = request.with_json(params).unwrap().send();
|
||||||
match result {
|
match result {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
// print!("{:?}", response.as_str().unwrap());
|
print!("{:?}", response.as_str().unwrap());
|
||||||
|
|
||||||
if (200..=299).contains(&response.status_code) {
|
if (200..=299).contains(&response.status_code) {
|
||||||
Ok(response)
|
Ok(response)
|
||||||
@@ -106,32 +109,9 @@ impl Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(&self, path: &str) -> Result<Response, APIError> {
|
|
||||||
let url = format!("{}{}", self.endpoint, path);
|
|
||||||
let request = self.build_request(minreq::post(url));
|
|
||||||
|
|
||||||
let result = request.send();
|
|
||||||
match result {
|
|
||||||
Ok(response) => {
|
|
||||||
if (200..=299).contains(&response.status_code) {
|
|
||||||
Ok(response)
|
|
||||||
} else {
|
|
||||||
Err(APIError {
|
|
||||||
message: format!(
|
|
||||||
"{}: {}",
|
|
||||||
response.status_code,
|
|
||||||
response.as_str().unwrap()
|
|
||||||
),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(error) => Err(self.new_error(error)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn chat(
|
pub fn chat(
|
||||||
&self,
|
&self,
|
||||||
model: String,
|
model: Model,
|
||||||
messages: Vec<ChatCompletionMessage>,
|
messages: Vec<ChatCompletionMessage>,
|
||||||
options: Option<ChatCompletionParams>,
|
options: Option<ChatCompletionParams>,
|
||||||
) -> Result<ChatCompletionResponse, APIError> {
|
) -> Result<ChatCompletionResponse, APIError> {
|
||||||
@@ -145,9 +125,25 @@ impl Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_models(&self) -> Result<ListModelsResponse, APIError> {
|
pub fn embeddings(
|
||||||
|
&self,
|
||||||
|
model: EmbedModel,
|
||||||
|
input: Vec<String>,
|
||||||
|
options: Option<EmbeddingRequestOptions>,
|
||||||
|
) -> Result<EmbeddingResponse, APIError> {
|
||||||
|
let request = EmbeddingRequest::new(model, input, options);
|
||||||
|
|
||||||
|
let response = self.post("/embeddings", &request)?;
|
||||||
|
let result = response.json::<EmbeddingResponse>();
|
||||||
|
match result {
|
||||||
|
Ok(response) => Ok(response),
|
||||||
|
Err(error) => Err(self.new_error(error)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn list_models(&self) -> Result<ModelListResponse, APIError> {
|
||||||
let response = self.get("/models")?;
|
let response = self.get("/models")?;
|
||||||
let result = response.json::<ListModelsResponse>();
|
let result = response.json::<ModelListResponse>();
|
||||||
match result {
|
match result {
|
||||||
Ok(response) => Ok(response),
|
Ok(response) => Ok(response),
|
||||||
Err(error) => Err(self.new_error(error)),
|
Err(error) => Err(self.new_error(error)),
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub const API_URL_BASE: &str = "https://api.mistral.ai/v1";
|
pub const API_URL_BASE: &str = "https://api.mistral.ai/v1";
|
||||||
|
|
||||||
pub const OPEN_MISTRAL_7B: &str = "open-mistral-7b";
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
pub const OPEN_MISTRAL_8X7B: &str = "open-mixtral-8x7b";
|
pub enum Model {
|
||||||
pub const MISTRAL_SMALL_LATEST: &str = "mistral-small-latest";
|
#[serde(rename = "open-mistral-7b")]
|
||||||
pub const MISTRAL_MEDIUM_LATEST: &str = "mistral-medium-latest";
|
OpenMistral7b,
|
||||||
pub const MISTRAL_LARGE_LATEST: &str = "mistral-large-latest";
|
#[serde(rename = "open-mistral-8x7b")]
|
||||||
|
OpenMistral8x7b,
|
||||||
|
#[serde(rename = "mistral-small-latest")]
|
||||||
|
MistralSmallLatest,
|
||||||
|
#[serde(rename = "mistral-medium-latest")]
|
||||||
|
MistralMediumLatest,
|
||||||
|
#[serde(rename = "mistral-large-latest")]
|
||||||
|
MistralLargeLatest,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub enum EmbedModel {
|
||||||
|
#[serde(rename = "mistral-embed")]
|
||||||
|
MistralEmbed,
|
||||||
|
}
|
||||||
|
|||||||
60
src/v1/embedding.rs
Normal file
60
src/v1/embedding.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::v1::{common, constants};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct EmbeddingRequestOptions {
|
||||||
|
pub encoding_format: Option<EmbeddingRequestEncodingFormat>,
|
||||||
|
}
|
||||||
|
impl Default for EmbeddingRequestOptions {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
encoding_format: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct EmbeddingRequest {
|
||||||
|
pub model: constants::EmbedModel,
|
||||||
|
pub input: Vec<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub encoding_format: Option<EmbeddingRequestEncodingFormat>,
|
||||||
|
}
|
||||||
|
impl EmbeddingRequest {
|
||||||
|
pub fn new(
|
||||||
|
model: constants::EmbedModel,
|
||||||
|
input: Vec<String>,
|
||||||
|
options: Option<EmbeddingRequestOptions>,
|
||||||
|
) -> Self {
|
||||||
|
let EmbeddingRequestOptions { encoding_format } = options.unwrap_or_default();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
model,
|
||||||
|
input,
|
||||||
|
encoding_format,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub enum EmbeddingRequestEncodingFormat {
|
||||||
|
float,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct EmbeddingResponse {
|
||||||
|
pub id: String,
|
||||||
|
pub object: String,
|
||||||
|
pub model: constants::EmbedModel,
|
||||||
|
pub data: Vec<EmbeddingResponseDataItem>,
|
||||||
|
pub usage: common::ResponseUsage,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
pub struct EmbeddingResponseDataItem {
|
||||||
|
pub index: u32,
|
||||||
|
pub embedding: Vec<f32>,
|
||||||
|
pub object: String,
|
||||||
|
}
|
||||||
@@ -2,5 +2,6 @@ pub mod chat_completion;
|
|||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
pub mod embedding;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod list_models;
|
pub mod model_list;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct ListModelsResponse {
|
pub struct ModelListResponse {
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub data: Vec<ListModelsModel>,
|
pub data: Vec<ModelListData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct ListModelsModel {
|
pub struct ModelListData {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub object: String,
|
pub object: String,
|
||||||
/// Unix timestamp (in seconds).
|
/// Unix timestamp (in seconds).
|
||||||
pub created: u32,
|
pub created: u32,
|
||||||
pub owned_by: String,
|
pub owned_by: String,
|
||||||
pub permission: Vec<ListModelsModelPermission>,
|
pub permission: Vec<ModelListDataPermission>,
|
||||||
// TODO Check this prop (seen in API responses but undocumented).
|
// TODO Check this prop (seen in API responses but undocumented).
|
||||||
// pub root: ???,
|
// pub root: ???,
|
||||||
// TODO Check this prop (seen in API responses but undocumented).
|
// TODO Check this prop (seen in API responses but undocumented).
|
||||||
@@ -21,7 +21,7 @@ pub struct ListModelsModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct ListModelsModelPermission {
|
pub struct ModelListDataPermission {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub object: String,
|
pub object: String,
|
||||||
/// Unix timestamp (in seconds).
|
/// Unix timestamp (in seconds).
|
||||||
@@ -2,7 +2,7 @@ use jrest::expect;
|
|||||||
use mistralai_client::v1::{
|
use mistralai_client::v1::{
|
||||||
chat_completion::{ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionParams},
|
chat_completion::{ChatCompletionMessage, ChatCompletionMessageRole, ChatCompletionParams},
|
||||||
client::Client,
|
client::Client,
|
||||||
constants::OPEN_MISTRAL_7B,
|
constants::Model,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -14,7 +14,7 @@ fn test_chat_completion() {
|
|||||||
|
|
||||||
let client = Client::new(None, None, None, None);
|
let client = Client::new(None, None, None, None);
|
||||||
|
|
||||||
let model = OPEN_MISTRAL_7B.to_string();
|
let model = Model::OpenMistral7b;
|
||||||
let messages = vec![ChatCompletionMessage {
|
let messages = vec![ChatCompletionMessage {
|
||||||
role: ChatCompletionMessageRole::user,
|
role: ChatCompletionMessageRole::user,
|
||||||
content: "Just guess the next word: \"Eiffel ...\"?".to_string(),
|
content: "Just guess the next word: \"Eiffel ...\"?".to_string(),
|
||||||
@@ -27,7 +27,7 @@ fn test_chat_completion() {
|
|||||||
|
|
||||||
let response = client.chat(model, messages, Some(options)).unwrap();
|
let response = client.chat(model, messages, Some(options)).unwrap();
|
||||||
|
|
||||||
expect!(response.model).to_be("open-mistral-7b".to_string());
|
expect!(response.model).to_be(Model::OpenMistral7b);
|
||||||
expect!(response.object).to_be("chat.completion".to_string());
|
expect!(response.object).to_be("chat.completion".to_string());
|
||||||
expect!(response.choices.len()).to_be(1);
|
expect!(response.choices.len()).to_be(1);
|
||||||
expect!(response.choices[0].index).to_be(0);
|
expect!(response.choices[0].index).to_be(0);
|
||||||
@@ -36,5 +36,5 @@ fn test_chat_completion() {
|
|||||||
.to_be("Tower. The Eiffel Tower is a famous landmark in Paris, France.".to_string());
|
.to_be("Tower. The Eiffel Tower is a famous landmark in Paris, France.".to_string());
|
||||||
expect!(response.usage.prompt_tokens).to_be_greater_than(0);
|
expect!(response.usage.prompt_tokens).to_be_greater_than(0);
|
||||||
expect!(response.usage.completion_tokens).to_be_greater_than(0);
|
expect!(response.usage.completion_tokens).to_be_greater_than(0);
|
||||||
expect!(response.usage.total_tokens).to_be_greater_than(21);
|
expect!(response.usage.total_tokens).to_be_greater_than(0);
|
||||||
}
|
}
|
||||||
|
|||||||
31
tests/v1_embeddings_test.rs
Normal file
31
tests/v1_embeddings_test.rs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
use jrest::expect;
|
||||||
|
use mistralai_client::v1::{client::Client, constants::EmbedModel};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_embeddings() {
|
||||||
|
extern crate dotenv;
|
||||||
|
|
||||||
|
use dotenv::dotenv;
|
||||||
|
dotenv().ok();
|
||||||
|
|
||||||
|
let client: Client = Client::new(None, None, None, None);
|
||||||
|
|
||||||
|
let model = EmbedModel::MistralEmbed;
|
||||||
|
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(model, input, options).unwrap();
|
||||||
|
|
||||||
|
expect!(response.model).to_be(EmbedModel::MistralEmbed);
|
||||||
|
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);
|
||||||
|
}
|
||||||
@@ -14,4 +14,12 @@ fn test_list_models() {
|
|||||||
|
|
||||||
expect!(response.object).to_be("list".to_string());
|
expect!(response.object).to_be("list".to_string());
|
||||||
expect!(response.data.len()).to_be_greater_than(0);
|
expect!(response.data.len()).to_be_greater_than(0);
|
||||||
|
|
||||||
|
// let open_mistral_7b_data_item = response
|
||||||
|
// .data
|
||||||
|
// .iter()
|
||||||
|
// .find(|item| item.id == "open-mistral-7b")
|
||||||
|
// .unwrap();
|
||||||
|
|
||||||
|
// expect!(open_mistral_7b_data_item.id).to_be("open-mistral-7b".to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user