remove generate_with_flume and tokio dep from core

master
Tymon 1 year ago
parent 1306d3ac47
commit 178096550e

1
Cargo.lock generated

@ -131,7 +131,6 @@ dependencies = [
"ron",
"serde",
"serde_json",
"tokio",
]
[[package]]

@ -3,8 +3,6 @@ name = "ai_core"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.70"
chrono = { version = "0.4.24", features = ["serde"] }
@ -14,5 +12,4 @@ rayon = "1.7.0"
reqwest = { version = "0.11.15", features = ["json"] }
ron = "0.8.0"
serde = { version = "1.0.158", features = ["derive"] }
serde_json = "1.0.94"
tokio = { version = "1.26.0", features = ["full"] }
serde_json = "1.0.94"

@ -1,7 +1,6 @@
use std::collections::HashMap;
use anyhow::{Context, Result};
use flume::Sender;
use once_cell::sync::Lazy;
use reqwest::Client;
use ron::Value as RonValue;
@ -101,21 +100,3 @@ pub struct Response {
pub response_type: ResponseType,
pub output: String,
}
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!")
});
}

@ -14,11 +14,11 @@ use eframe::{
use egui_notify::Toasts;
use ai_core::{
ai::{generate_with_flume, Params, Response, ResponseType, AI},
ai::{Params, Response, ResponseType, AI},
history::{read_all_history, write_history, HistoryEntry},
};
use crate::CONFIG;
use crate::{utils::generate_with_flume, CONFIG};
pub struct App {
toasts: Toasts,

@ -1,6 +1,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod app;
mod utils;
use std::fs;

@ -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!")
});
}