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: find plugin load

Nathan6ba7f93f69ff
diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs
index c0dd3c2d38..bca27488cd 100644
--- a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs
+++ b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs
@@ -5,7 +5,9 @@ use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use lib_infra::async_trait::async_trait;
use crate::entities::LackOfAIResourcePB;
-use crate::local_ai::watch::{ollama_plugin_command_available, ollama_plugin_path};
+use crate::local_ai::watch::{
+ is_plugin_ready, ollama_plugin_command_available, ollama_plugin_path,
+};
#[cfg(target_os = "macos")]
use crate::local_ai::watch::{watch_offline_app, WatchContext};
use crate::notification::{
@@ -236,14 +238,14 @@ impl LocalAIResourceController {
let llm_setting = self.get_llm_setting();
let bin_path = match get_operating_system() {
OperatingSystem::MacOS | OperatingSystem::Windows => {
- let path = ollama_plugin_path();
- if !path.exists() {
+ if !is_plugin_ready() {
return Err(FlowyError::new(
- ErrorCode::AIOfflineNotInstalled,
- format!("AppFlowy Offline not installed at path: {:?}", path),
+ ErrorCode::AppFlowyLAINotReady,
+ "AppFlowyLAI not found",
));
}
- path
+
+ ollama_plugin_path()
},
_ => {
return Err(
diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs b/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs
index 12d7a4c5b6..a6ad07563b 100644
--- a/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs
+++ b/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs
@@ -84,6 +84,10 @@ pub(crate) fn offline_app_path() -> PathBuf {
PathBuf::new()
}
+pub fn is_plugin_ready() -> bool {
+ ollama_plugin_path().exists() || ollama_plugin_command_available()
+}
+
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
pub(crate) fn ollama_plugin_path() -> std::path::PathBuf {
#[cfg(target_os = "windows")]
diff --git a/frontend/rust-lib/flowy-error/src/code.rs b/frontend/rust-lib/flowy-error/src/code.rs
index e97393d094..85822f5e02 100644
--- a/frontend/rust-lib/flowy-error/src/code.rs
+++ b/frontend/rust-lib/flowy-error/src/code.rs
@@ -302,8 +302,8 @@ pub enum ErrorCode {
#[error("Unsupported file format")]
UnsupportedFileFormat = 104,
- #[error("AI offline not started")]
- AIOfflineNotInstalled = 105,
+ #[error("AppFlowy LAI not ready")]
+ AppFlowyLAINotReady = 105,
#[error("Invalid Request")]
InvalidRequest = 106,