1macro_rules! string_id {
8 (
9 $(#[$meta:meta])*
10 $name:ident { $( $ctor:ident => $value:literal ),* $(,)? }
11 ) => {
12 $(#[$meta])*
13 #[derive(
14 Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
15 serde::Serialize, serde::Deserialize,
16 )]
17 #[serde(transparent)]
18 pub struct $name(String);
19
20 impl $name {
21 $(
22 #[doc = concat!("The well-known `", $value, "` value.")]
23 pub fn $ctor() -> Self {
24 Self(String::from($value))
25 }
26 )*
27
28 pub fn as_str(&self) -> &str {
30 &self.0
31 }
32 }
33
34 impl AsRef<str> for $name {
35 fn as_ref(&self) -> &str {
36 &self.0
37 }
38 }
39
40 impl From<&str> for $name {
41 fn from(value: &str) -> Self {
42 Self(value.to_owned())
43 }
44 }
45
46 impl From<String> for $name {
47 fn from(value: String) -> Self {
48 Self(value)
49 }
50 }
51
52 impl From<$name> for String {
53 fn from(value: $name) -> Self {
54 value.0
55 }
56 }
57
58 impl std::fmt::Display for $name {
59 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60 formatter.write_str(&self.0)
61 }
62 }
63 };
64}
65
66string_id! {
67 Modality {
69 unknown => "unknown",
70 text => "text",
71 image => "image",
72 speech => "speech",
73 audio => "audio",
74 video => "video",
75 vision => "vision",
76 embedding => "embedding",
77 }
78}
79
80string_id! {
81 Capability {
83 chat => "chat",
84 complete => "complete",
85 embed => "embed",
86 see => "see",
87 image => "image",
88 speak => "speak",
89 transcribe => "transcribe",
90 tools => "tools",
91 }
92}
93
94string_id! {
95 SourceKind {
97 ollama => "ollama",
98 huggingface_cache => "huggingface-cache",
99 lm_studio => "lm-studio",
100 builtin => "builtin",
101 endpoint => "endpoint",
102 file => "file",
103 folder => "folder",
104 }
105}
106
107string_id! {
108 RuntimeId {
110 llama_cpp => "llama-cpp",
111 whisper_cpp => "whisper-cpp",
112 ollama => "ollama",
113 mlx_swift => "mlx-swift",
114 apple_foundation => "apple-foundation",
115 openai_endpoint => "generic:openai-server",
116 mflux => "python:mflux",
117 diffusers => "python:diffusers",
118 mlx_lm => "python:mlx-lm",
119 mlx_audio => "python:mlx-audio",
120 mlx_vlm => "python:mlx-vlm",
121 embeddings => "python:embeddings",
122 comfy_ui => "comfyui",
123 a1111 => "a1111",
124 }
125}
126
127#[derive(
129 Debug, Clone, Copy, PartialEq, Eq, Hash, Default, serde::Serialize, serde::Deserialize,
130)]
131#[serde(rename_all = "lowercase")]
132pub enum ExecutionMode {
133 Stream,
135 Job,
137 #[default]
139 Sync,
140}
141
142#[derive(
144 Debug, Clone, Copy, PartialEq, Eq, Hash, Default, serde::Serialize, serde::Deserialize,
145)]
146#[serde(rename_all = "kebab-case")]
147pub enum RunTier {
148 Native,
150 Managed,
152 Remote,
154 #[default]
156 RecipeNeeded,
157}
158
159#[derive(
161 Debug, Clone, Copy, PartialEq, Eq, Hash, Default, serde::Serialize, serde::Deserialize,
162)]
163#[serde(rename_all = "lowercase")]
164pub enum ModelState {
165 Ready,
167 #[default]
169 Unresolved,
170 Missing,
172}
173
174pub struct BidPreference;
177
178impl BidPreference {
179 pub const LLAMA_CPP: i64 = 10;
181 pub const WHISPER_CPP: i64 = 10;
183 pub const ENDPOINT: i64 = 10;
185 pub const MLX_VLM: i64 = 14;
187 pub const MLX_SWIFT: i64 = 15;
189 pub const APPLE_FOUNDATION: i64 = 15;
191 pub const OLLAMA: i64 = 20;
193 pub const MFLUX: i64 = 25;
195 pub const DIFFUSERS: i64 = 26;
197 pub const COMFY_UI: i64 = 27;
199 pub const A1111: i64 = 28;
201 pub const MLX_AUDIO: i64 = 30;
203 pub const EMBEDDINGS: i64 = 32;
205 pub const MLX_LM: i64 = 40;
207 pub const MANIFEST: i64 = 100;
209}