Skip to content

Commit 31c8df7

Browse files
committed
feat(uni): add for cosine simliarity
1 parent 4bb5198 commit 31c8df7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

inference_core/src/inference.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace inference {
22
[Throws=SemanticError]
33
Semantic init_semantic(sequence<u8> model, sequence<u8> tokenizer_data);
4+
Similarity get_cosine_similarity();
45
};
56

67
[Custom]

inference_core/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub mod embedding;
33
pub mod similarity;
44
pub mod store;
55

6+
use std::sync::Arc;
67
// make the following types available in the generated bindings
78
pub use document::Document;
89
pub use document::Metadata;
@@ -19,5 +20,8 @@ pub use similarity::RelevanceScore;
1920
pub use store::EmbeddingStore;
2021
pub use store::InMemoryEmbeddingStore;
2122

23+
pub fn get_cosine_similarity() -> Arc<dyn Similarity> {
24+
Arc::new(CosineSimilarity {})
25+
}
2226

2327
uniffi::include_scaffolding!("inference");

0 commit comments

Comments
 (0)