[package]
name = "embellama"
version = "0.10.1"
edition = "2024"
authors = ["Embellama Contributors"]
description = "High-performance Rust library for generating text embeddings using llama-cpp"
repository = "https://github.com/darjus/embellama"
readme = "README.md"
keywords = ["embeddings", "llama", "nlp", "machine-learning", "ai"]
categories = ["science", "api-bindings", "text-processing"]
license = "Apache-2.0"

[dependencies]
llama-cpp-2 = { version = "=0.1.138" }
llama-cpp-sys-2 = { version = "=0.1.138" }
byteorder = "1"
thiserror = "2.0"
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rayon = "1.8"
parking_lot = "0.12"
num_cpus = "1.16"

# Caching dependencies
moka = { version = "0.12", features = ["sync"] }
dashmap = "6.0"
sha2 = "0.10"
lru = "0.12"

# Optional server dependencies
axum = { version = "0.8", optional = true }
tokio = { version = "1.44", features = ["full"], optional = true }
clap = { version = "4.4", features = ["derive", "env"], optional = true }
async-trait = { version = "0.1", optional = true }
tower = { version = "0.5", optional = true }
tower-http = { version = "0.6", features = ["cors", "trace"], optional = true }
uuid = { version = "1.11", features = ["v4", "serde"], optional = true }
base64 = { version = "0.22", optional = true }
# Phase 4 dependencies
governor = { version = "0.7", optional = true }
prometheus = { version = "0.14", optional = true }
rand = { version = "0.8", optional = true }
subtle = { version = "2.6", optional = true }
sysinfo = { version = "0.38"}
redis = { version = "0.27", optional = true, features = ["tokio-comp", "connection-manager"] }
self_cell = "1.2.0"
once_cell = "1.21.3"

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
serial_test = "3.0"
tempfile = "3.8"
test-with = { version = "0.15", default-features = false }
tokio-test = "0.4"
pretty_assertions = "1.4"
proptest = "1.4"
test-log = { version = "0.2.18", features = ["trace"] }
# Server testing dependencies
reqwest = { version = "0.12", features = ["json", "blocking"] }
hyper = { version = "1.0", features = ["full"] }
hyper-util = "0.1"
chrono = { version = "0.4", features = ["serde"] }
axum-test = "18.1"

[features]
# Default features - safe for all platforms
default = ["openmp"]

# Backend acceleration features (pass-through to llama-cpp-2)
# Note: These are mutually exclusive in practice - use only one GPU backend at a time
metal = ["llama-cpp-2/metal"]  # macOS Metal acceleration
cuda = ["llama-cpp-2/cuda"]  # NVIDIA CUDA acceleration
cuda-no-vmm = ["cuda", "llama-cpp-2/cuda-no-vmm"]  # CUDA without virtual memory management
vulkan = ["llama-cpp-2/vulkan"]  # Vulkan acceleration (cross-platform GPU)
rocm = ["llama-cpp-2/rocm"]  # AMD ROCm/HIP acceleration

# CPU optimization features
openmp = ["llama-cpp-2/openmp"]  # OpenMP parallel processing

# Other llama-cpp-2 features
dynamic-link = ["llama-cpp-2/dynamic-link"]  # Dynamic linking
sampler = ["llama-cpp-2/sampler"]  # Sampler support

# Android-specific features
android-shared-stdcxx = ["llama-cpp-2/android-shared-stdcxx"]
android-static-stdcxx = ["llama-cpp-2/android-static-stdcxx"]
mtmd = ["llama-cpp-2/mtmd"]

# Backend feature groups (convenience aliases)
cuda-backend = ["cuda"]
metal-backend = ["metal"]
vulkan-backend = ["vulkan"]
rocm-backend = ["rocm"]
cpu-optimized = ["openmp"]

# Server feature
server = ["dep:axum", "dep:tokio", "dep:clap", "dep:async-trait", "dep:tower", "dep:tower-http", "dep:uuid", "dep:base64", "dep:governor", "dep:prometheus", "dep:rand", "dep:subtle"]

# Optional Redis cache feature
redis-cache = ["dep:redis", "server"]

[[bin]]
name = "embellama-server"
required-features = ["server"]
path = "src/bin/server.rs"

[[bench]]
name = "embeddings_bench"
harness = false

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
panic = "abort"

[profile.bench]
inherits = "release"

[package.metadata.docs.rs]
# Documentation build configuration
features = ["server", "openmp"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc"]

[lints.clippy]
pedantic = { level = "deny", priority = -1 }
missing_errors_doc = "allow"
