MCPcopy Create free account
hub / github.com/Rustixir/darkbird / main

Function main

example/Version-6.2.0 ( Vector Engine )/example.rs:9–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[tokio::main]
9async fn main() {
10 let db = Schema::new()
11 .with_vecstore(factory_option("LLM"))
12 .await
13 .unwrap()
14 .build();
15
16 // insert with vector_id
17 let _ = db.vec_insert("vector1".to_string(), vec![1.0, 2.0, 3.0]).await.unwrap();
18 let _ = db.vec_insert("vector2".to_string(), vec![4.0, 5.0, 6.0]).await.unwrap();
19 let _ = db.vec_insert("vector3".to_string(), vec![7.0, 8.0, 9.0]).await.unwrap();
20
21 // also can insert with uuid
22 let _ = db.vec_insert_with_uuid(vec![10.0, 0.0, 10.0]).await.unwrap();
23
24 // query
25 let query_vector = Vector(vec![2.0, 3.0, 4.0]);
26
27 // search
28 let nearest_neighbors = db.vec_k_nearest_neighbors(&query_vector, 2).unwrap();
29
30 // check
31 assert_eq!(
32 nearest_neighbors,
33 vec![
34 ("vector1".to_string(), Vector(vec![1.0, 2.0, 3.0])),
35 ("vector2".to_string(), Vector(vec![4.0, 5.0, 6.0]))
36 ]
37 );
38}

Callers

nothing calls this directly

Calls 8

VectorClass · 0.85
buildMethod · 0.80
with_vecstoreMethod · 0.80
vec_insertMethod · 0.80
vec_insert_with_uuidMethod · 0.80
factory_optionFunction · 0.70
to_stringMethod · 0.45

Tested by

no test coverage detected