Skip to content

Commit 0325f15

Browse files
authored
Rename StoreInput and MetadataValue Variant From Binary to Image (#76)
* Change storeinput and metavalue variant from binary to image, remove store_type from aiproxy create_store * Fix python lib after change in types and update readme
1 parent 44b6181 commit 0325f15

File tree

29 files changed

+59
-249
lines changed

29 files changed

+59
-249
lines changed

ahnlich/ai/src/engine/store.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::error::AIProxyError;
22
use crate::AHNLICH_AI_RESERVED_META_KEY;
33
use ahnlich_types::ai::AIModel;
44
use ahnlich_types::ai::AIStoreInfo;
5-
use ahnlich_types::ai::AIStoreType;
65
use ahnlich_types::keyval::StoreInput;
76
use ahnlich_types::keyval::StoreKey;
87
use ahnlich_types::keyval::StoreName;
@@ -58,18 +57,14 @@ impl AIStoreHandler {
5857
pub(crate) fn create_store(
5958
&self,
6059
store_name: StoreName,
61-
store_type: AIStoreType,
60+
6261
model: AIModel,
6362
) -> Result<(), AIProxyError> {
6463
if self
6564
.stores
6665
.try_insert(
6766
store_name.clone(),
68-
Arc::new(AIStore::create(
69-
store_type,
70-
store_name.clone(),
71-
model.clone(),
72-
)),
67+
Arc::new(AIStore::create(store_name.clone(), model.clone())),
7368
&self.stores.guard(),
7469
)
7570
.is_err()
@@ -88,7 +83,6 @@ impl AIStoreHandler {
8883
.map(|(store_name, store)| AIStoreInfo {
8984
name: store_name.clone(),
9085
model: store.model.clone(),
91-
r#type: store.r#type.clone(),
9286
embedding_size: store.model.embedding_size().into(),
9387
})
9488
.collect()
@@ -197,14 +191,12 @@ impl AIStoreHandler {
197191
pub struct AIStore {
198192
name: StoreName,
199193
/// Making use of a concurrent hashmap, we should be able to create an engine that manages stores
200-
r#type: AIStoreType,
201194
model: AIModel,
202195
}
203196

204197
impl AIStore {
205-
pub(super) fn create(r#type: AIStoreType, store_name: StoreName, model: AIModel) -> Self {
198+
pub(super) fn create(store_name: StoreName, model: AIModel) -> Self {
206199
Self {
207-
r#type,
208200
name: store_name,
209201
model,
210202
}

ahnlich/ai/src/error.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ahnlich_types::{ai::AIStoreType, keyval::StoreName};
1+
use ahnlich_types::keyval::StoreName;
22
use thiserror::Error;
33

44
#[derive(Error, Debug, Eq, PartialEq, PartialOrd, Ord)]
@@ -15,9 +15,4 @@ pub enum AIProxyError {
1515
ReservedError(String),
1616
#[error("Unexpected DB Response {0} ")]
1717
UnexpectedDBResponse(String),
18-
#[error("Store dimension is [{store_type}], input dimension of [{input_type}] was specified")]
19-
StoreTypeMismatch {
20-
store_type: AIStoreType,
21-
input_type: AIStoreType,
22-
},
2318
}

ahnlich/ai/src/server/task.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ impl AhnlichProtocol for AIProxyTask {
5656
)),
5757
AIQuery::InfoServer => Ok(AIServerResponse::InfoServer(self.server_info())),
5858
AIQuery::CreateStore {
59-
r#type,
6059
store,
6160
model,
6261
mut predicates,
@@ -85,7 +84,7 @@ impl AhnlichProtocol for AIProxyTask {
8584
Err(err) => Err(err.to_string()),
8685
Ok(_) => self
8786
.store_handler
88-
.create_store(store, r#type, model)
87+
.create_store(store, model)
8988
.map(|_| AIServerResponse::Unit)
9089
.map_err(|e| e.to_string()),
9190
}

ahnlich/ai/src/tests/aiproxy_test.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use ahnlich_db::cli::ServerConfig;
22
use ahnlich_db::server::handler::Server;
33
use ahnlich_types::{
4-
ai::{
5-
AIModel, AIQuery, AIServerQuery, AIServerResponse, AIServerResult, AIStoreInfo, AIStoreType,
6-
},
4+
ai::{AIModel, AIQuery, AIServerQuery, AIServerResponse, AIServerResult, AIStoreInfo},
75
db::StoreUpsert,
86
keyval::{StoreInput, StoreName, StoreValue},
97
metadata::{MetadataKey, MetadataValue},
@@ -119,7 +117,6 @@ async fn test_ai_proxy_create_store_success() {
119117
let second_stream = TcpStream::connect(address).await.unwrap();
120118
let store_name = StoreName(String::from("Sample Store"));
121119
let message = AIServerQuery::from_queries(&[AIQuery::CreateStore {
122-
r#type: AIStoreType::RawString,
123120
store: store_name.clone(),
124121
model: AIModel::Llama3,
125122
predicates: HashSet::new(),
@@ -138,7 +135,7 @@ async fn test_ai_proxy_create_store_success() {
138135
AIStoreInfo {
139136
name: store_name.clone(),
140137
model: AIModel::Llama3,
141-
r#type: AIStoreType::RawString,
138+
142139
embedding_size: AIModel::Llama3.embedding_size().into(),
143140
},
144141
]))));
@@ -178,7 +175,6 @@ async fn test_ai_proxy_get_pred_succeeds() {
178175
];
179176
let message = AIServerQuery::from_queries(&[
180177
AIQuery::CreateStore {
181-
r#type: AIStoreType::RawString,
182178
store: store_name.clone(),
183179
model: AIModel::Llama3,
184180
predicates: HashSet::from_iter([
@@ -255,7 +251,6 @@ async fn test_ai_proxy_get_sim_n_succeeds() {
255251
];
256252
let message = AIServerQuery::from_queries(&[
257253
AIQuery::CreateStore {
258-
r#type: AIStoreType::RawString,
259254
store: store_name.clone(),
260255
model: AIModel::Llama3,
261256
predicates: HashSet::from_iter([
@@ -313,7 +308,6 @@ async fn test_ai_proxy_create_drop_pred_index() {
313308
)];
314309
let message = AIServerQuery::from_queries(&[
315310
AIQuery::CreateStore {
316-
r#type: AIStoreType::RawString,
317311
store: store_name.clone(),
318312
model: AIModel::Llama3,
319313
predicates: HashSet::from_iter([]),
@@ -381,7 +375,6 @@ async fn test_ai_proxy_del_key_drop_store() {
381375
)];
382376
let message = AIServerQuery::from_queries(&[
383377
AIQuery::CreateStore {
384-
r#type: AIStoreType::RawString,
385378
store: store_name.clone(),
386379
model: AIModel::Llama3,
387380
predicates: HashSet::from_iter([]),
@@ -437,7 +430,6 @@ async fn test_ai_proxy_fails_db_server_unavailable() {
437430
let message = AIServerQuery::from_queries(&[
438431
AIQuery::Ping,
439432
AIQuery::CreateStore {
440-
r#type: AIStoreType::RawString,
441433
store: store_name.clone(),
442434
model: AIModel::Llama3,
443435
predicates: HashSet::from_iter([]),
@@ -480,14 +472,12 @@ async fn test_ai_proxy_test_with_persistence() {
480472

481473
let message = AIServerQuery::from_queries(&[
482474
AIQuery::CreateStore {
483-
r#type: AIStoreType::RawString,
484475
store: store_name.clone(),
485476
model: AIModel::Llama3,
486477
predicates: HashSet::from_iter([]),
487478
non_linear_indices: HashSet::new(),
488479
},
489480
AIQuery::CreateStore {
490-
r#type: AIStoreType::Binary,
491481
store: store_name_2.clone(),
492482
model: AIModel::Llama3,
493483
predicates: HashSet::from_iter([]),
@@ -536,7 +526,6 @@ async fn test_ai_proxy_test_with_persistence() {
536526
expected.push(Ok(AIServerResponse::StoreList(HashSet::from_iter([
537527
AIStoreInfo {
538528
name: store_name_2.clone(),
539-
r#type: AIStoreType::Binary,
540529
model: AIModel::Llama3,
541530
embedding_size: AIModel::Llama3.embedding_size().into(),
542531
},
@@ -555,7 +544,6 @@ async fn test_ai_proxy_destroy_database() {
555544
let store_name = StoreName(String::from("Deven Kicks"));
556545
let message = AIServerQuery::from_queries(&[
557546
AIQuery::CreateStore {
558-
r#type: AIStoreType::RawString,
559547
store: store_name.clone(),
560548
model: AIModel::Llama3,
561549
predicates: HashSet::from_iter([]),
@@ -571,7 +559,7 @@ async fn test_ai_proxy_destroy_database() {
571559
expected.push(Ok(AIServerResponse::StoreList(HashSet::from_iter([
572560
AIStoreInfo {
573561
name: store_name,
574-
r#type: AIStoreType::RawString,
562+
575563
model: AIModel::Llama3,
576564
embedding_size: AIModel::Llama3.embedding_size().into(),
577565
},
@@ -599,15 +587,15 @@ async fn test_ai_proxy_binary_store_actions() {
599587
)]);
600588
let store_data = vec![
601589
(
602-
StoreInput::Binary(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
590+
StoreInput::Image(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
603591
store_value_1.clone(),
604592
),
605593
(
606-
StoreInput::Binary(vec![102, 3, 4, 6, 7, 8, 4, 190]),
594+
StoreInput::Image(vec![102, 3, 4, 6, 7, 8, 4, 190]),
607595
store_value_2.clone(),
608596
),
609597
(
610-
StoreInput::Binary(vec![211, 2, 4, 6, 7, 8, 8, 92, 21, 10]),
598+
StoreInput::Image(vec![211, 2, 4, 6, 7, 8, 8, 92, 21, 10]),
611599
StoreValue::from_iter([(
612600
matching_metadatakey.clone(),
613601
MetadataValue::RawString("Daniel".to_owned()),
@@ -617,7 +605,6 @@ async fn test_ai_proxy_binary_store_actions() {
617605

618606
let message = AIServerQuery::from_queries(&[
619607
AIQuery::CreateStore {
620-
r#type: AIStoreType::Binary,
621608
store: store_name.clone(),
622609
model: AIModel::Llama3,
623610
predicates: HashSet::new(),
@@ -656,7 +643,6 @@ async fn test_ai_proxy_binary_store_actions() {
656643
expected.push(Ok(AIServerResponse::StoreList(HashSet::from_iter([
657644
AIStoreInfo {
658645
name: store_name,
659-
r#type: AIStoreType::Binary,
660646
model: AIModel::Llama3,
661647
embedding_size: AIModel::Llama3.embedding_size().into(),
662648
},
@@ -668,7 +654,7 @@ async fn test_ai_proxy_binary_store_actions() {
668654
})));
669655
expected.push(Ok(AIServerResponse::Del(1)));
670656
expected.push(Ok(AIServerResponse::Get(vec![(
671-
StoreInput::Binary(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
657+
StoreInput::Image(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
672658
store_value_1.clone(),
673659
)])));
674660
expected.push(Ok(AIServerResponse::Del(1)));
@@ -695,15 +681,15 @@ async fn test_ai_proxy_binary_store_with_text_and_binary() {
695681
)]);
696682
let store_data = vec![
697683
(
698-
StoreInput::Binary(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
684+
StoreInput::Image(vec![93, 4, 1, 6, 2, 8, 8, 32, 45]),
699685
store_value_1.clone(),
700686
),
701687
(
702-
StoreInput::Binary(vec![102, 3, 4, 6, 7, 8, 4, 190]),
688+
StoreInput::Image(vec![102, 3, 4, 6, 7, 8, 4, 190]),
703689
store_value_2.clone(),
704690
),
705691
(
706-
StoreInput::Binary(vec![211, 2, 4, 6, 7, 8, 8, 92, 21, 10]),
692+
StoreInput::Image(vec![211, 2, 4, 6, 7, 8, 8, 92, 21, 10]),
707693
StoreValue::from_iter([(
708694
matching_metadatakey.clone(),
709695
MetadataValue::RawString("Daniel".to_owned()),
@@ -720,7 +706,6 @@ async fn test_ai_proxy_binary_store_with_text_and_binary() {
720706

721707
let message = AIServerQuery::from_queries(&[
722708
AIQuery::CreateStore {
723-
r#type: AIStoreType::Binary,
724709
store: store_name.clone(),
725710
model: AIModel::Llama3,
726711
predicates: HashSet::new(),
@@ -761,7 +746,6 @@ async fn test_ai_proxy_binary_store_with_text_and_binary() {
761746
expected.push(Ok(AIServerResponse::StoreList(HashSet::from_iter([
762747
AIStoreInfo {
763748
name: store_name,
764-
r#type: AIStoreType::Binary,
765749
model: AIModel::Llama3,
766750
embedding_size: AIModel::Llama3.embedding_size().into(),
767751
},

0 commit comments

Comments
 (0)