@@ -19,6 +19,7 @@ class MLXService {
1919 /// Includes both language models (LLM) and vision-language models (VLM).
2020 static let availableModels : [ LMModel ] = [
2121 LMModel ( name: " llama3.2:1b " , configuration: LLMRegistry . llama3_2_1B_4bit, type: . llm) ,
22+ LMModel ( name: " llama3.2:3b " , configuration: LLMRegistry . llama3_2_3B_4bit, type: . llm) ,
2223 LMModel ( name: " qwen2.5:1.5b " , configuration: LLMRegistry . qwen2_5_1_5b, type: . llm) ,
2324 LMModel ( name: " smolLM:135m " , configuration: LLMRegistry . smolLM_135M_4bit, type: . llm) ,
2425 LMModel ( name: " qwen3:0.6b " , configuration: LLMRegistry . qwen3_0_6b_4bit, type: . llm) ,
@@ -72,13 +73,13 @@ class MLXService {
7273 self . modelDownloadProgress = progress
7374 }
7475 }
75-
76+
7677 // Clear out the promptCache
7778 promptCache. removeObject ( forKey: model. name as NSString )
78-
79+
7980 // Cache the loaded model for future use
8081 modelCache. setObject ( container, forKey: model. name as NSString )
81-
82+
8283 return container
8384 }
8485 }
@@ -127,15 +128,20 @@ class MLXService {
127128 // Get the prompt cache and adjust new prompt to remove
128129 // prefix already in cache, trim cache if cache is
129130 // inconsistent with new prompt.
130- let ( cache, lmInput) = getPromptCache ( fullPrompt: fullPrompt, parameters: parameters, context: context, modelName: model. name)
131-
131+ let ( cache, lmInput) = getPromptCache (
132+ fullPrompt: fullPrompt, parameters: parameters, context: context,
133+ modelName: model. name)
134+
132135 // TODO: The generated tokens should be added to the prompt cache but not possible with AsyncStream
133136 return try MLXLMCommon . generate (
134137 input: lmInput, parameters: parameters, context: context, cache: cache. cache)
135138 }
136139 }
137-
138- func getPromptCache( fullPrompt: LMInput , parameters: GenerateParameters , context: ModelContext , modelName: String ) -> ( PromptCache , LMInput ) {
140+
141+ func getPromptCache(
142+ fullPrompt: LMInput , parameters: GenerateParameters , context: ModelContext ,
143+ modelName: String
144+ ) -> ( PromptCache , LMInput ) {
139145 let cache : PromptCache
140146 if let existingCache = promptCache. object ( forKey: modelName as NSString ) {
141147 cache = existingCache
@@ -146,7 +152,7 @@ class MLXService {
146152 }
147153
148154 let lmInput : LMInput
149-
155+
150156 /// Remove prefix from prompt that is already in cache
151157 if let suffix = cache. getUncachedSuffix ( prompt: fullPrompt. text. tokens) {
152158 lmInput = LMInput ( text: LMInput . Text ( tokens: suffix) )
@@ -157,7 +163,7 @@ class MLXService {
157163 self . promptCache. setObject ( newCache, forKey: modelName as NSString )
158164 lmInput = fullPrompt
159165 }
160-
166+
161167 return ( cache, lmInput)
162168 }
163169}
0 commit comments