Skip to main content

entrenar/ecosystem/realizar/
metadata.rs

1//! GGUF metadata types.
2
3use super::provenance::ExperimentProvenance;
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7/// GGUF metadata container.
8#[derive(Debug, Clone, Default, Serialize, Deserialize)]
9pub struct GgufMetadata {
10    /// General model information
11    pub general: GeneralMetadata,
12    /// Experiment provenance (optional)
13    pub provenance: Option<ExperimentProvenance>,
14    /// Custom key-value pairs
15    pub custom: HashMap<String, String>,
16}
17
18/// General model metadata.
19#[derive(Debug, Clone, Default, Serialize, Deserialize)]
20pub struct GeneralMetadata {
21    /// Model architecture (e.g., "llama", "mistral", "qwen")
22    pub architecture: String,
23    /// Model name
24    pub name: String,
25    /// Author or organization
26    pub author: Option<String>,
27    /// Model description
28    pub description: Option<String>,
29    /// License identifier
30    pub license: Option<String>,
31    /// URL for more information
32    pub url: Option<String>,
33    /// File type (quantization level)
34    pub file_type: Option<String>,
35}
36
37impl GeneralMetadata {
38    /// Create new general metadata.
39    pub fn new(architecture: impl Into<String>, name: impl Into<String>) -> Self {
40        Self {
41            architecture: architecture.into(),
42            name: name.into(),
43            author: None,
44            description: None,
45            license: None,
46            url: None,
47            file_type: None,
48        }
49    }
50
51    /// Set author.
52    pub fn with_author(mut self, author: impl Into<String>) -> Self {
53        self.author = Some(author.into());
54        self
55    }
56
57    /// Set description.
58    pub fn with_description(mut self, desc: impl Into<String>) -> Self {
59        self.description = Some(desc.into());
60        self
61    }
62
63    /// Set license.
64    pub fn with_license(mut self, license: impl Into<String>) -> Self {
65        self.license = Some(license.into());
66        self
67    }
68}