chore: force restart plugin

This commit is contained in:
Nathan 2025-03-13 13:45:01 +08:00
parent 2b8aaf1d46
commit f0b8b00461
3 changed files with 14 additions and 9 deletions

View File

@ -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",

View File

@ -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" }

View File

@ -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;