Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: bump lai

Nathan917aa60c9881
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index d59db1a875..01b9251e23 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -345,7 +345,7 @@ dependencies = [
[[package]]
name = "af-local-ai"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e#dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"
dependencies = [
"af-plugin",
"anyhow",
@@ -365,7 +365,7 @@ dependencies = [
[[package]]
name = "af-mcp"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e#dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"
dependencies = [
"anyhow",
"futures-util",
@@ -379,7 +379,7 @@ dependencies = [
[[package]]
name = "af-plugin"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e#dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"
dependencies = [
"anyhow",
"cfg-if",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 66a82bc2ca..b4a0a34b14 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -152,6 +152,6 @@ collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFl
# To update the commit ID, run:
# scripts/tool/update_local_ai_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e" }
-af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e" }
-af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "dd7002f75a981a3ce0d5456eb7dac9ca0bb88a5e" }
+af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
+af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
+af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
diff --git a/frontend/rust-lib/flowy-ai/Cargo.toml b/frontend/rust-lib/flowy-ai/Cargo.toml
index 22cecd3713..ee056021c4 100644
--- a/frontend/rust-lib/flowy-ai/Cargo.toml
+++ b/frontend/rust-lib/flowy-ai/Cargo.toml
@@ -35,7 +35,7 @@ serde_json = { workspace = true }
anyhow = "1.0.86"
tokio-stream = "0.1.15"
tokio-util = { workspace = true, features = ["full"] }
-af-local-ai = { version = "0.1.0", features = ["verbose"] }
+af-local-ai = { version = "0.1.0" }
af-plugin = { version = "0.1.0" }
reqwest = { version = "0.11.27", features = ["json"] }
sha2 = "0.10.7"
diff --git a/frontend/rust-lib/flowy-ai/src/ai_manager.rs b/frontend/rust-lib/flowy-ai/src/ai_manager.rs
index 10f7bc2d09..eabf41a1e3 100644
--- a/frontend/rust-lib/flowy-ai/src/ai_manager.rs
+++ b/frontend/rust-lib/flowy-ai/src/ai_manager.rs
@@ -117,8 +117,18 @@ impl AIManager {
}
}
+ #[instrument(skip_all, err)]
pub async fn initialize(&self, _workspace_id: &str) -> Result<(), FlowyError> {
- self.local_ai.reload().await?;
+ let local_ai = self.local_ai.clone();
+ tokio::spawn(async move {
+ if let Err(err) = local_ai.destroy_plugin().await {
+ error!("Failed to destroy plugin: {}", err);
+ }
+
+ if let Err(err) = local_ai.reload().await {
+ error!("[AI Manager] failed to reload local AI: {:?}", err);
+ }
+ });
Ok(())
}
diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs
index c9b9ab52be..c3f57e6fac 100644
--- a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs
+++ b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs
@@ -175,7 +175,6 @@ impl LocalAIController {
pub async fn reload(&self) -> FlowyResult<()> {
let is_enabled = self.is_enabled();
-
self.toggle_plugin(is_enabled).await?;
Ok(())
}
@@ -459,7 +458,6 @@ async fn initialize_ai_plugin(
llm_resource: &Arc<LocalAIResourceController>,
ret: Option<tokio::sync::oneshot::Sender<()>>,
) -> FlowyResult<()> {
- let plugin = plugin.clone();
let lack_of_resource = llm_resource.get_lack_of_resource().await;
chat_notification_builder(
@@ -489,16 +487,17 @@ async fn initialize_ai_plugin(
})
.send();
- if let Err(err) = plugin.destroy_plugin().await {
- error!(
- "[AI Plugin] failed to destroy plugin when lack of resource: {:?}",
- err
- );
- }
-
return Ok(());
}
+ if let Err(err) = plugin.destroy_plugin().await {
+ error!(
+ "[AI Plugin] failed to destroy plugin when lack of resource: {:?}",
+ err
+ );
+ }
+
+ let plugin = plugin.clone();
let cloned_llm_res = llm_resource.clone();
tokio::task::spawn_blocking(move || {
futures::executor::block_on(async move {