Skip to content

Commit e90669b

Browse files
committed
Fix compiler errors due to JSONValue ambiguity
1 parent 0646e79 commit e90669b

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Sources/AnyLanguageModel/Models/MLXLanguageModel.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ import Foundation
281281
}
282282

283283
/// Additional key-value pairs injected into the chat template rendering context.
284-
public var additionalContext: [String: JSONValue]?
284+
public var additionalContext: [String: MLXLMCommon.JSONValue]?
285285

286286
var additionalContextForUserInput: [String: any Sendable]? {
287287
additionalContext?.mapValues { $0.toSendable() }
@@ -298,7 +298,7 @@ import Foundation
298298
public init(
299299
kvCache: KVCache,
300300
userInputProcessing: UserInputProcessing?,
301-
additionalContext: [String: JSONValue]?
301+
additionalContext: [String: MLXLMCommon.JSONValue]?
302302
) {
303303
self.kvCache = kvCache
304304
self.additionalContext = additionalContext
@@ -1591,7 +1591,7 @@ import Foundation
15911591
{
15921592
header += ". Expected value: \(constString)"
15931593
} else if let enumValues = jsonSchema.enum, !enumValues.isEmpty,
1594-
let data = try? encoder.encode(JSONValue.array(enumValues)),
1594+
let data = try? encoder.encode(enumValues),
15951595
let enumString = String(data: data, encoding: .utf8)
15961596
{
15971597
header += ". Allowed values: \(enumString)"
@@ -1637,11 +1637,11 @@ import Foundation
16371637
options[custom: MLXLanguageModel.self]?.processingForUserInput
16381638
?? .init(resize: nil)
16391639

1640-
let userInput = makeUserInput(
1640+
let userInput = MLXLMCommon.UserInput(
16411641
chat: chat,
1642-
tools: nil,
16431642
processing: userInputProcessing,
1644-
additionalContext: additionalContext
1643+
tools: nil,
1644+
additionalContext: additionalContext,
16451645
)
16461646
let lmInput = try await context.processor.prepare(input: userInput)
16471647

@@ -1882,7 +1882,7 @@ import Foundation
18821882
return sampledToken.item(Int.self)
18831883
}
18841884
}
1885-
extension JSONValue {
1885+
extension MLXLMCommon.JSONValue {
18861886
/// Recursively converts a `JSONValue` to its primitive Swift equivalent.
18871887
func toSendable() -> any Sendable {
18881888
switch self {

Tests/AnyLanguageModelTests/MLXLanguageModelTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ import Testing
264264
)
265265
var custom = MLXLanguageModel.CustomGenerationOptions.default
266266
custom.additionalContext = [
267-
"user_name": .string("Alice"),
268-
"turn_count": .int(3),
269-
"verbose": .bool(true),
267+
"user_name": MLXLMCommon.JSONValue.string("Alice"),
268+
"turn_count": MLXLMCommon.JSONValue.int(3),
269+
"verbose": MLXLMCommon.JSONValue.bool(true),
270270
]
271271
options[custom: MLXLanguageModel.self] = custom
272272

0 commit comments

Comments
 (0)