YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
try to fix deno issue + add similarity threshold for search
Louis Beaumontaef34260f4fb
diff --git a/screenpipe-app-tauri/bun.lockb b/screenpipe-app-tauri/bun.lockbindex b636ef8be..706689063 100755Binary files a/screenpipe-app-tauri/bun.lockb and b/screenpipe-app-tauri/bun.lockb differdiff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 98597ff2c..3c3e317e0 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -35,7 +35,7 @@ import { PipeConfigForm } from "./pipe-config-form";import { useHealthCheck } from "@/lib/hooks/use-health-check";import posthog from "posthog-js";import { open } from "@tauri-apps/plugin-dialog";-import { open as openUrl } from "@tauri-apps/plugin-shell";+import { Command, open as openUrl } from "@tauri-apps/plugin-shell";import {Tooltip,TooltipContent,@@ -101,7 +101,10 @@ const PipeDialog: React.FC = () => {const handleResetAllPipes = async () => {try {// reset pipes- await invoke("reset_all_pipes");+ // await invoke("reset_all_pipes");+ // instead use screenpipe pipe purge -y+ const cmd = Command.sidecar("screenpipe", ["pipe", "purge", "-y"]);+ await cmd.execute();await new Promise((resolve) => setTimeout(resolve, 1000));toast({title: "All pipes deleted",diff --git a/screenpipe-app-tauri/components/search-chat.tsx b/screenpipe-app-tauri/components/search-chat.tsxindex e4bc8c04d..bb533e3b2 100644--- a/screenpipe-app-tauri/components/search-chat.tsx+++ b/screenpipe-app-tauri/components/search-chat.tsx@@ -71,8 +71,9 @@ import { formatISO } from "date-fns";import { IconCode } from "@/components/ui/icons";import { CodeBlock } from "./ui/codeblock";import { SqlAutocompleteInput } from "./sql-autocomplete-input";-import { encode } from "@/lib/utils";+import { encode, removeDuplicateSelections } from "@/lib/utils";import { ExampleSearch, ExampleSearchCards } from "./example-search-cards";+import { useDebounce } from "@/lib/hooks/use-debounce";export function SearchChat() {// Search state@@ -118,6 +119,7 @@ export function SearchChat() {const [selectedResults, setSelectedResults] = useState<Set<number>>(new Set());+ const [similarityThreshold, setSimilarityThreshold] = useState(0.9);const [hoveredResult, setHoveredResult] = useState<number | null>(null);const [isCurlDialogOpen, setIsCurlDialogOpen] = useState(false);@@ -131,6 +133,9 @@ export function SearchChat() {const [hasSearched, setHasSearched] = useState(false);+ const [isFiltering, setIsFiltering] = useState(false);+ const debouncedThreshold = useDebounce(similarityThreshold, 300);+const handleExampleSelect = async (example: ExampleSearch) => {posthog.capture("example_search", { example: example.title });@@ -191,6 +196,23 @@ export function SearchChat() {}}, [results]);+ useEffect(() => {+ handleFilterDuplicates();+ }, [debouncedThreshold, results]);++ const handleFilterDuplicates = async () => {+ setIsFiltering(true);+ // simulate a delay to show loading state+ await new Promise((resolve) => setTimeout(resolve, 100));++ const allIndices = new Set(results.map((_, index) => index));+ setSelectedResults(+ removeDuplicateSelections(results, allIndices, debouncedThreshold)+ );+ setSelectAll(false);+ setIsFiltering(false);+ };+useEffect(() => {const handleScroll = () => {const currentScrollPosition = window.scrollY;@@ -966,13 +988,47 @@ export function SearchChat() {</div>)}{results.length > 0 && (- <div className="flex items-center space-x-2 mb-4 my-8">- <Checkbox- id="select-all"- checked={selectAll}- onCheckedChange={handleSelectAll}- />- <Label htmlFor="select-all">select all results</Label>+ <div className="flex flex-col space-y-4 mb-4 my-8">+ <div className="flex justify-between items-center">+ <div className="flex items-center space-x-2">+ <Checkbox+ id="select-all"+ checked={selectAll}+ onCheckedChange={handleSelectAll}+ />+ <Label htmlFor="select-all">select all results</Label>+ </div>+ <div className="flex items-center space-x-2">+ <Label htmlFor="similarity-threshold" className="ml-4">+ similarity threshold: {similarityThreshold.toFixed(2)}+ </Label>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircle className="h-4 w-4 text-gray-400 cursor-help" />+ </TooltipTrigger>+ <TooltipContent>+ <p>+ adjust this slider to unselect similar results. lower+ values mean stricter filtering.+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <div className="relative w-64">+ <Slider+ id="similarity-threshold"+ min={0.5}+ max={1}+ step={0.01}+ value={[similarityThreshold]}+ onValueChange={(value) => setSimilarityThreshold(value[0])}+ className={isFiltering ? "opacity-50 cursor-not-allowed" : ""}+ disabled={isFiltering}+ />+ </div>+ </div>+ </div></div>)}<div className="space-y-4">diff --git a/screenpipe-app-tauri/lib/hooks/use-debounce.tsx b/screenpipe-app-tauri/lib/hooks/use-debounce.tsxnew file mode 100644index 000000000..ba49720b5--- /dev/null+++ b/screenpipe-app-tauri/lib/hooks/use-debounce.tsx@@ -0,0 +1,17 @@+import { useState, useEffect } from "react";++export function useDebounce<T>(value: T, delay: number): T {+ const [debouncedValue, setDebouncedValue] = useState<T>(value);++ useEffect(() => {+ const handler = setTimeout(() => {+ setDebouncedValue(value);+ }, delay);++ return () => {+ clearTimeout(handler);+ };+ }, [value, delay]);++ return debouncedValue;+}diff --git a/screenpipe-app-tauri/lib/utils.ts b/screenpipe-app-tauri/lib/utils.tsindex f686818b4..5218a6e37 100644--- a/screenpipe-app-tauri/lib/utils.ts+++ b/screenpipe-app-tauri/lib/utils.ts@@ -1,6 +1,8 @@import { platform } from "@tauri-apps/plugin-os";import { type ClassValue, clsx } from "clsx";import { twMerge } from "tailwind-merge";+import { ContentItem } from "./screenpipe";+import levenshtein from "js-levenshtein";export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs));@@ -58,3 +60,43 @@ export function getCliPath() {return "screenpipe";}}++// Add this pure function outside of the SearchChat component+export const removeDuplicateSelections = (+ results: ContentItem[],+ selectedResults: Set<number>,+ similarityThreshold: number = 0.9+): Set<number> => {+ const newSelectedResults = new Set<number>();+ const seenContents: string[] = [];++ const getSimilarity = (str1: string, str2: string): number => {+ const maxLength = Math.max(str1.length, str2.length);+ const distance = levenshtein(str1, str2);+ return 1 - distance / maxLength;+ };++ const isDuplicate = (content: string): boolean => {+ return seenContents.some(+ (seenContent) =>+ getSimilarity(content, seenContent) >= similarityThreshold+ );+ };++ Array.from(selectedResults).forEach((index) => {+ const item = results[index];+ if (!item || !item.type) return;++ let content = "";+ if (item.type === "OCR") content = item.content.text;+ else if (item.type === "Audio") content = item.content.transcription;+ else if (item.type === "FTS") content = item.content.matched_text;++ if (!isDuplicate(content)) {+ seenContents.push(content);+ newSelectedResults.add(index);+ }+ });++ return newSelectedResults;+};diff --git a/screenpipe-app-tauri/package.json b/screenpipe-app-tauri/package.jsonindex 8dd89cae4..2dd4a6b65 100644--- a/screenpipe-app-tauri/package.json+++ b/screenpipe-app-tauri/package.json@@ -42,6 +42,7 @@"@tauri-apps/plugin-shell": "2.0.0-beta.8","@tauri-apps/plugin-store": "2.0.0-beta.7","@tauri-apps/plugin-updater": "2.0.0-beta.7",+ "@types/js-levenshtein": "^1.1.3","ai": "^3.3","ansi-to-html": "^0.7.2","class-variance-authority": "^0.7.0",@@ -49,6 +50,7 @@"cmdk": "1.0.0","date-fns": "^3.6.0","framer-motion": "^11.5.4",+ "js-levenshtein": "^1.1.6","localforage": "^1.10.0","lodash": "^4.17.21","lucide-react": "^0.414.0",diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 54ac7e506..cc0d4377c 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.2.73"+version = "0.2.74"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/capabilities/main.json b/screenpipe-app-tauri/src-tauri/capabilities/main.jsonindex 4a8c4b50c..0bb692099 100644--- a/screenpipe-app-tauri/src-tauri/capabilities/main.json+++ b/screenpipe-app-tauri/src-tauri/capabilities/main.json@@ -118,6 +118,21 @@}]},+ {+ "identifier": "shell:allow-execute",+ "allow": [+ {+ "name": "screenpipe",+ "cmd": "screenpipe",+ "args": [+ "pipe",+ "purge",+ "-y"+ ],+ "sidecar": true+ }+ ]+ },"cli:default","shell:default","dialog:default",diff --git a/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json b/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.jsonindex 4fab81021..f16e58bef 100644--- a/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json+++ b/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json@@ -1 +1 @@-{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:default","process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:allow-open","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/pipes/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of file+{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:default","process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:allow-open","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/pipes/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["pipe","purge","-y"],"cmd":"screenpipe","name":"screenpipe","sidecar":true}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of filediff --git a/screenpipe-core/Cargo.toml b/screenpipe-core/Cargo.tomlindex c84ce6f63..83020fede 100644--- a/screenpipe-core/Cargo.toml+++ b/screenpipe-core/Cargo.toml@@ -22,8 +22,8 @@ hf-hub = { workspace = true, features = ["tokio"], optional = true }reqwest = { workspace = true }tokio = { workspace = true }-deno_core = { version = "0.307.0", optional = true }-deno_ast = { version = "0.38.2", features = ["transpiling"], optional = true }+deno_core = { version = "0.311.0", optional = true }+deno_ast = { version = "0.42.0", features = ["transpiling"], optional = true }# Securityregex = { version = "1.10.6", features = ["std"], optional = true }lazy_static = { version = "1.4.0", optional = true }diff --git a/screenpipe-core/src/llama.rs b/screenpipe-core/src/llama.rsindex 050ab9f6f..a6c8e90c4 100644--- a/screenpipe-core/src/llama.rs+++ b/screenpipe-core/src/llama.rs@@ -18,6 +18,7 @@ mod llm_module {use crate::{hub_load_safetensors, TokenOutputStream};const EOS_TOKEN: &str = "</s>";+ const DEFAULT_PROMPT: &str = "My favorite theorem is ";#[derive(Clone, Debug, Copy, PartialEq, Eq)]enum Which {@@ -83,10 +84,10 @@ mod llm_module {use_flash_attn: false,prompt: None,temperature: 0.8,- top_p: Some(0.95),+ top_p: None,top_k: None,seed: 299792458,- sample_len: 100,+ sample_len: 10000,which: Which::V32_3bInstruct,model_id: None,revision: None,@@ -102,49 +103,6 @@ mod llm_module {whereF: FnMut(String) -> Result<()>,{- println!(- "avx: {}, neon: {}, simd128: {}, f16c: {}",- candle::utils::with_avx(),- candle::utils::with_neon(),- candle::utils::with_simd128(),- candle::utils::with_f16c()- );- println!(- "temp: {:.2} repeat-penalty: {:.2} repeat-last-n: {}",- args.temperature, args.repeat_penalty, args.repeat_last_n- );-- let start = std::time::Instant::now();- let api = ApiBuilder::new()- // ! hardcoded louis token dont CARE- .with_token(Some("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".to_string()))- .build()?;- let model_id = args.model_id.unwrap_or_else(|| match args.which {- Which::V1 => "Narsil/amall-7b".to_string(),- Which::V2 => "meta-llama/Llama-2-7b-hf".to_string(),- Which::V3 => "meta-llama/Meta-Llama-3-8B".to_string(),- Which::V3Instruct => "meta-llama/Meta-Llama-3-8B-Instruct".to_string(),- Which::V31 => "meta-llama/Meta-Llama-3.1-8B".to_string(),- Which::V31Instruct => "meta-llama/Meta-Llama-3.1-8B-Instruct".to_string(),- Which::V32_1b => "meta-llama/Llama-3.2-1B".to_string(),- Which::V32_1bInstruct => "meta-llama/Llama-3.2-1B-Instruct".to_string(),- Which::V32_3b => "meta-llama/Llama-3.2-3B".to_string(),- Which::V32_3bInstruct => "meta-llama/Llama-3.2-3B-Instruct".to_string(),- Which::Solar10_7B => "upstage/SOLAR-10.7B-v1.0".to_string(),- Which::TinyLlama1_1BChat => "TinyLlama/TinyLlama-1.1B-Chat-v1.0".to_string(),- });- println!("loading the model weights from {model_id}");- let revision = args.revision.unwrap_or("main".to_string());- let api = api.repo(Repo::with_revision(model_id, RepoType::Model, revision));-- let tokenizer_filename = api.get("tokenizer.json")?;- let config_filename = api.get("config.json")?;- let config: LlamaConfig = serde_json::from_slice(&std::fs::read(config_filename)?)?;- let config = config.into_config(args.use_flash_attn);-- let filenames = hub_load_safetensors(&api, "model.safetensors.index.json")?;- println!("retrieved the files in {:?}", start.elapsed());-let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu));let dtype = match args.dtype.as_deref() {@@ -154,27 +112,66 @@ mod llm_module {Some(dtype) => anyhow::bail!("Unsupported dtype {dtype}"),None => DType::F16,};+ let (llama, tokenizer_filename, mut cache, config) = {+ let api = Api::new()?;+ let model_id = args.model_id.unwrap_or_else(|| match args.which {+ Which::V1 => "Narsil/amall-7b".to_string(),+ Which::V2 => "meta-llama/Llama-2-7b-hf".to_string(),+ Which::V3 => "meta-llama/Meta-Llama-3-8B".to_string(),+ Which::V3Instruct => "meta-llama/Meta-Llama-3-8B-Instruct".to_string(),+ Which::V31 => "meta-llama/Meta-Llama-3.1-8B".to_string(),+ Which::V31Instruct => "meta-llama/Meta-Llama-3.1-8B-Instruct".to_string(),+ Which::V32_1b => "meta-llama/Llama-3.2-1B".to_string(),+ Which::V32_1bInstruct => "meta-llama/Llama-3.2-1B-Instruct".to_string(),+ Which::V32_3b => "meta-llama/Llama-3.2-3B".to_string(),+ Which::V32_3bInstruct => "meta-llama/Llama-3.2-3B-Instruct".to_string(),+ Which::Solar10_7B => "upstage/SOLAR-10.7B-v1.0".to_string(),+ Which::TinyLlama1_1BChat => "TinyLlama/TinyLlama-1.1B-Chat-v1.0".to_string(),+ });+ println!("loading the model weights from {model_id}");+ let revision = args.revision.unwrap_or("main".to_string());+ let api = api.repo(Repo::with_revision(model_id, RepoType::Model, revision));++ let tokenizer_filename = api.get("tokenizer.json")?;+ let config_filename = api.get("config.json")?;+ let config: LlamaConfig = serde_json::from_slice(&std::fs::read(config_filename)?)?;+ let config = config.into_config(args.use_flash_attn);++ let filenames = match args.which {+ Which::V1+ | Which::V2+ | Which::V3+ | Which::V3Instruct+ | Which::V31+ | Which::V31Instruct+ | Which::V32_3b+ | Which::V32_3bInstruct+ | Which::Solar10_7B => hub_load_safetensors(&api, "model.safetensors.index.json")?,+ Which::V32_1b | Which::V32_1bInstruct | Which::TinyLlama1_1BChat => {+ vec![api.get("model.safetensors")?]+ }+ };+ let cache = model::Cache::new(!args.no_kv_cache, dtype, &config, &device)?;- let start = std::time::Instant::now();- let mut cache = model::Cache::new(!args.no_kv_cache, dtype, &config, &device)?;- let vb = unsafe { VarBuilder::from_mmaped_safetensors(&filenames, dtype, &device)? };- let llama = Llama::load(vb, &config)?;- println!("loaded the model in {:?}", start.elapsed());-+ let vb = unsafe { VarBuilder::from_mmaped_safetensors(&filenames, dtype, &device)? };+ (Llama::load(vb, &config)?, tokenizer_filename, cache, config)+ };let tokenizer = Tokenizer::from_file(tokenizer_filename).map_err(E::msg)?;+ let eos_token_id = config.eos_token_id.or_else(|| {+ tokenizer+ .token_to_id(EOS_TOKEN)+ .map(model::LlamaEosToks::Single)+ });+ let prompt = args.prompt.as_ref().map_or(DEFAULT_PROMPT, |p| p.as_str());let mut tokens = tokenizer- .encode(args.prompt.unwrap(), true)+ .encode(prompt, true).map_err(E::msg)?.get_ids().to_vec();-let mut tokenizer = TokenOutputStream::new(tokenizer);- for &t in tokens.iter() {- if let Some(t) = tokenizer.next_token(t)? {- callback(t)?;- }- }+ println!("starting the inference loop");+ print!("{prompt}");let mut logits_processor = {let temperature = args.temperature;let sampling = if temperature <= 0. {@@ -190,15 +187,18 @@ mod llm_module {LogitsProcessor::from_sampling(args.seed, sampling)};+ let mut start_gen = std::time::Instant::now();let mut index_pos = 0;let mut token_generated = 0;- let start_gen = std::time::Instant::now();for index in 0..args.sample_len {let (context_size, context_index) = if cache.use_kv_cache && index > 0 {(1, index_pos)} else {(tokens.len(), 0)};+ if index == 1 {+ start_gen = std::time::Instant::now()+ }let ctxt = &tokens[tokens.len().saturating_sub(context_size)..];let input = Tensor::new(ctxt, &device)?.unsqueeze(0)?;let logits = llama.forward(&input, context_index, &mut cache)?;@@ -219,15 +219,24 @@ mod llm_module {token_generated += 1;tokens.push(next_token);+ match eos_token_id {+ Some(model::LlamaEosToks::Single(eos_tok_id)) if next_token == eos_tok_id => {+ break;+ }+ Some(model::LlamaEosToks::Multiple(ref eos_ids))+ if eos_ids.contains(&next_token) =>+ {+ break;+ }+ _ => (),+ }if let Some(t) = tokenizer.next_token(next_token)? {- callback(t)?;+ print!("{t}");}}-if let Some(rest) = tokenizer.decode_rest().map_err(E::msg)? {- callback(rest)?;+ print!("{rest}");}-let dt = start_gen.elapsed();println!("\n\n{} tokens generated ({} token/s)\n",diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex 9f0403f8e..419daa0e2 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -645,20 +645,27 @@ async fn handle_pipe_command(pipe: PipeCommand, pipe_manager: &PipeManager) -> aErr(e) => eprintln!("failed to update pipe config: {}", e),}}- PipeCommand::Purge => {- print!("are you sure you want to purge all pipes? this action cannot be undone. (y/N): ");- io::stdout().flush()?;-- let mut input = String::new();- io::stdin().read_line(&mut input)?;-- if input.trim().to_lowercase() == "y" {+ PipeCommand::Purge { yes } => {+ if yes {match pipe_manager.purge_pipes().await {Ok(_) => println!("all pipes purged successfully."),Err(e) => eprintln!("failed to purge pipes: {}", e),}} else {- println!("pipe purge cancelled.");+ print!("are you sure you want to purge all pipes? this action cannot be undone. (y/N): ");+ io::stdout().flush()?;++ let mut input = String::new();+ io::stdin().read_line(&mut input)?;++ if input.trim().to_lowercase() == "y" {+ match pipe_manager.purge_pipes().await {+ Ok(_) => println!("all pipes purged successfully."),+ Err(e) => eprintln!("failed to purge pipes: {}", e),+ }+ } else {+ println!("pipe purge cancelled.");+ }}},}diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rsindex 45c0e54d2..ebc1b6be6 100644--- a/screenpipe-server/src/cli.rs+++ b/screenpipe-server/src/cli.rs@@ -259,5 +259,9 @@ pub enum PipeCommand {config: String,},/// Purge all pipes- Purge,+ Purge {+ /// Automatically confirm purge without prompting+ #[arg(short = 'y', long)]+ yes: bool,+ },}