chore: find plugin load

This commit is contained in:
Nathan 2025-03-11 13:14:47 +08:00
parent 702a486cce
commit 6ba7f93f69
3 changed files with 14 additions and 8 deletions

View File

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

View File

@ -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")]

View File

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