MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / preview

Method preview

python/src/document_loader.rs:213–224  ·  view source on GitHub ↗
(&self, max_length: usize)

Source from the content-addressed store, hash-verified

211 /// Get a preview of the content (first n characters)
212 #[pyo3(signature = (max_length=500))]
213 fn preview(&self, max_length: usize) -> String {
214 // Use char-based iteration to respect UTF-8 character boundaries
215 let char_count = self.inner.content.chars().count();
216
217 if char_count <= max_length {
218 self.inner.content.clone()
219 } else {
220 // Take the first max_length characters (not bytes)
221 let preview: String = self.inner.content.chars().take(max_length).collect();
222 format!("{preview}...")
223 }
224 }
225
226 /// String representation
227 fn __repr__(&self) -> String {

Calls 2

countMethod · 0.80
cloneMethod · 0.80

Tested by 2