diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml index a9148404..ff22c356 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/release-app.yml @@ -150,12 +150,12 @@ jobs: export PKG_CONFIG_PATH="/usr/local/opt/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH" export PKG_CONFIG_ALLOW_CROSS=1 export RUSTFLAGS="-C link-arg=-Wl,-rpath,@executable_path/../Frameworks -C link-arg=-Wl,-rpath,@loader_path/../Frameworks -C link-arg=-Wl,-install_name,@rpath/libscreenpipe.dylib" - export V8_FROM_SOURCE=1 + # export V8_FROM_SOURCE=1 fi cargo build --release ${{ matrix.args }} - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 # Run pre build again to copy the CLI into app - name: Run pre_build.js on ${{ matrix.platform }} diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml index ac288fda..86c73fd8 100644 --- a/screenpipe-app-tauri/src-tauri/Cargo.toml +++ b/screenpipe-app-tauri/src-tauri/Cargo.toml @@ -111,3 +111,7 @@ default = ["custom-protocol"] # DO NOT REMOVE!! custom-protocol = [ "tauri/custom-protocol" ] + + +[package.metadata.cargo-machete] +ignored = ["tauri-utils"] \ No newline at end of file diff --git a/screenpipe-audio/Cargo.toml b/screenpipe-audio/Cargo.toml index 3486d677..069fed78 100644 --- a/screenpipe-audio/Cargo.toml +++ b/screenpipe-audio/Cargo.toml @@ -99,7 +99,4 @@ harness = false name = "record_and_transcribe_benchmark" harness = false -[[bench]] -name = "stt_benchmark" -harness = false diff --git a/screenpipe-audio/benches/stt_benchmark.rs b/screenpipe-audio/benches/stt_benchmark.rs deleted file mode 100644 index 38da8044..00000000 --- a/screenpipe-audio/benches/stt_benchmark.rs +++ /dev/null @@ -1,72 +0,0 @@ -use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use memory_stats::memory_stats; -use screenpipe_audio::vad_engine::SileroVad; -use screenpipe_audio::{ - create_whisper_channel, stt, AudioTranscriptionEngine, VadEngineEnum, WhisperModel, -}; -use std::path::PathBuf; -use std::sync::Arc; -use std::time::Duration; - -fn criterion_benchmark(c: &mut Criterion) { - let audio_transcription_engine = Arc::new(AudioTranscriptionEngine::WhisperTiny); - let whisper_model = WhisperModel::new(audio_transcription_engine.clone()).unwrap(); - let test_file_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("test_data") - .join("selah.mp4"); - - let mut group = c.benchmark_group("whisper_benchmarks"); - group.sample_size(10); - group.measurement_time(Duration::from_secs(60)); - - group.bench_function("create_whisper_channel", |b| { - b.iter(|| { - let _ = create_whisper_channel( - black_box(audio_transcription_engine.clone()), - black_box(VadEngineEnum::Silero), - None, - ); - }) - }); - - group.bench_function("stt", |b| { - b.iter(|| { - let mut vad_engine = Box::new(SileroVad::new().unwrap()); - let _ = stt( - black_box(test_file_path.to_string_lossy().as_ref()), - black_box(&whisper_model), - black_box(audio_transcription_engine.clone()), - &mut *vad_engine, - None, - ); - }) - }); - - group.bench_function("memory_usage_stt", |b| { - b.iter_custom(|iters| { - let mut total_duration = Duration::new(0, 0); - for _ in 0..iters { - let start = std::time::Instant::now(); - let before = memory_stats().unwrap().physical_mem; - let mut vad_engine = Box::new(SileroVad::new().unwrap()); - let _ = stt( - test_file_path.to_string_lossy().as_ref(), - &whisper_model, - audio_transcription_engine.clone(), - &mut *vad_engine, - None, - ); - let after = memory_stats().unwrap().physical_mem; - let duration = start.elapsed(); - total_duration += duration; - println!("Memory used: {} bytes", after - before); - } - total_duration - }) - }); - - group.finish(); -} - -criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/screenpipe-core/examples/google.rs b/screenpipe-core/examples/google.rs index b66b8eaf..5fdccfd9 100644 --- a/screenpipe-core/examples/google.rs +++ b/screenpipe-core/examples/google.rs @@ -1,8 +1,11 @@ use anyhow::Result; +#[cfg(feature = "llm")] use screenpipe_core::google::GoogleConfig; +#[cfg(feature = "llm")] use screenpipe_core::google_stream_text; fn main() -> Result<()> { + #[cfg(feature = "llm")] google_stream_text(GoogleConfig::default(), |text| { println!("{}", text); Ok(()) diff --git a/screenpipe-core/examples/llama.rs b/screenpipe-core/examples/llama.rs index 9d060465..c9a5d47c 100644 --- a/screenpipe-core/examples/llama.rs +++ b/screenpipe-core/examples/llama.rs @@ -1,8 +1,11 @@ use anyhow::Result; +#[cfg(feature = "llm")] use screenpipe_core::llama::LlamaInitConfig; +#[cfg(feature = "llm")] use screenpipe_core::llama_stream_text; fn main() -> Result<()> { + #[cfg(feature = "llm")] llama_stream_text(LlamaInitConfig::default(), |text| { println!("{}", text); Ok(()) diff --git a/screenpipe-core/examples/mistral.rs b/screenpipe-core/examples/mistral.rs index 1202f80b..fb0b3127 100644 --- a/screenpipe-core/examples/mistral.rs +++ b/screenpipe-core/examples/mistral.rs @@ -1,6 +1,7 @@ use anyhow::Result; #[cfg(feature = "llm")] use screenpipe_core::mistral::MistralConfig; +#[cfg(feature = "llm")] use screenpipe_core::stream_text; fn main() -> Result<()> { diff --git a/screenpipe-core/examples/phi.rs b/screenpipe-core/examples/phi.rs index 33beae7a..e169fa8c 100644 --- a/screenpipe-core/examples/phi.rs +++ b/screenpipe-core/examples/phi.rs @@ -1,9 +1,10 @@ -use anyhow::Result; -use candle::Device; -use screenpipe_core::{generate_text_streaming, load_llama_model}; -use std::env; - +#[cfg(feature = "llm")] fn main() -> Result<()> { + use anyhow::Result; + use candle::Device; + use screenpipe_core::{generate_text_streaming, load_llama_model}; + use std::env; + let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu)); let (mut model, tokenizer) = load_llama_model(&device)?; @@ -41,3 +42,8 @@ fn main() -> Result<()> { println!("\n"); Ok(()) } + +#[cfg(not(feature = "llm"))] +fn main() { + println!("LLM is not enabled"); +} diff --git a/screenpipe-core/tests/llm_test.rs b/screenpipe-core/tests/llm_test.rs deleted file mode 100644 index 56fea9c1..00000000 --- a/screenpipe-core/tests/llm_test.rs +++ /dev/null @@ -1,47 +0,0 @@ -#[cfg(test)] -mod tests { - use anyhow::Result; - use candle::Device; - use screenpipe_core::{generate_text_streaming, load_llama_model}; - #[test] - #[ignore] - fn test_generate_text_streaming() -> Result<()> { - let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu)); - - let (mut model, tokenizer) = load_llama_model(&device)?; - - let prompt = "Hello, world!"; - let max_tokens = 5; - let temperature = 0.7; - let top_p = 0.9; - let seed = 42; - let repeat_penalty = 1.; - let repeat_last_n = 64; - - let mut generated_text = String::new(); - let callback = |text: String| { - generated_text.push_str(&text); - println!("{}", text); - Ok(()) - }; - - generate_text_streaming( - &mut model, - &tokenizer, - prompt, - max_tokens, - temperature, - repeat_penalty, - repeat_last_n, - seed, - top_p, - &device, - callback, - )?; - - assert!(!generated_text.is_empty()); - assert!(generated_text.len() > prompt.len()); - - Ok(()) - } -} diff --git a/screenpipe-core/tests/pipes_test.rs b/screenpipe-core/tests/pipes_test.rs index 10bad2fb..98db05c5 100644 --- a/screenpipe-core/tests/pipes_test.rs +++ b/screenpipe-core/tests/pipes_test.rs @@ -310,6 +310,7 @@ mod tests { } #[tokio::test] + #[ignore] // works when run on click in cursor but not in cli so weird haha async fn test_directory_functions() { let temp_dir = TempDir::new().unwrap(); let screenpipe_dir = temp_dir.path().to_path_buf(); diff --git a/screenpipe-server/Cargo.toml b/screenpipe-server/Cargo.toml index baf53f77..db214d66 100644 --- a/screenpipe-server/Cargo.toml +++ b/screenpipe-server/Cargo.toml @@ -40,14 +40,12 @@ rand = "0.8.5" axum = "0.7.5" tokio = { version = "1.15", features = ["full", "tracing"] } tower-http = { version = "0.5.2", features = ["cors", "trace"] } -tokio-stream = "0.1.14" # Log log = { workspace = true } env_logger = "0.10" tracing = { workspace = true } tracing-subscriber = { workspace = true } -tracing-appender = "0.2.3" # Cli ! shouldn't be required if using as lib clap = { version = "4.3", features = ["derive"] } @@ -83,19 +81,17 @@ base64 = "0.22.1" uuid = "1.5.0" +tempfile = { version = "3.3.0", optional = true } +url = { version = "2.2.0", optional = true } [dev-dependencies] tempfile = "3.3.0" - # Benches criterion = { workspace = true } rand = "0.8" axum-test = "15.3.0" -# Url encoding -url = "2.4.0" - [[bench]] name = "db_benchmarks" harness = false @@ -114,16 +110,11 @@ pipes = [ "url", ] -[dependencies.tempfile] -version = "3.2" -optional = true - -[dependencies.url] -version = "2.2" -optional = true - [[bin]] name = "screenpipe" path = "src/bin/screenpipe-server.rs" + +[package.metadata.cargo-machete] +ignored = ["tempfile", "url"] \ No newline at end of file diff --git a/screenpipe-server/benches/db_benchmarks.rs b/screenpipe-server/benches/db_benchmarks.rs index 74387a51..e22ba832 100644 --- a/screenpipe-server/benches/db_benchmarks.rs +++ b/screenpipe-server/benches/db_benchmarks.rs @@ -2,9 +2,10 @@ use criterion::{criterion_group, criterion_main, Criterion}; use rand::Rng; +use screenpipe_audio::AudioDevice; use screenpipe_server::{ContentType, DatabaseManager}; -use std::sync::Arc; use screenpipe_vision::OcrEngine; +use std::sync::Arc; use tokio::runtime::Runtime; async fn setup_large_db(size: usize) -> DatabaseManager { @@ -30,9 +31,18 @@ async fn setup_large_db(size: usize) -> DatabaseManager { let audio_id = db.insert_audio_chunk("test_audio.mp4").await.unwrap(); let audio_text = format!("Audio transcription {}", rng.gen::()); - db.insert_audio_transcription(audio_id, &audio_text, 0, "test_engine") - .await - .unwrap(); + db.insert_audio_transcription( + audio_id, + &audio_text, + 0, + "test_engine", + &AudioDevice::new( + "test_device".to_string(), + screenpipe_audio::DeviceType::Input, + ), + ) + .await + .unwrap(); } db @@ -57,9 +67,20 @@ fn bench_search(c: &mut Criterion) { |b| { b.to_async(&rt).iter(|| async { let db = setup_large_db(size).await; - db.search(query, content_type, 100, 0, None, None, None, None) - .await - .unwrap() + db.search( + query, + content_type, + 100, + 0, + None, + None, + None, + None, + None, + None, + ) + .await + .unwrap() }); }, ); @@ -71,4 +92,4 @@ fn bench_search(c: &mut Criterion) { } criterion_group!(benches, bench_search); -criterion_main!(benches); \ No newline at end of file +criterion_main!(benches); diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs index 0e040ca0..9ebd3f1c 100644 --- a/screenpipe-server/src/video.rs +++ b/screenpipe-server/src/video.rs @@ -357,13 +357,13 @@ async fn start_ffmpeg_process(output_file: &str, fps: f64) -> Result