remove generate_with_flume and tokio dep from core
parent
1306d3ac47
commit
178096550e
@ -0,0 +1,20 @@
|
||||
use ai_core::ai::{generate, Params, Response, ResponseType, AI};
|
||||
use flume::Sender;
|
||||
|
||||
pub fn generate_with_flume(ai: AI, params: Params, tx: Sender<Response>) {
|
||||
tokio::spawn(async move {
|
||||
let output = match generate(ai, params).await {
|
||||
Ok(output) => Response {
|
||||
response_type: ResponseType::Success,
|
||||
output,
|
||||
},
|
||||
Err(error) => Response {
|
||||
response_type: ResponseType::Error,
|
||||
output: error.to_string(),
|
||||
},
|
||||
};
|
||||
|
||||
tx.send(output)
|
||||
.expect("Failed to send output, this should never happen!")
|
||||
});
|
||||
}
|
Reference in new issue