mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-06 21:29:53 +00:00
Revert "chore: try to fix the mobile build" (#7844)
This reverts commit 3f06f6415aee635e1e39cc772ece081484f0ab14.
This commit is contained in:
parent
2463107c6c
commit
168b29abe3
@ -23,6 +23,8 @@ use flowy_ai_pub::persistence::{
|
||||
use flowy_ai_pub::user_service::AIUserService;
|
||||
use futures_util::SinkExt;
|
||||
use lib_infra::util::get_operating_system;
|
||||
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
|
||||
use ollama_rs::Ollama;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Deref;
|
||||
use std::path::PathBuf;
|
||||
@ -32,11 +34,6 @@ use tokio_stream::StreamExt;
|
||||
use tracing::{debug, error, info, instrument, warn};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use ollama_rs::Ollama;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct LocalAISetting {
|
||||
pub ollama_server_url: String,
|
||||
@ -62,7 +59,6 @@ pub struct LocalAIController {
|
||||
current_chat_id: ArcSwapOption<Uuid>,
|
||||
store_preferences: Weak<KVStorePreferences>,
|
||||
user_service: Arc<dyn AIUserService>,
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
ollama: ArcSwapOption<Ollama>,
|
||||
}
|
||||
|
||||
@ -95,9 +91,7 @@ impl LocalAIController {
|
||||
res_impl,
|
||||
));
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
let ollama = {
|
||||
let mut ollama = ArcSwapOption::default();
|
||||
let ollama = ArcSwapOption::default();
|
||||
let sys = get_operating_system();
|
||||
if sys.is_desktop() {
|
||||
let setting = local_ai_resource.get_llm_setting();
|
||||
@ -106,9 +100,6 @@ impl LocalAIController {
|
||||
.map(Arc::new)
|
||||
.ok(),
|
||||
);
|
||||
}
|
||||
ollama
|
||||
};
|
||||
|
||||
// Subscribe to state changes
|
||||
let mut running_state_rx = local_ai.subscribe_running_state();
|
||||
@ -172,9 +163,8 @@ impl LocalAIController {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
Self {
|
||||
ai_plugin: local_ai,
|
||||
resource: local_ai_resource,
|
||||
@ -184,18 +174,6 @@ impl LocalAIController {
|
||||
ollama,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
{
|
||||
Self {
|
||||
ai_plugin: local_ai,
|
||||
resource: local_ai_resource,
|
||||
current_chat_id: ArcSwapOption::default(),
|
||||
store_preferences,
|
||||
user_service,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[instrument(level = "debug", skip_all)]
|
||||
pub async fn observe_plugin_resource(&self) {
|
||||
let sys = get_operating_system();
|
||||
@ -329,35 +307,18 @@ impl LocalAIController {
|
||||
}
|
||||
|
||||
pub async fn get_all_chat_local_models(&self) -> Vec<AIModel> {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
self
|
||||
.get_filtered_local_models(|name| !name.contains("embed"))
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
{
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_all_embedded_local_models(&self) -> Vec<AIModel> {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
self
|
||||
.get_filtered_local_models(|name| name.contains("embed"))
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
{
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to avoid code duplication in model retrieval
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
async fn get_filtered_local_models<F>(&self, filter_fn: F) -> Vec<AIModel>
|
||||
where
|
||||
F: Fn(&str) -> bool,
|
||||
@ -383,8 +344,6 @@ impl LocalAIController {
|
||||
let mut conn = self.user_service.sqlite_connection(uid)?;
|
||||
match select_local_ai_model(&mut conn, model_name) {
|
||||
None => {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
let ollama = self
|
||||
.ollama
|
||||
.load_full()
|
||||
@ -414,12 +373,6 @@ impl LocalAIController {
|
||||
},
|
||||
)?;
|
||||
Ok(model_type)
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
{
|
||||
Ok(ModelType::Chat)
|
||||
}
|
||||
},
|
||||
Some(r) => Ok(ModelType::from(r.model_type)),
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user