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: force restart plugin

Nathanf0b8b004610b
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 672e355983..c7d563e256 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -198,7 +198,7 @@ dependencies = [
[[package]]
name = "appflowy-local-ai"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cf0b5e77d3bbcecbcd9cbed86476658b477399e6#cf0b5e77d3bbcecbcd9cbed86476658b477399e6"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0#cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0"
dependencies = [
"anyhow",
"appflowy-plugin",
@@ -218,7 +218,7 @@ dependencies = [
[[package]]
name = "appflowy-plugin"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cf0b5e77d3bbcecbcd9cbed86476658b477399e6#cf0b5e77d3bbcecbcd9cbed86476658b477399e6"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0#cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0"
dependencies = [
"anyhow",
"cfg-if",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 0a732ec2a2..ccbfbca269 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -152,5 +152,5 @@ 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
# ⚠️⚠️⚠️️
-appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cf0b5e77d3bbcecbcd9cbed86476658b477399e6" }
-appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cf0b5e77d3bbcecbcd9cbed86476658b477399e6" }
+appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0" }
+appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0" }
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 8fa27ccc26..11a0e9a480 100644
--- a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs
+++ b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs
@@ -141,7 +141,7 @@ impl LocalAIController {
resource: &Arc<LocalAIResourceController>,
ai_plugin: &Arc<OllamaAIPlugin>,
) {
- if let Err(err) = initialize_ai_plugin(ai_plugin, resource, None).await {
+ if let Err(err) = initialize_ai_plugin(ai_plugin, resource, None, false).await {
error!("[AI Plugin] failed to setup plugin: {:?}", err);
}
}
@@ -278,7 +278,7 @@ impl LocalAIController {
#[instrument(level = "debug", skip_all)]
pub async fn restart_plugin(&self) {
- if let Err(err) = initialize_ai_plugin(&self.ai_plugin, &self.resource, None).await {
+ if let Err(err) = initialize_ai_plugin(&self.ai_plugin, &self.resource, None, true).await {
error!("[AI Plugin] failed to setup plugin: {:?}", err);
}
}
@@ -430,7 +430,8 @@ impl LocalAIController {
);
if enabled {
let (tx, rx) = tokio::sync::oneshot::channel();
- if let Err(err) = initialize_ai_plugin(&self.ai_plugin, &self.resource, Some(tx)).await {
+ if let Err(err) = initialize_ai_plugin(&self.ai_plugin, &self.resource, Some(tx), false).await
+ {
error!("[AI Plugin] failed to initialize local ai: {:?}", err);
}
let _ = rx.await;
@@ -460,10 +461,14 @@ async fn initialize_ai_plugin(
plugin: &Arc<OllamaAIPlugin>,
llm_resource: &Arc<LocalAIResourceController>,
ret: Option<tokio::sync::oneshot::Sender<()>>,
+ force: bool,
) -> FlowyResult<()> {
let plugin = plugin.clone();
- if plugin.get_plugin_running_state().is_loading() {
- return Ok(());
+
+ if !force {
+ if plugin.get_plugin_running_state().is_loading() {
+ return Ok(());
+ }
}
let lack_of_resource = llm_resource.get_lack_of_resource().await;