feat: implement the Debug trait for Client (#11)

This is useful if you want to include client::Client in your own
implementation and derive Debug.
This commit is contained in:
Federico G. Schwindt
2024-07-24 19:08:25 +01:00
committed by GitHub
parent 0c097aa56d
commit 3afeec1d58
3 changed files with 13 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ use std::{
use crate::v1::{chat, chat_stream, constants, embedding, error, model_list, tool, utils}; use crate::v1::{chat, chat_stream, constants, embedding, error, model_list, tool, utils};
#[derive(Debug)]
pub struct Client { pub struct Client {
pub api_key: String, pub api_key: String,
pub endpoint: String, pub endpoint: String,

View File

@@ -1,6 +1,6 @@
use async_trait::async_trait; use async_trait::async_trait;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{any::Any, collections::HashMap}; use std::{any::Any, collections::HashMap, fmt::Debug};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Definitions // Definitions
@@ -136,3 +136,9 @@ pub enum ToolChoice {
pub trait Function { pub trait Function {
async fn execute(&self, arguments: String) -> Box<dyn Any + Send>; async fn execute(&self, arguments: String) -> Box<dyn Any + Send>;
} }
impl Debug for dyn Function {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Function()")
}
}

View File

@@ -1,6 +1,11 @@
use jrest::expect; use jrest::expect;
use mistralai_client::v1::{client::Client, error::ClientError}; use mistralai_client::v1::{client::Client, error::ClientError};
#[derive(Debug)]
struct _Foo {
_client: Client,
}
#[test] #[test]
fn test_client_new_with_none_params() { fn test_client_new_with_none_params() {
let maybe_original_mistral_api_key = std::env::var("MISTRAL_API_KEY").ok(); let maybe_original_mistral_api_key = std::env::var("MISTRAL_API_KEY").ok();