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