use menta::{embed, rank_by_similarity};

fn main() {
    let query = embed("openai/text-embedding-3-small", "rust cargo").expect("embed failed");
    let docs = vec![
        (
            "rust crates",
            embed("openai/text-embedding-3-small", "rust crates")
                .expect("embed failed")
                .embedding,
        ),
        (
            "garden flowers",
            embed("openai/text-embedding-3-small", "garden flowers")
                .expect("embed failed")
                .embedding,
        ),
        (
            "cargo workspace",
            embed("openai/text-embedding-3-small", "cargo workspace")
                .expect("embed failed")
                .embedding,
        ),
    ];

    let ranked = rank_by_similarity(
        &query.embedding,
        docs.iter()
            .map(|(name, embedding)| (*name, embedding.as_slice())),
    );

    println!("best match: {}", ranked[0].0);
}
