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
fixed chunking simple on tesseract
matthew-heartful2544da910195
diff --git a/screenpipe-server/src/chunking.rs b/screenpipe-server/src/chunking.rsindex 085ddcfb8..887a364f8 100644--- a/screenpipe-server/src/chunking.rs+++ b/screenpipe-server/src/chunking.rs@@ -1,4 +1,4 @@-use anyhow::{Result, anyhow};+use anyhow::Result;use candle::{Device, Tensor, DType};use candle_nn::{VarBuilder, Module};use candle_transformers::models::jina_bert::{BertModel, Config};@@ -82,22 +82,14 @@ pub fn text_chunking_simple(text: &str) -> Result<Vec<String>> {let end = (start + chunk_size).min(text.len());// Find a valid char boundary- let end = match text[start..].char_indices().take_while(|(i, _)| *i + start <= end).last() {- Some((i, _)) => start + i + 1,- None => break, // If we can't find a valid boundary, stop processing- };+ let end = text[start..].char_indices()+ .take_while(|(i, _)| *i + start <= end)+ .last()+ .map(|(i, _)| start + i + 1)+ .unwrap_or(text.len());- if end <= start {- // If we couldn't find a valid boundary, skip this character- start += 1;- continue;- }-// Safely create the chunk- match text.get(start..end) {- Some(chunk) => chunks.push(chunk.to_string()),- None => return Err(anyhow!("Failed to create chunk from indices {} to {}", start, end)),- }+ chunks.push(text[start..end].to_string());start = if end == text.len() { end } else { end - overlap };}