qdrant_client/builders/
recommend_input_builder.rs

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