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    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    pub fn negative<VALUE: core::convert::Into<Vec<VectorInput>>>(self, value: VALUE) -> Self {
22        let mut new = self;
23        new.negative = Option::Some(value.into());
24        new
25    }
26    /// How to use the provided vectors to find the results
27    pub fn strategy<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
28        let mut new = self;
29        new.strategy = Option::Some(Option::Some(value.into()));
30        new
31    }
32
33    fn build_inner(self) -> Result<RecommendInput, std::convert::Infallible> {
34        Ok(RecommendInput {
35            positive: self.positive.unwrap_or_default(),
36            negative: self.negative.unwrap_or_default(),
37            strategy: self.strategy.unwrap_or_default(),
38        })
39    }
40    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
41    fn create_empty() -> Self {
42        Self {
43            positive: core::default::Default::default(),
44            negative: core::default::Default::default(),
45            strategy: core::default::Default::default(),
46        }
47    }
48}
49
50impl From<RecommendInputBuilder> for RecommendInput {
51    fn from(value: RecommendInputBuilder) -> Self {
52        value.build_inner().unwrap_or_else(|_| {
53            panic!(
54                "Failed to convert {0} to {1}",
55                "RecommendInputBuilder", "RecommendInput"
56            )
57        })
58    }
59}
60
61impl RecommendInputBuilder {
62    /// Builds the desired type. Can often be omitted.
63    pub fn build(self) -> RecommendInput {
64        self.build_inner().unwrap_or_else(|_| {
65            panic!(
66                "Failed to build {0} into {1}",
67                "RecommendInputBuilder", "RecommendInput"
68            )
69        })
70    }
71}
72
73impl Default for RecommendInputBuilder {
74    fn default() -> Self {
75        Self::create_empty()
76    }
77}