Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-adapters/blob/main/src/models.rs # spark-adapters Hardware abstraction adapters for local AI accelerators Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `spark-adapters / src / models.rs` 174 lines ยท 5709 bytes Raw Blame History 1 use serde::{Deserialize, Serialize}; 2 3 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] 4 #[serde(rename_all = "snake_case")] 5 pub enum ProviderType { 6 OpenAI, 7 Anthropic, 8 OpenRouter, 9 Gemini, 10 Groq, 11 Ollama, 12 DeepSeek, 13 Together, 14 Mistral, 15 LocalMax, 16 } 17 18 impl ProviderType { 19 pub fn slug(&self) -> &'static str { 20 match self { 21 ProviderType::OpenAI => "openai", 22 ProviderType::Anthropic => "anthropic", 23 ProviderType::OpenRouter => "openrouter", 24 ProviderType::Gemini => "gemini", 25 ProviderType::Groq => "groq", 26 ProviderType::Ollama => "ollama", 27 ProviderType::DeepSeek => "deepseek", 28 ProviderType::Together => "together", 29 ProviderType::Mistral => "mistral", 30 ProviderType::LocalMax => "local_max", 31 } 32 } 33 34 pub fn display_name(&self) -> &'static str { 35 match self { 36 ProviderType::OpenAI => "OpenAI", 37 ProviderType::Anthropic => "Anthropic", 38 ProviderType::OpenRouter => "OpenRouter (Multi-Model Gateway)", 39 ProviderType::Gemini => "Google Gemini", 40 ProviderType::Groq => "Groq LPU Engine", 41 ProviderType::Ollama => "Ollama Local Engine", 42 ProviderType::DeepSeek => "DeepSeek Cloud", 43 ProviderType::Together => "Together AI", 44 ProviderType::Mistral => "Mistral AI", 45 ProviderType::LocalMax => "Modular MAX (GB10 Native)", 46 } 47 } 48 49 pub fn default_endpoint(&self) -> &'static str { 50 match self { 51 ProviderType::OpenAI => "https://api.openai.com/v1/chat/completions", 52 ProviderType::Anthropic => "https://api.anthropic.com/v1/messages", 53 ProviderType::OpenRouter => "https://openrouter.ai/api/v1/chat/completions", 54 ProviderType::Gemini => "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions", 55 ProviderType::Groq => "https://api.groq.com/openai/v1/chat/completions", 56 ProviderType::Ollama => "http://127.0.0.1:11434/v1/chat/completions", 57 ProviderType::DeepSeek => "https://api.deepseek.com/v1/chat/completions", 58 ProviderType::Together => "https://api.together.xyz/v1/chat/completions", 59 ProviderType::Mistral => "https://api.mistral.ai/v1/chat/completions", 60 ProviderType::LocalMax => "http://127.0.0.1:18006/v1/chat/completions", 61 } 62 } 63 64 pub fn key_name(&self) -> Option<&'static str> { 65 match self { 66 ProviderType::OpenAI => Some("OPENAI_API_KEY"), 67 ProviderType::Anthropic => Some("ANTHROPIC_API_KEY"), 68 ProviderType::OpenRouter => Some("OPENROUTER_API_KEY"), 69 ProviderType::Gemini => Some("GEMINI_API_KEY"), 70 ProviderType::Groq => Some("GROQ_API_KEY"), 71 ProviderType::Ollama => None, 72 ProviderType::DeepSeek => Some("DEEPSEEK_API_KEY"), 73 ProviderType::Together => Some("TOGETHER_API_KEY"), 74 ProviderType::Mistral => Some("MISTRAL_API_KEY"), 75 ProviderType::LocalMax => None, 76 } 77 } 78 } 79 80 #[derive(Debug, Clone, Serialize, Deserialize)] 81 pub struct AdapterSpec { 82 pub id: String, 83 pub name: String, 84 pub provider: ProviderType, 85 pub endpoint: String, 86 pub model_id: String, 87 pub context_length: usize, 88 pub is_available: bool, 89 pub requires_key: bool, 90 pub is_resident: bool, 91 } 92 93 #[derive(Debug, Clone, Serialize, Deserialize)] 94 pub struct ChatMessage { 95 pub role: String, 96 pub content: String, 97 #[serde(skip_serializing_if = "Option::is_none")] 98 pub reasoning: Option, 99 } 100 101 #[derive(Debug, Clone, Serialize, Deserialize)] 102 pub struct NormalizedChunk { 103 pub content: String, 104 pub reasoning: String, 105 pub is_done: bool, 106 } 107 108 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] 109 #[serde(rename_all = "snake_case")] 110 pub enum TaskType { 111 CodeSynthesis, 112 SystemArchitecture, 113 ReasoningTrace, 114 RefactorLogic, 115 VerificationHarness, 116 } 117 118 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] 119 #[serde(rename_all = "snake_case")] 120 pub enum VerificationStrategy { 121 CompilerCheck, 122 JsonSchema, 123 UnslopStrict, 124 DualConsensus, 125 } 126 127 #[derive(Debug, Clone, Serialize, Deserialize)] 128 pub struct VerificationOutcome { 129 pub passed: bool, 130 pub score: f32, 131 pub rule_violations: Vec, 132 pub compiler_output: Option, 133 } 134 135 #[derive(Debug, Clone, Serialize, Deserialize)] 136 pub struct Rollout { 137 pub provider: ProviderType, 138 pub model_id: String, 139 pub content: String, 140 pub reasoning: Option, 141 pub duration_ms: u64, 142 pub token_count: usize, 143 pub verification: VerificationOutcome, 144 } 145 146 #[derive(Debug, Clone, Serialize, Deserialize)] 147 pub struct DistillTask { 148 pub id: String, 149 pub task_type: TaskType, 150 pub prompt: String, 151 pub system_prompt: Option, 152 pub teacher_model: String, 153 pub student_model: Option, 154 pub verification_strategy: VerificationStrategy, 155 pub commit_to_cortex: bool, 156 } 157 158 #[derive(Debug, Clone, Serialize, Deserialize)] 159 pub struct DistillationRecord { 160 pub task_id: String, 161 pub task_type: TaskType, 162 pub prompt: String, 163 pub system_prompt: Option, 164 pub teacher_rollout: Rollout, 165 pub student_rollout: Option, 166 pub chosen: String, 167 pub chosen_reasoning: Option, 168 pub rejected: Option, 169 pub rejected_reasoning: Option, 170 pub preference_delta: f32, 171 pub durable_memory_committed: bool, 172 pub cortex_entity_id: Option, 173 pub created_at: String, 174 }