mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-12-25 06:05:47 +00:00
chore: find plugin load
This commit is contained in:
parent
702a486cce
commit
6ba7f93f69
@ -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(
|
||||
|
||||
@ -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")]
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user