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

Method new

core/src/text_splitter.rs:141–155  ·  view source on GitHub ↗

Create a new text chunk

(content: String, start_index: usize, end_index: usize, chunk_index: usize)

Source from the content-addressed store, hash-verified

139impl TextChunk {
140 /// Create a new text chunk
141 pub fn new(content: String, start_index: usize, end_index: usize, chunk_index: usize) -> Self {
142 let mut metadata = HashMap::new();
143 metadata.insert(
144 "length".to_string(),
145 serde_json::Value::Number(content.chars().count().into()),
146 );
147
148 Self {
149 content,
150 start_index,
151 end_index,
152 chunk_index,
153 metadata,
154 }
155 }
156
157 /// Add metadata to the chunk
158 pub fn with_metadata(mut self, key: String, value: serde_json::Value) -> Self {

Callers

nothing calls this directly

Calls 3

insertMethod · 0.80
to_stringMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected