vectus 0.1.38

A vector database implemented in Rust for learning purposes.
Documentation
pub mod splitters;

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use uuid::Uuid;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Document {
    pub id: Uuid,
    pub page_content: String,
    pub metadata: HashMap<String, String>,
}

pub struct DocBuilder {
    page_content: String,
    metadata: HashMap<String, String>,
}

impl DocBuilder {
    pub fn new() -> Self {
        DocBuilder {
            page_content: String::new(),
            metadata: HashMap::new(),
        }
    }

    pub fn with_page_content(mut self, page_content: &str) -> Self {
        self.page_content = page_content.to_string();
        self
    }

    pub fn add_metadata(mut self, key: &str, value: &str) -> Self {
        self.metadata.insert(key.to_string(), value.to_string());
        self
    }

    pub fn build(self) -> Document {
        Document {
            id: Uuid::new_v4(),
            page_content: self.page_content,
            metadata: self.metadata,
        }
    }
}