Skip to content

Commit 71a77e0

Browse files
author
Aegis-AI
committed
apply copilot review suggestions for PR #28
1 parent 4f54bcc commit 71a77e0

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

Libraries/MLXLLM/LLMModelFactory.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ public final class LLMModelFactory: ModelFactory {
574574

575575
// Build a ModelConfiguration with loaded EOS token IDs and tool call format
576576
var mutableConfiguration = configuration
577-
mutableConfiguration.eosTokenIds = eosTokenIds.union(configuration.eosTokenIds)
577+
eosTokenIds.formUnion(configuration.eosTokenIds)
578+
mutableConfiguration.eosTokenIds = eosTokenIds
578579
if mutableConfiguration.toolCallFormat == nil {
579580
mutableConfiguration.toolCallFormat = ToolCallFormat.infer(
580581
from: baseConfig.modelType, configData: configData)

Libraries/MLXLMCommon/ModelConfiguration.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ public struct ModelConfiguration: Sendable {
101101
/// Additional tokens to use for end of string (specified as strings, converted to IDs at runtime)
102102
public var extraEOSTokens: Set<String>
103103

104-
/// EOS token IDs loaded from config.json/generation_config.json
104+
/// EOS token IDs used during generation.
105+
///
106+
/// At load time this set is populated by merging:
107+
/// - IDs from the model's `config.json` / `generation_config.json` (loaded at runtime)
108+
/// - Any additional IDs provided by the registry / caller at registration time
109+
/// (e.g. `eosTokenIds: [0]` in ``LLMRegistry`` for Gemma-4 pad-token workaround)
105110
public var eosTokenIds: Set<Int> = []
106111

107112
/// Tool call format for this model (nil = default JSON format)

Libraries/MLXVLM/VLMModelFactory.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ public final class VLMModelFactory: ModelFactory {
361361
}
362362

363363
var mutableConfiguration = configuration
364-
mutableConfiguration.eosTokenIds = eosTokenIds.union(configuration.eosTokenIds)
364+
eosTokenIds.formUnion(configuration.eosTokenIds)
365+
mutableConfiguration.eosTokenIds = eosTokenIds
365366

366367
// Auto-detect tool call format from model type if not explicitly set
367368
if mutableConfiguration.toolCallFormat == nil {

0 commit comments

Comments
 (0)