Skip to main content

qdrant_client/builders/
feedback_item_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct FeedbackItemBuilder {
5    /// The id or vector from the original model
6    pub(crate) example: VectorInput,
7    /// Score for this vector as determined by the feedback provider
8    pub(crate) score: f32,
9}
10
11impl FeedbackItemBuilder {
12    /// Create a new builder with an example and its score.
13    ///
14    /// # Arguments
15    ///
16    /// * `example` - The id or vector from the original model.
17    /// * `score` - Score for this vector as determined by the feedback provider.
18    ///
19    /// # Examples
20    ///
21    /// ```
22    /// use qdrant_client::qdrant::{FeedbackItemBuilder, PointId, VectorInput};
23    ///
24    /// let item = FeedbackItemBuilder::new(VectorInput::new_id(PointId::from(42)), 0.9);
25    /// ```
26    pub fn new(example: impl Into<VectorInput>, score: f32) -> Self {
27        Self {
28            example: example.into(),
29            score,
30        }
31    }
32
33    /// Builds the desired type. Can often be omitted.
34    pub fn build(self) -> FeedbackItem {
35        FeedbackItem {
36            example: Some(self.example),
37            score: self.score,
38        }
39    }
40}
41
42impl From<FeedbackItemBuilder> for FeedbackItem {
43    fn from(value: FeedbackItemBuilder) -> Self {
44        value.build()
45    }
46}