qdrant_client/builders/
recommend_input_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct RecommendInputBuilder {
5    /// Look for vectors closest to the vectors from these points
6    pub(crate) positive: Option<Vec<VectorInput>>,
7    /// Try to avoid vectors like the vector from these points
8    pub(crate) negative: Option<Vec<VectorInput>>,
9    /// How to use the provided vectors to find the results
10    pub(crate) strategy: Option<Option<i32>>,
11}
12
13impl RecommendInputBuilder {
14    /// Look for vectors closest to the vectors from these points
15    #[allow(unused_mut)]
16    pub fn positive<VALUE: core::convert::Into<Vec<VectorInput>>>(self, value: VALUE) -> Self {
17        let mut new = self;
18        new.positive = Option::Some(value.into());
19        new
20    }
21    /// Try to avoid vectors like the vector from these points
22    #[allow(unused_mut)]
23    pub fn negative<VALUE: core::convert::Into<Vec<VectorInput>>>(self, value: VALUE) -> Self {
24        let mut new = self;
25        new.negative = Option::Some(value.into());
26        new
27    }
28    /// How to use the provided vectors to find the results
29    #[allow(unused_mut)]
30    pub fn strategy<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
31        let mut new = self;
32        new.strategy = Option::Some(Option::Some(value.into()));
33        new
34    }
35
36    fn build_inner(self) -> Result<RecommendInput, std::convert::Infallible> {
37        Ok(RecommendInput {
38            positive: self.positive.unwrap_or_default(),
39            negative: self.negative.unwrap_or_default(),
40            strategy: self.strategy.unwrap_or_default(),
41        })
42    }
43    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
44    fn create_empty() -> Self {
45        Self {
46            positive: core::default::Default::default(),
47            negative: core::default::Default::default(),
48            strategy: core::default::Default::default(),
49        }
50    }
51}
52
53impl From<RecommendInputBuilder> for RecommendInput {
54    fn from(value: RecommendInputBuilder) -> Self {
55        value.build_inner().unwrap_or_else(|_| {
56            panic!(
57                "Failed to convert {0} to {1}",
58                "RecommendInputBuilder", "RecommendInput"
59            )
60        })
61    }
62}
63
64impl RecommendInputBuilder {
65    /// Builds the desired type. Can often be omitted.
66    pub fn build(self) -> RecommendInput {
67        self.build_inner().unwrap_or_else(|_| {
68            panic!(
69                "Failed to build {0} into {1}",
70                "RecommendInputBuilder", "RecommendInput"
71            )
72        })
73    }
74}
75
76impl Default for RecommendInputBuilder {
77    fn default() -> Self {
78        Self::create_empty()
79    }
80}