mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-12-26 06:36:44 +00:00
chore: bump lai
This commit is contained in:
parent
ac8141ab15
commit
ccb020e885
125
frontend/rust-lib/Cargo.lock
generated
125
frontend/rust-lib/Cargo.lock
generated
@ -342,6 +342,61 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "af-local-ai"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=bcd9782fa3d6f6d36f2fa6d065e834a1400f156e#bcd9782fa3d6f6d36f2fa6d065e834a1400f156e"
|
||||
dependencies = [
|
||||
"af-plugin",
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"futures",
|
||||
"reqwest 0.11.27",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"zip 2.2.0",
|
||||
"zip-extensions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "af-mcp"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=bcd9782fa3d6f6d36f2fa6d065e834a1400f156e#bcd9782fa3d6f6d36f2fa6d065e834a1400f156e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures-util",
|
||||
"mcp_daemon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "af-plugin"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=bcd9782fa3d6f6d36f2fa6d065e834a1400f156e#bcd9782fa3d6f6d36f2fa6d065e834a1400f156e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"log",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 1.0.64",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"winreg 0.55.0",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "again"
|
||||
version = "0.1.2"
|
||||
@ -434,9 +489,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.94"
|
||||
version = "1.0.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
||||
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
||||
|
||||
[[package]]
|
||||
name = "app-error"
|
||||
@ -473,47 +528,6 @@ dependencies = [
|
||||
"thiserror 1.0.64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "appflowy-local-ai"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=52ad76f21f8f3a7b510dae029836b5fe86479e5a#52ad76f21f8f3a7b510dae029836b5fe86479e5a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"appflowy-plugin",
|
||||
"bytes",
|
||||
"futures",
|
||||
"reqwest 0.11.27",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"zip 2.2.0",
|
||||
"zip-extensions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "appflowy-plugin"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=52ad76f21f8f3a7b510dae029836b5fe86479e5a#52ad76f21f8f3a7b510dae029836b5fe86479e5a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"log",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 1.0.64",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"winreg 0.55.0",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.3.2"
|
||||
@ -2450,10 +2464,11 @@ dependencies = [
|
||||
name = "flowy-ai"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"af-local-ai",
|
||||
"af-mcp",
|
||||
"af-plugin",
|
||||
"allo-isolate",
|
||||
"anyhow",
|
||||
"appflowy-local-ai",
|
||||
"appflowy-plugin",
|
||||
"arc-swap",
|
||||
"base64 0.21.5",
|
||||
"bytes",
|
||||
@ -2472,7 +2487,6 @@ dependencies = [
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"log",
|
||||
"mcp_daemon",
|
||||
"md5",
|
||||
"notify",
|
||||
"pin-project",
|
||||
@ -2545,8 +2559,8 @@ dependencies = [
|
||||
name = "flowy-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"af-local-ai",
|
||||
"anyhow",
|
||||
"appflowy-local-ai",
|
||||
"arc-swap",
|
||||
"base64 0.21.5",
|
||||
"bytes",
|
||||
@ -6664,9 +6678,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.128"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@ -7498,22 +7512,21 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.38.0"
|
||||
version = "1.44.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
|
||||
checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio 0.8.9",
|
||||
"num_cpus",
|
||||
"mio 1.0.3",
|
||||
"parking_lot 0.12.1",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2 0.5.5",
|
||||
"tokio-macros",
|
||||
"tracing",
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -7528,9 +7541,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.3.0"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@ -152,5 +152,6 @@ 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 = "52ad76f21f8f3a7b510dae029836b5fe86479e5a" }
|
||||
appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "52ad76f21f8f3a7b510dae029836b5fe86479e5a" }
|
||||
af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "bcd9782fa3d6f6d36f2fa6d065e834a1400f156e" }
|
||||
af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "bcd9782fa3d6f6d36f2fa6d065e834a1400f156e" }
|
||||
af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "bcd9782fa3d6f6d36f2fa6d065e834a1400f156e" }
|
||||
|
||||
@ -12,6 +12,7 @@ flowy-error = { path = "../flowy-error", features = [
|
||||
"impl_from_dispatch_error",
|
||||
"impl_from_collab_folder",
|
||||
"impl_from_sqlite",
|
||||
"impl_from_appflowy_cloud",
|
||||
] }
|
||||
lib-dispatch = { workspace = true }
|
||||
tracing.workspace = true
|
||||
@ -34,8 +35,8 @@ serde_json = { workspace = true }
|
||||
anyhow = "1.0.86"
|
||||
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" }
|
||||
af-local-ai = { version = "0.1.0", features = ["verbose"] }
|
||||
af-plugin = { version = "0.1.0" }
|
||||
reqwest = { version = "0.11.27", features = ["json"] }
|
||||
sha2 = "0.10.7"
|
||||
base64 = "0.21.5"
|
||||
@ -50,7 +51,7 @@ collab-integrate.workspace = true
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
notify = "6.1.1"
|
||||
mcp_daemon = "0.2.1"
|
||||
af-mcp = { version = "0.1.0" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winreg = "0.55"
|
||||
|
||||
@ -8,7 +8,7 @@ use crate::middleware::chat_service_mw::AICloudServiceMiddleware;
|
||||
use crate::persistence::{insert_chat, read_chat_metadata, ChatTable};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use appflowy_plugin::manager::PluginManager;
|
||||
use af_plugin::manager::PluginManager;
|
||||
use dashmap::DashMap;
|
||||
use flowy_ai_pub::cloud::{AIModel, ChatCloudService, ChatSettings, UpdateChatParams};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use appflowy_plugin::core::plugin::RunningState;
|
||||
use af_plugin::core::plugin::RunningState;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::local_ai::controller::LocalAISetting;
|
||||
|
||||
@ -6,7 +6,10 @@ mod chat;
|
||||
mod completion;
|
||||
pub mod entities;
|
||||
mod local_ai;
|
||||
mod mcp;
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
|
||||
pub mod mcp;
|
||||
|
||||
mod middleware;
|
||||
pub mod notification;
|
||||
mod persistence;
|
||||
|
||||
@ -4,8 +4,8 @@ use crate::local_ai::resource::{LLMResourceService, LocalAIResourceController};
|
||||
use crate::notification::{
|
||||
chat_notification_builder, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY,
|
||||
};
|
||||
use af_plugin::manager::PluginManager;
|
||||
use anyhow::Error;
|
||||
use appflowy_plugin::manager::PluginManager;
|
||||
use flowy_ai_pub::cloud::{ChatCloudService, ChatMessageMetadata, ContextLoader, LocalAIConfig};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_sqlite::kv::KVStorePreferences;
|
||||
@ -15,8 +15,8 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::local_ai::watch::is_plugin_ready;
|
||||
use crate::stream_message::StreamMessage;
|
||||
use appflowy_local_ai::ollama_plugin::OllamaAIPlugin;
|
||||
use appflowy_plugin::core::plugin::RunningState;
|
||||
use af_local_ai::ollama_plugin::OllamaAIPlugin;
|
||||
use af_plugin::core::plugin::RunningState;
|
||||
use arc_swap::ArcSwapOption;
|
||||
use futures_util::SinkExt;
|
||||
use lib_infra::util::get_operating_system;
|
||||
|
||||
@ -11,7 +11,7 @@ use crate::local_ai::watch::{watch_offline_app, WatchContext};
|
||||
use crate::notification::{
|
||||
chat_notification_builder, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY,
|
||||
};
|
||||
use appflowy_local_ai::ollama_plugin::OllamaPluginConfig;
|
||||
use af_local_ai::ollama_plugin::OllamaPluginConfig;
|
||||
use lib_infra::util::{get_operating_system, OperatingSystem};
|
||||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use appflowy_plugin::error::PluginError;
|
||||
use af_plugin::error::PluginError;
|
||||
|
||||
use flowy_ai_pub::cloud::QuestionStreamValue;
|
||||
use flowy_error::FlowyError;
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
use crate::mcp::util::map_mcp_error;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use mcp_daemon::transport::{ClientStdioTransport, Transport};
|
||||
use mcp_daemon::types::Implementation;
|
||||
use mcp_daemon::Client;
|
||||
|
||||
pub struct MCPServerConfig {
|
||||
server_cmd: String,
|
||||
args: Vec<String>,
|
||||
}
|
||||
|
||||
impl MCPServerConfig {
|
||||
pub fn is_sse_server(&self) -> bool {
|
||||
self.server_cmd.starts_with("http")
|
||||
}
|
||||
}
|
||||
|
||||
// https://modelcontextprotocol.io/docs/concepts/tools
|
||||
#[derive(Clone)]
|
||||
pub struct MCPClient {
|
||||
pub client: Client<ClientStdioTransport>,
|
||||
pub transport: ClientStdioTransport,
|
||||
}
|
||||
|
||||
impl MCPClient {
|
||||
pub async fn initialize(&self) -> Result<(), FlowyError> {
|
||||
self.transport.open().await.map_err(map_mcp_error)?;
|
||||
self.client.start().await.map_err(map_mcp_error)?;
|
||||
|
||||
let implementation = Implementation {
|
||||
name: "test".to_string(),
|
||||
version: "0.0.1".to_string(),
|
||||
};
|
||||
self
|
||||
.client
|
||||
.initialize(implementation)
|
||||
.map(|err| map_mcp_error)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn stop(&mut self) -> FlowyResult<()> {
|
||||
self.transport.close().await.map_err(map_mcp_error)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -1,29 +1,8 @@
|
||||
use crate::mcp::client::MCPClient;
|
||||
use anyhow::Context;
|
||||
use af_mcp::client::{MCPClient, MCPServerConfig};
|
||||
use af_mcp::entities::ToolsList;
|
||||
use dashmap::DashMap;
|
||||
use flowy_error::{ErrorCode, FlowyError};
|
||||
use mcp_daemon::transport::{
|
||||
ClientHttpTransport, ClientStdioTransport, ServerStdioTransport, Transport, TransportError,
|
||||
};
|
||||
use mcp_daemon::types::Implementation;
|
||||
use mcp_daemon::Client;
|
||||
use serde_json::Value;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use flowy_error::FlowyError;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use tracing::{debug, info};
|
||||
|
||||
pub struct MCPServerConfig {
|
||||
server_cmd: String,
|
||||
args: Vec<String>,
|
||||
}
|
||||
|
||||
impl MCPServerConfig {
|
||||
pub fn is_sse_server(&self) -> bool {
|
||||
self.server_cmd.starts_with("http")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MCPClientManager {
|
||||
stdio_clients: Arc<DashMap<String, MCPClient>>,
|
||||
@ -37,7 +16,7 @@ impl MCPClientManager {
|
||||
}
|
||||
|
||||
pub async fn connect_server(&self, config: MCPServerConfig) -> Result<(), FlowyError> {
|
||||
let client = connect_to_stdio_server(&config.server_cmd, config.args.as_ref()).await?;
|
||||
let client = MCPClient::new_stdio(config.clone()).await?;
|
||||
self.stdio_clients.insert(config.server_cmd, client.clone());
|
||||
client.initialize().await?;
|
||||
Ok(())
|
||||
@ -50,20 +29,11 @@ impl MCPClientManager {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn connect_to_stdio_server(command: &str, args: &[&str]) -> Result<MCPClient, FlowyError> {
|
||||
info!(
|
||||
"Connecting to running server with command: {} {}",
|
||||
command,
|
||||
args.join(" ")
|
||||
);
|
||||
|
||||
let transport = ClientStdioTransport::new(command, args).map_err(map_mcp_error)?;
|
||||
let client = Client::builder(transport.clone()).build();
|
||||
Ok(MCPClient { client, transport })
|
||||
}
|
||||
|
||||
fn map_mcp_error(err: TransportError) -> FlowyError {
|
||||
FlowyError::new(ErrorCode::MCPError, err.to_string())
|
||||
pub async fn tool_list(&self, server_cmd: &str) -> Option<ToolsList> {
|
||||
let client = self.stdio_clients.get(server_cmd)?;
|
||||
let tools = client.list_tools().await.ok();
|
||||
tracing::trace!("{}: tool list: {:?}", server_cmd, tools);
|
||||
tools
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1 @@
|
||||
mod client;
|
||||
mod manager;
|
||||
mod util;
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
use flowy_error::{ErrorCode, FlowyError};
|
||||
use mcp_daemon::transport::TransportError;
|
||||
|
||||
pub(crate) fn map_mcp_error(err: TransportError) -> FlowyError {
|
||||
FlowyError::new(ErrorCode::MCPError, err.to_string())
|
||||
}
|
||||
@ -5,7 +5,7 @@ use crate::notification::{
|
||||
chat_notification_builder, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY,
|
||||
};
|
||||
use crate::persistence::{select_single_message, ChatMessageTable};
|
||||
use appflowy_plugin::error::PluginError;
|
||||
use af_plugin::error::PluginError;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use flowy_ai_pub::cloud::{
|
||||
|
||||
@ -38,7 +38,7 @@ flowy-storage-pub = { workspace = true }
|
||||
client-api.workspace = true
|
||||
flowy-ai = { workspace = true }
|
||||
flowy-ai-pub = { workspace = true }
|
||||
appflowy-local-ai = { version = "0.1.0" }
|
||||
af-local-ai = { version = "0.1.0" }
|
||||
|
||||
|
||||
tracing.workspace = true
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use appflowy_local_ai::ai_ops::{LocalAITranslateItem, LocalAITranslateRowData};
|
||||
use af_local_ai::ai_ops::{LocalAITranslateItem, LocalAITranslateRowData};
|
||||
use collab_integrate::collab_builder::AppFlowyCollabBuilder;
|
||||
use collab_integrate::CollabKVDB;
|
||||
use flowy_ai::ai_manager::AIManager;
|
||||
|
||||
@ -57,8 +57,8 @@ pub fn create_log_filter(
|
||||
filters.push(format!("lib_infra={}", level));
|
||||
filters.push(format!("flowy_search={}", level));
|
||||
filters.push(format!("flowy_chat={}", level));
|
||||
filters.push(format!("appflowy_local_ai={}", level));
|
||||
filters.push(format!("appflowy_plugin={}", level));
|
||||
filters.push(format!("af_local_ai={}", level));
|
||||
filters.push(format!("af_plugin={}", level));
|
||||
filters.push(format!("flowy_ai={}", level));
|
||||
filters.push(format!("flowy_storage={}", level));
|
||||
// Enable the frontend logs. DO NOT DISABLE.
|
||||
|
||||
@ -15,7 +15,7 @@ for dir in "${directories[@]}"; do
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
# Define the crates to update
|
||||
crates=("appflowy-local-ai" "appflowy-plugin")
|
||||
crates=("af-local-ai" "af-plugin" "af-mcp")
|
||||
|
||||
for crate in "${crates[@]}"; do
|
||||
sed -i.bak "/^${crate}[[:alnum:]-]*[[:space:]]*=/s/rev = \"[a-fA-F0-9]\{6,40\}\"/rev = \"$NEW_REV\"/g" Cargo.toml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user