Skip to main content

qdrant_client/builders/
feedback_item_builder.rs

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