neomemx 0.1.2

A high-performance memory library for AI agents with semantic search
Documentation
//! ChromaDB vector store configuration

use serde::{Deserialize, Serialize};

/// Configuration for ChromaDB vector store
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChromaConfig {
    /// Name of the collection
    #[serde(default = "default_collection_name")]
    pub collection_name: String,

    /// Path to the local database directory
    pub path: Option<String>,

    /// Host address for ChromaDB server
    pub host: Option<String>,

    /// Port for ChromaDB server
    pub port: Option<u16>,

    /// ChromaDB Cloud API key
    pub api_key: Option<String>,

    /// ChromaDB Cloud tenant ID
    pub tenant: Option<String>,
}

fn default_collection_name() -> String {
    "neomemx".to_string()
}

impl Default for ChromaConfig {
    fn default() -> Self {
        Self {
            collection_name: default_collection_name(),
            path: Some("/tmp/chroma".to_string()),
            host: None,
            port: None,
            api_key: None,
            tenant: None,
        }
    }
}

impl ChromaConfig {
    /// Get the base URL for HTTP API
    pub fn get_base_url(&self) -> Option<String> {
        if let (Some(host), Some(port)) = (&self.host, &self.port) {
            Some(format!("http://{}:{}", host, port))
        } else {
            None
        }
    }
}