mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-06-27 02:50:15 +00:00
chore: remove unused ai code (#7919)
This commit is contained in:
parent
5e99eeb167
commit
7e5b243e40
833
frontend/rust-lib/Cargo.lock
generated
833
frontend/rust-lib/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -101,8 +101,6 @@ zip = "2.2.0"
|
||||
dashmap = "6.0.1"
|
||||
derive_builder = "0.20.2"
|
||||
tantivy = { version = "0.24.1" }
|
||||
af-plugin = { version = "0.1" }
|
||||
af-local-ai = { version = "0.1" }
|
||||
num_enum = "0.7.3"
|
||||
flowy-sqlite-vec = { path = "flowy-sqlite-vec" }
|
||||
|
||||
@ -157,12 +155,4 @@ collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlo
|
||||
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33f6844954f9b631693cac11aef573cf376d04f8" }
|
||||
collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33f6844954f9b631693cac11aef573cf376d04f8" }
|
||||
|
||||
# Working directory: frontend
|
||||
# To update the commit ID, run:
|
||||
# scripts/tool/update_local_ai_rev.sh new_rev_id
|
||||
# ⚠️⚠️⚠️️
|
||||
af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "093d3f4916a7b924ac66b4f0a9d81cc5fcc72eaa" }
|
||||
af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "093d3f4916a7b924ac66b4f0a9d81cc5fcc72eaa" }
|
||||
af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "093d3f4916a7b924ac66b4f0a9d81cc5fcc72eaa" }
|
||||
|
||||
langchain-rust = { version = "4.6.0", git = "https://github.com/appflowy/langchain-rust", branch = "af" }
|
@ -35,8 +35,6 @@ serde_json = { workspace = true }
|
||||
anyhow = "1.0.86"
|
||||
tokio-stream.workspace = true
|
||||
tokio-util = { workspace = true, features = ["full"] }
|
||||
af-local-ai = { workspace = true }
|
||||
af-plugin = { workspace = true }
|
||||
reqwest = { version = "0.11.27", features = ["json"] }
|
||||
sha2 = "0.10.7"
|
||||
base64 = "0.21.5"
|
||||
@ -55,7 +53,6 @@ flowy-sqlite-vec.workspace = true
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
notify = "6.1.1"
|
||||
af-mcp = { version = "0.1.0" }
|
||||
lopdf = { version = "0.36.0", optional = true }
|
||||
pulldown-cmark = { version = "0.13.0", optional = true }
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::local_ai::controller::LocalAISetting;
|
||||
use crate::local_ai::resource::PendingResource;
|
||||
use af_plugin::core::plugin::RunningState;
|
||||
use flowy_ai_pub::cloud::{
|
||||
AIModel, ChatMessage, ChatMessageType, CompletionMessage, LLMModel, OutputContent, OutputLayout,
|
||||
RelatedQuestion, RepeatedChatMessage, RepeatedRelatedQuestion, ResponseFormat,
|
||||
@ -570,19 +569,6 @@ pub enum RunningStatePB {
|
||||
Stopped = 4,
|
||||
}
|
||||
|
||||
impl From<RunningState> for RunningStatePB {
|
||||
fn from(value: RunningState) -> Self {
|
||||
match value {
|
||||
RunningState::ReadyToConnect => RunningStatePB::ReadyToRun,
|
||||
RunningState::Connecting => RunningStatePB::Connecting,
|
||||
RunningState::Connected { .. } => RunningStatePB::Connected,
|
||||
RunningState::Running { .. } => RunningStatePB::Running,
|
||||
RunningState::Stopped { .. } => RunningStatePB::Stopped,
|
||||
RunningState::UnexpectedStop { .. } => RunningStatePB::Stopped,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf, Clone, Debug)]
|
||||
pub struct LocalAIPB {
|
||||
#[pb(index = 1)]
|
||||
|
@ -7,4 +7,3 @@ pub mod completion;
|
||||
pub mod database;
|
||||
pub mod prompt;
|
||||
pub mod stream_util;
|
||||
pub mod watch;
|
||||
|
@ -1,65 +1,2 @@
|
||||
use af_plugin::error::PluginError;
|
||||
|
||||
use flowy_ai_pub::cloud::QuestionStreamValue;
|
||||
use flowy_error::FlowyError;
|
||||
use futures::{ready, Stream};
|
||||
use pin_project::pin_project;
|
||||
use serde_json::Value;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use tracing::error;
|
||||
|
||||
pub const STEAM_METADATA_KEY: &str = "0";
|
||||
pub const STEAM_ANSWER_KEY: &str = "1";
|
||||
|
||||
#[pin_project]
|
||||
pub struct QuestionStream {
|
||||
stream: Pin<Box<dyn Stream<Item = Result<Value, PluginError>> + Send>>,
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl QuestionStream {
|
||||
pub fn new<S>(stream: S) -> Self
|
||||
where
|
||||
S: Stream<Item = Result<Value, PluginError>> + Send + 'static,
|
||||
{
|
||||
QuestionStream {
|
||||
stream: Box::pin(stream),
|
||||
buffer: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for QuestionStream {
|
||||
type Item = Result<QuestionStreamValue, FlowyError>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
|
||||
match ready!(this.stream.as_mut().poll_next(cx)) {
|
||||
Some(Ok(value)) => match value {
|
||||
Value::Object(mut value) => {
|
||||
if let Some(metadata) = value.remove(STEAM_METADATA_KEY) {
|
||||
return Poll::Ready(Some(Ok(QuestionStreamValue::Metadata { value: metadata })));
|
||||
}
|
||||
|
||||
if let Some(answer) = value
|
||||
.remove(STEAM_ANSWER_KEY)
|
||||
.and_then(|s| s.as_str().map(ToString::to_string))
|
||||
{
|
||||
return Poll::Ready(Some(Ok(QuestionStreamValue::Answer { value: answer })));
|
||||
}
|
||||
|
||||
error!("Invalid streaming value: {:?}", value);
|
||||
Poll::Ready(None)
|
||||
},
|
||||
_ => {
|
||||
error!("Unexpected JSON value type: {:?}", value);
|
||||
Poll::Ready(None)
|
||||
},
|
||||
},
|
||||
Some(Err(err)) => Poll::Ready(Some(Err(FlowyError::local_ai().with_context(err)))),
|
||||
None => Poll::Ready(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
use crate::local_ai::resource::WatchDiskEvent;
|
||||
use af_plugin::core::path::{install_path, ollama_plugin_path};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use std::path::PathBuf;
|
||||
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
|
||||
use tracing::{error, trace};
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
|
||||
#[allow(dead_code)]
|
||||
pub struct WatchContext {
|
||||
watcher: notify::RecommendedWatcher,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
|
||||
#[allow(dead_code)]
|
||||
pub fn watch_offline_app() -> FlowyResult<(WatchContext, UnboundedReceiver<WatchDiskEvent>)> {
|
||||
use notify::{Event, Watcher};
|
||||
|
||||
let install_path = install_path().ok_or_else(|| {
|
||||
FlowyError::internal().with_context("Unsupported platform for offline app watching")
|
||||
})?;
|
||||
let (tx, rx) = unbounded_channel();
|
||||
let app_path = ollama_plugin_path();
|
||||
let mut watcher = notify::recommended_watcher(move |res: Result<Event, _>| match res {
|
||||
Ok(event) => {
|
||||
if event.paths.iter().any(|path| path == &app_path) {
|
||||
trace!("watch event: {:?}", event);
|
||||
match event.kind {
|
||||
notify::EventKind::Create(_) => {
|
||||
if let Err(err) = tx.send(WatchDiskEvent::Create) {
|
||||
error!("watch send error: {:?}", err)
|
||||
}
|
||||
},
|
||||
notify::EventKind::Remove(_) => {
|
||||
if let Err(err) = tx.send(WatchDiskEvent::Remove) {
|
||||
error!("watch send error: {:?}", err)
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
trace!("unhandle watch event: {:?}", event);
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => error!("watch error: {:?}", e),
|
||||
})
|
||||
.map_err(|err| FlowyError::internal().with_context(err))?;
|
||||
watcher
|
||||
.watch(&install_path, notify::RecursiveMode::NonRecursive)
|
||||
.map_err(|err| FlowyError::internal().with_context(err))?;
|
||||
|
||||
Ok((
|
||||
WatchContext {
|
||||
watcher,
|
||||
path: install_path,
|
||||
},
|
||||
rx,
|
||||
))
|
||||
}
|
@ -38,8 +38,6 @@ flowy-storage-pub = { workspace = true }
|
||||
client-api.workspace = true
|
||||
flowy-ai = { workspace = true }
|
||||
flowy-ai-pub = { workspace = true }
|
||||
af-local-ai = { workspace = true }
|
||||
af-plugin = { workspace = true }
|
||||
|
||||
|
||||
tracing.workspace = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user