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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: try to fix windows flashing window issue
Nathan81bac5950c18
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex c7d563e256..4e1619044c 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -198,7 +198,7 @@ dependencies = [[[package]]name = "appflowy-local-ai"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0#cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=f4000af60ac18ad36a5dfb3fdc72c6d3ae967127#f4000af60ac18ad36a5dfb3fdc72c6d3ae967127"dependencies = ["anyhow","appflowy-plugin",@@ -218,7 +218,7 @@ dependencies = [[[package]]name = "appflowy-plugin"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0#cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=f4000af60ac18ad36a5dfb3fdc72c6d3ae967127#f4000af60ac18ad36a5dfb3fdc72c6d3ae967127"dependencies = ["anyhow","cfg-if",diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.tomlindex ccbfbca269..42120203cc 100644--- a/frontend/rust-lib/Cargo.toml+++ b/frontend/rust-lib/Cargo.toml@@ -152,5 +152,5 @@ collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFl# To update the commit ID, run:# scripts/tool/update_local_ai_rev.sh new_rev_id# ⚠️⚠️⚠️️-appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0" }-appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "cca2e80536dc2e0a994931f43b0f1c0fd9d4abd0" }+appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "f4000af60ac18ad36a5dfb3fdc72c6d3ae967127" }+appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "f4000af60ac18ad36a5dfb3fdc72c6d3ae967127" }diff --git a/frontend/rust-lib/flowy-ai/Cargo.toml b/frontend/rust-lib/flowy-ai/Cargo.tomlindex 145ce41d3b..2db562aa0d 100644--- a/frontend/rust-lib/flowy-ai/Cargo.toml+++ b/frontend/rust-lib/flowy-ai/Cargo.toml@@ -36,7 +36,7 @@ tokio-stream = "0.1.15"tokio-util = { workspace = true, features = ["full"] }appflowy-local-ai = { version = "0.1.0", features = ["verbose"] }appflowy-plugin = { version = "0.1.0" }-reqwest = "0.11.27"+reqwest = { version = "0.11.27", features = ["json"] }sha2 = "0.10.7"base64 = "0.21.5"futures-util = "0.3.30"diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rsindex 1380ed38ec..4a9403d670 100644--- a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs+++ b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs@@ -14,11 +14,22 @@ use crate::notification::{use appflowy_local_ai::ollama_plugin::OllamaPluginConfig;use lib_infra::util::{get_operating_system, OperatingSystem};use reqwest::Client;+use serde::Deserialize;use std::path::PathBuf;use std::sync::Arc;use std::time::Duration;use tracing::{error, info, instrument, trace};+#[derive(Debug, Deserialize)]+struct TagsResponse {+ models: Vec<ModelEntry>,+}++#[derive(Debug, Deserialize)]+struct ModelEntry {+ name: String,+}+#[async_trait]pub trait LLMResourceService: Send + Sync + 'static {/// Get local ai configuration from remote server@@ -155,7 +166,6 @@ impl LocalAIResourceController {resources.pop().map(|r| r.desc())}- /// Returns true when all resources are downloaded and ready to use.pub async fn calculate_pending_resources(&self) -> FlowyResult<Vec<PendingResource>> {let mut resources = vec![];let app_path = ollama_plugin_path();@@ -184,39 +194,40 @@ impl LocalAIResourceController {},}- let required_models = vec![- setting.chat_model_name,- setting.embedding_model_name,- // Add any additional required models here.- ];- match tokio::process::Command::new("ollama")- .arg("list")- .output()- .await- {- Ok(output) if output.status.success() => {- let stdout = String::from_utf8_lossy(&output.stdout);- for model in &required_models {- if !stdout.contains(model.as_str()) {+ let required_models = vec![setting.chat_model_name, setting.embedding_model_name];++ // Query the /api/tags endpoint to get a structured list of locally available models.+ let tags_url = format!("{}/api/tags", setting.ollama_server_url);++ match client.get(&tags_url).send().await {+ Ok(resp) if resp.status().is_success() => {+ let tags: TagsResponse = resp.json().await.map_err(|e| {+ log::error!(+ "[LLM Resource] Failed to parse /api/tags JSON response: {:?}",+ e+ );+ e+ })?;+ // Check each required model is present in the response.+ for required in &required_models {+ if !tags.models.iter().any(|m| m.name.contains(required)) {log::trace!(- "[LLM Resource] required model '{}' not found in ollama list",- model+ "[LLM Resource] required model '{}' not found in API response",+ required);- resources.push(PendingResource::MissingModel(model.clone()));+ resources.push(PendingResource::MissingModel(required.clone()));+ // Optionally, you could continue checking all models rather than returning early.return Ok(resources);}}},- Ok(output) => {+ _ => {error!(- "[LLM Resource] 'ollama list' command failed with status: {:?}",- output.status+ "[LLM Resource] Failed to fetch models from {} (GET /api/tags)",+ setting.ollama_server_url);resources.push(PendingResource::OllamaServerNotReady);- },- Err(e) => {- error!("[LLM Resource] failed to execute 'ollama list': {:?}", e);- resources.push(PendingResource::OllamaServerNotReady);+ return Ok(resources);},}