Files
mistralai-client-rs/tests/v1_client_chat_stream_test.rs

45 lines
1.3 KiB
Rust
Raw Permalink Normal View History

// Streaming tests require a live API key and are not run in CI.
// Uncomment to test locally.
// use futures::stream::StreamExt;
// use mistralai_client::v1::{
// 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::mistral_small_latest();
// let messages = vec![ChatMessage::new_user_message(
// "Just guess the next word: \"Eiffel ...\"?",
// )];
// let options = ChatParams {
// temperature: Some(0.0),
// random_seed: Some(42),
// ..Default::default()
// };
//
// 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),
// }
// })
// .await;
// }