litellm-rs 0.4.16

A high-performance AI Gateway written in Rust, providing OpenAI-compatible APIs with intelligent routing, load balancing, and enterprise features
Documentation
//! Milvus Vector Database Provider
//!
//! Milvus is an open-source vector database designed for AI applications,
//! providing high-performance similarity search and vector storage.
//!
//! This provider enables integration with Milvus for:
//! - Vector storage and retrieval
//! - Similarity search
//! - Collection management
//! - Embedding storage (embeddings must be generated by another provider)
//!
//! ## Features
//!
//! - **Vector Insert**: Store embeddings with metadata
//! - **Similarity Search**: Find similar vectors with filtering
//! - **Collection Management**: Work with multiple collections
//! - **Authentication**: Support for token and basic auth
//!
//! ## Example Usage
//!
//! ```rust,ignore
//! use litellm_rs::core::providers::milvus::{MilvusProvider, MilvusConfig};
//!
//! // Create provider
//! let config = MilvusConfig::new("localhost")
//!     .with_collection("my_embeddings")
//!     .with_token("my-token");
//!
//! let provider = MilvusProvider::new(config).await?;
//!
//! // Insert vectors (embeddings from another provider)
//! let vectors = vec![vec![0.1, 0.2, 0.3, 0.4]];
//! provider.insert_vectors("my_collection", vectors, None).await?;
//!
//! // Search for similar vectors
//! let query = vec![0.1, 0.2, 0.3, 0.4];
//! let results = provider.search_vectors("my_collection", query, 10, None, None).await?;
//! ```
//!
//! ## Configuration
//!
//! Environment variables:
//! - `MILVUS_HOST`: Server host (default: localhost)
//! - `MILVUS_PORT`: Server port (default: 19530)
//! - `MILVUS_COLLECTION`: Default collection name
//! - `MILVUS_DATABASE`: Database name
//! - `MILVUS_USERNAME`: Username for basic auth
//! - `MILVUS_PASSWORD`: Password for basic auth
//! - `MILVUS_TOKEN`: API token for bearer auth
//! - `MILVUS_USE_HTTPS`: Use HTTPS (default: false)
//!
//! ## Note
//!
//! Milvus is a vector database, not an embedding model provider. To generate
//! embeddings, use another provider like OpenAI, Voyage, or Cohere, then store
//! them in Milvus for efficient similarity search.
//!
//! Reference: <https://milvus.io/docs/restful_api.md>

mod config;
mod error;
mod models;
mod provider;

// Re-export main types for external use
pub use config::MilvusConfig;
pub use error::MilvusError;
pub use models::{
    ConsistencyLevel, IndexType, MetricType, MilvusEmbeddingModel, get_available_models,
    get_model_dimensions, get_model_info, get_recommended_metric, is_known_model,
};
pub use provider::{
    MilvusInsertRequest, MilvusProvider, MilvusResponse, MilvusSearchRequest, MilvusSearchResult,
    MilvusVectorData,
};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_module_exports() {
        // Verify that main types are exported correctly
        let _ = MilvusConfig::default();
        let _ = MetricType::default();
        let _ = IndexType::default();
        let _ = ConsistencyLevel::default();
    }

    #[test]
    fn test_model_functions() {
        let models = get_available_models();
        assert!(!models.is_empty());

        let info = get_model_info("text-embedding-ada-002");
        assert!(info.is_some());

        let dims = get_model_dimensions("voyage-3");
        assert_eq!(dims, Some(1024));

        let metric = get_recommended_metric("text-embedding-ada-002");
        assert_eq!(metric, MetricType::Cosine);

        assert!(is_known_model("bge-base-en-v1.5"));
        assert!(!is_known_model("unknown-model"));
    }
}