test: update all tests for v1.0 API
- Use Model::mistral_small_latest() instead of enum variants - Use Model::mistral_embed() instead of EmbedModel::MistralEmbed - Use serde_json::json!() for tool parameter schemas - Update ChatParams for Option<f32> temperature field - Update streaming test comments for new delta.content type
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
// Streaming tests require a live API key and are not run in CI.
|
||||
// Uncomment to test locally.
|
||||
|
||||
// use futures::stream::StreamExt;
|
||||
// use jrest::expect;
|
||||
// use mistralai_client::v1::{
|
||||
// chat_completion::{ChatParams, ChatMessage, ChatMessageRole},
|
||||
// chat::{ChatMessage, ChatParams},
|
||||
// client::Client,
|
||||
// constants::Model,
|
||||
// };
|
||||
|
||||
//
|
||||
// #[tokio::test]
|
||||
// async fn test_client_chat_stream() {
|
||||
// let client = Client::new(None, None, None, None).unwrap();
|
||||
|
||||
// let model = Model::OpenMistral7b;
|
||||
//
|
||||
// let model = Model::mistral_small_latest();
|
||||
// let messages = vec![ChatMessage::new_user_message(
|
||||
// "Just guess the next word: \"Eiffel ...\"?",
|
||||
// )];
|
||||
@@ -19,22 +21,24 @@
|
||||
// random_seed: Some(42),
|
||||
// ..Default::default()
|
||||
// };
|
||||
|
||||
// let stream_result = client.chat_stream(model, messages, Some(options)).await;
|
||||
// let mut stream = stream_result.expect("Failed to create stream.");
|
||||
// while let Some(maybe_chunk_result) = stream.next().await {
|
||||
// match maybe_chunk_result {
|
||||
// Some(Ok(chunk)) => {
|
||||
// if chunk.choices[0].delta.role == Some(ChatMessageRole::Assistant)
|
||||
// || chunk.choices[0].finish_reason == Some("stop".to_string())
|
||||
// {
|
||||
// expect!(chunk.choices[0].delta.content.len()).to_be(0);
|
||||
// } else {
|
||||
// expect!(chunk.choices[0].delta.content.len()).to_be_greater_than(0);
|
||||
//
|
||||
// let stream = client
|
||||
// .chat_stream(model, messages, Some(options))
|
||||
// .await
|
||||
// .expect("Failed to create stream.");
|
||||
//
|
||||
// stream
|
||||
// .for_each(|chunk_result| async {
|
||||
// match chunk_result {
|
||||
// Ok(chunks) => {
|
||||
// for chunk in &chunks {
|
||||
// if let Some(content) = &chunk.choices[0].delta.content {
|
||||
// print!("{}", content);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Err(error) => eprintln!("Error: {:?}", error),
|
||||
// }
|
||||
// Some(Err(error)) => eprintln!("Error processing chunk: {:?}", error),
|
||||
// None => (),
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .await;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user