Skip to main content

rs_plugin_common_interfaces/domain/
embedding.rs

1use serde::{Deserialize, Serialize};
2
3/// Where a background embedding pass over one library stands.
4#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
5#[serde(rename_all = "camelCase")]
6pub enum EmbeddingPassState {
7    /// Sent before the model is loaded and, the first time, downloaded.
8    Started,
9    /// Sent after each media.
10    Running,
11    Completed,
12    /// Left because the library was paused; resuming starts a new pass.
13    Paused,
14    /// Left because embeddings were turned off for the library, or it was removed.
15    Stopped,
16    /// Left early after too many failures in a row; a later pass carries on.
17    Interrupted,
18    /// Could not run, for example because the model cannot be loaded.
19    Failed,
20}
21
22/// Payload of the `embedding_progress` event. A pass sends `started` once, `running`
23/// after each media, then exactly one of `completed`, `paused`, `stopped`,
24/// `interrupted` or `failed`.
25#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
26#[serde(rename_all = "camelCase")]
27pub struct EmbeddingProgressMessage {
28    pub library: String,
29    pub state: EmbeddingPassState,
30    pub embedder: String,
31    /// Medias tried so far in this pass.
32    pub processed: u64,
33    /// Of which embedded; the others failed.
34    pub embedded: u64,
35    /// Medias this pass covers: those pending when it started, kept in step with
36    /// uploads and deletions since. Never below `processed`.
37    pub total: u64,
38}