Skip to content

Commit

Permalink
Trim builder methods for GetSimN, add default to condition (#151)
Browse files Browse the repository at this point in the history
* Trim builder methods for getsim, add default to condition

* set default preprocess action to modelprocessing
  • Loading branch information
Iamdavidonuh authored Nov 30, 2024
1 parent 4ed3ad4 commit fcaa75d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ahnlich/client/src/builders/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub struct GetSimNParams {
#[builder(setter(into, transform = |s: String| StoreName(s)))]
pub store: StoreName,
pub search_input: StoreInput,

#[builder(default = None)]
pub condition: Option<PredicateCondition>,

#[builder(setter(into, transform = |n: usize| NonZeroUsize::new(n).unwrap()),default=NonZeroUsize::new(1).unwrap())]
Expand All @@ -68,7 +70,6 @@ pub struct CreatePredIndexParams {
#[builder(setter(into, transform = |s: String| StoreName(s)))]
pub store: StoreName,

//#[builder(default = HashSet::new())]
pub predicates: HashSet<MetadataKey>,

#[builder(default = None)]
Expand All @@ -92,7 +93,6 @@ pub struct DropPredIndexParams {
#[builder(setter(into, transform = |s: String| StoreName(s)))]
pub store: StoreName,

//#[builder(default = HashSet::new())]
pub predicates: HashSet<MetadataKey>,

#[builder(default = true)]
Expand All @@ -109,7 +109,7 @@ pub struct SetParams {

pub inputs: Vec<(StoreInput, StoreValue)>,

#[builder(default = PreprocessAction::NoPreprocessing)]
#[builder(default = PreprocessAction::ModelPreprocessing)]
pub preprocess_action: PreprocessAction,

#[builder(default = None)]
Expand Down
7 changes: 1 addition & 6 deletions examples/rust/image-search/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use std::{

use ahnlich_client_rs::{ai::AIClient, builders::ai as ai_params};
use ahnlich_types::{
ai::{AIModel, AIServerResponse, PreprocessAction},
ai::{AIModel, AIServerResponse},
keyval::{StoreInput, StoreName},
metadata::{MetadataKey, MetadataValue},
similarity::Algorithm,
};
use clap::{Parser, Subcommand};
use tokio;
Expand Down Expand Up @@ -84,7 +83,6 @@ async fn index_mode() {
let set_params = ai_params::SetParams::builder()
.store(storename.to_string())
.inputs(inputs)
.preprocess_action(PreprocessAction::ModelPreprocessing)
.build();
let res = ai_client
.set(set_params)
Expand Down Expand Up @@ -113,9 +111,6 @@ async fn query_mode() {
let get_sim_n_params = ai_params::GetSimNParams::builder()
.store(storename.clone().to_string())
.search_input(StoreInput::RawString(input.to_string()))
.closest_n(1)
.algorithm(Algorithm::CosineSimilarity)
.condition(None)
.build();

let res = ai_client
Expand Down

0 comments on commit fcaa75d

Please sign in to comment.