nihility-model 0.2.2

nihility project ai model module
Documentation
use nihility_model::NihilityModel;
use nihility_model::config::ModelType;
use tokio_stream::StreamExt;
use tracing::{error, info};

#[tokio::test]
async fn test_text() {
    nihility_log::init().unwrap();
    let model = NihilityModel::init_from_file_config().unwrap();
    let resp = model
        .completion(ModelType::TextSmall, "今天天气真好!")
        .await
        .unwrap();
    info!("test resp: {}", resp);
}

#[tokio::test]
async fn test_text_stream() {
    nihility_log::init().unwrap();
    let model = NihilityModel::init_from_file_config().unwrap();
    let mut resp_stream = model
        .completion_stream(ModelType::TextSmall, "今天天气真好!")
        .await
        .unwrap();
    while let Some(response) = resp_stream.next().await {
        match response {
            Ok(text) => info!("stream resp: {}", text),
            Err(e) => error!("stream resp error: {}", e),
        }
    }
}