Skip to main content

videre_api/
types.rs

1use serde::Serialize;
2
3/// Versioned model context attached to evidence captured by a Gallery action.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct TeachingContext {
6    pub embedding_model_id: String,
7    pub active_profile_id: Option<i64>,
8}
9
10/// Durable learning work committed with a visible people mutation.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
12pub struct LearningAcknowledgement {
13    pub generation: u64,
14    pub event_ids: Vec<i64>,
15    pub message_key: String,
16}
17
18/// Learning status for the gallery background worker.
19#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
20pub struct FaceLearningStatus {
21    pub generation: u64,
22    pub trained_generation: u64,
23    pub status: String,
24    pub last_profile_id: Option<i64>,
25    /// What became of the last trained candidate: `promoted` or `rejected`,
26    /// or `None` before any candidate was stored. Lets a `current` status
27    /// say whether the last run changed the profile in use.
28    pub last_candidate: Option<String>,
29    pub last_error: Option<String>,
30    /// While `status` is `waiting`: the feedback training still needs, in
31    /// words the People page shows as is (`dissolve 2 more wrong clusters`).
32    pub feedback_needed: Option<String>,
33    pub pending_questions: usize,
34}
35
36/// The stored outcome of one background training run.
37#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
38pub struct TrainedProfileSummary {
39    pub profile_id: i64,
40    pub model_kind: String,
41    pub promoted: bool,
42}
43
44/// Result of answering one identity question: the new delivery state and, for
45/// Yes and No, the durable learning work the answer committed.
46#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
47pub struct QuestionAnswerOutcome {
48    pub status: String,
49    pub acknowledgement: Option<LearningAcknowledgement>,
50}
51
52/// One labeled person: their confirmed faces plus a representative face id
53/// (the primary, or lowest id) used as the card thumbnail.
54#[derive(Serialize, Clone)]
55pub struct PersonData {
56    /// Identity: normalized, what URLs and actions use.
57    pub label: String,
58    /// What a reader sees. Falls back to `label` for a person whose row
59    /// predates the people table.
60    pub full_name: String,
61    pub face_ids: Vec<i64>,
62    pub representative_id: i64,
63    pub hashes: Vec<String>,
64}
65
66/// One unassigned cluster (green section in the labeling UI).
67#[derive(Serialize, Clone)]
68pub struct ClusterData {
69    pub cluster_id: i64,
70    pub face_ids: Vec<i64>,
71    pub hashes: Vec<String>,
72}
73
74/// One unclustered, unassigned face (orange section).
75#[derive(Serialize, Clone)]
76pub struct SingletonData {
77    pub face_id: i64,
78    pub hash: String,
79}
80
81/// Top-level payload for the labeling page.
82///
83/// `Default` is the "detection has never run" answer, which is a state rather
84/// than an error. See `faces_list`.
85#[derive(Serialize, Clone, Default)]
86pub struct FacesData {
87    pub people: Vec<PersonData>,
88    pub clusters: Vec<ClusterData>,
89    pub singletons: Vec<SingletonData>,
90}
91
92/// One face row on a cluster detail page.
93#[derive(Serialize, Clone)]
94pub struct ClusterFaceData {
95    pub face_id: i64,
96    pub hash: String,
97    pub path: String,
98}
99
100/// Cluster detail: every face in one unassigned cluster.
101#[derive(Serialize, Clone)]
102pub struct ClusterDetail {
103    pub cluster_id: i64,
104    pub faces: Vec<ClusterFaceData>,
105}
106
107/// One face row on a person detail page. `is_primary` marks the current
108/// default photo (the person's thumbnail on the labeling page).
109#[derive(Serialize, Clone)]
110pub struct PersonFaceData {
111    pub face_id: i64,
112    pub hash: String,
113    pub path: String,
114    pub is_primary: bool,
115}
116
117/// Person detail: every confirmed face for one person.
118#[derive(Serialize, Clone)]
119pub struct PersonDetail {
120    /// Identity: what the URL and every face row use.
121    pub label: String,
122    /// What a reader sees, and what the page lets them edit.
123    pub full_name: String,
124    pub faces: Vec<PersonFaceData>,
125}