diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index b81eb77..9642a33 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -87,7 +87,7 @@ jobs: - name: Install WasmEdge run: | VERSION=0.13.5 - curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- --plugins wasmedge_rustls --version=$VERSION -p /usr/local + curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- --version=$VERSION -p /usr/local - name: MySQL async examples run: | diff --git a/qdrant/.cargo/config.toml b/qdrant/.cargo/config.toml index 818507c..6b8b460 100644 --- a/qdrant/.cargo/config.toml +++ b/qdrant/.cargo/config.toml @@ -1,5 +1,6 @@ [build] target = "wasm32-wasi" +rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] [target.wasm32-wasi] runner = "wasmedge" diff --git a/qdrant/Cargo.toml b/qdrant/Cargo.toml index a41ad6d..46f35a1 100644 --- a/qdrant/Cargo.toml +++ b/qdrant/Cargo.toml @@ -3,10 +3,16 @@ name = "qdrant_examples" version = "0.1.0" edition = "2021" +[patch.crates-io] +socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } +reqwest = { git = "https://github.com/second-state/wasi_reqwest.git", branch = "0.11.x" } +hyper = { git = "https://github.com/second-state/wasi_hyper.git", branch = "v0.14.x" } +tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } + [dependencies] anyhow = "1.0" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } url = "2.3" -tokio_wasi = { version = "1", features = ["io-util", "fs", "net", "time", "rt", "macros"] } -qdrant_rest_client = "0.0.1" +tokio = { version = "1", features = ["io-util", "fs", "net", "time", "rt", "macros"] } +qdrant_rest_client = { version = "0.0.4", git="https://github.com/L-jasmine/qdrant-rest-client.git", branch = "bump/remove_rustls_plugin" } diff --git a/qdrant/src/main.rs b/qdrant/src/main.rs index 9ed4d68..db9cc89 100644 --- a/qdrant/src/main.rs +++ b/qdrant/src/main.rs @@ -1,5 +1,5 @@ -use serde_json::{json}; use qdrant::*; +use serde_json::json; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box> { @@ -9,47 +9,67 @@ async fn main() -> Result<(), Box> { println!("Create collection result is {:?}", r); let mut points = Vec::::new(); - points.push(Point{ - id: PointId::Num(1), vector: vec!(0.05, 0.61, 0.76, 0.74), payload: json!({"city": "Berlin"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(1), + vector: vec![0.05, 0.61, 0.76, 0.74], + payload: json!({"city": "Berlin"}).as_object().map(|m| m.to_owned()), }); - points.push(Point{ - id: PointId::Num(2), vector: vec!(0.19, 0.81, 0.75, 0.11), payload: json!({"city": "London"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(2), + vector: vec![0.19, 0.81, 0.75, 0.11], + payload: json!({"city": "London"}).as_object().map(|m| m.to_owned()), }); - points.push(Point{ - id: PointId::Num(3), vector: vec!(0.36, 0.55, 0.47, 0.94), payload: json!({"city": "Moscow"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(3), + vector: vec![0.36, 0.55, 0.47, 0.94], + payload: json!({"city": "Moscow"}).as_object().map(|m| m.to_owned()), }); - points.push(Point{ - id: PointId::Num(4), vector: vec!(0.18, 0.01, 0.85, 0.80), payload: json!({"city": "New York"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(4), + vector: vec![0.18, 0.01, 0.85, 0.80], + payload: json!({"city": "New York"}) + .as_object() + .map(|m| m.to_owned()), }); - points.push(Point{ - id: PointId::Num(5), vector: vec!(0.24, 0.18, 0.22, 0.44), payload: json!({"city": "Beijing"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(5), + vector: vec![0.24, 0.18, 0.22, 0.44], + payload: json!({"city": "Beijing"}).as_object().map(|m| m.to_owned()), }); - points.push(Point{ - id: PointId::Num(6), vector: vec!(0.35, 0.08, 0.11, 0.44), payload: json!({"city": "Mumbai"}).as_object().map(|m| m.to_owned()) + points.push(Point { + id: PointId::Num(6), + vector: vec![0.35, 0.08, 0.11, 0.44], + payload: json!({"city": "Mumbai"}).as_object().map(|m| m.to_owned()), }); let r = client.upsert_points("my_test", points).await; println!("Upsert points result is {:?}", r); - println!("The collection size is {}", client.collection_info("my_test").await); + println!( + "The collection size is {}", + client.collection_info("my_test").await + ); let p = client.get_point("my_test", 2).await; println!("The second point is {:?}", p); - let ps = client.get_points("my_test", vec!(1, 2, 3, 4, 5, 6)).await; + let ps = client.get_points("my_test", vec![1, 2, 3, 4, 5, 6]).await; println!("The 1-6 points are {:?}", ps); let q = vec![0.2, 0.1, 0.9, 0.7]; - let r = client.search_points("my_test", q, 2).await; + let r = client.search_points("my_test", q, 2, None).await; println!("Search result points are {:?}", r); - let r = client.delete_points("my_test", vec!(1, 4)).await; + let r = client.delete_points("my_test", vec![1, 4]).await; println!("Delete points result is {:?}", r); - println!("The collection size is {}", client.collection_info("my_test").await); + println!( + "The collection size is {}", + client.collection_info("my_test").await + ); let q = vec![0.2, 0.1, 0.9, 0.7]; - let r = client.search_points("my_test", q, 2).await; + let r = client.search_points("my_test", q, 2, None).await; println!("Search result points are {:?}", r); Ok(()) }