Skip to content

Conversation

@XMLHexagram
Copy link
Contributor

fix #70

@mattt
Copy link
Owner

mattt commented Dec 22, 2025

Hi @XMLHexagram. Thank you for opening this PR. I'm sorry for the inconvenience caused by the current code not working. I just merged #67, which I believe makes an equivalent change. Is there anything in here that we'd be missing? (I see there are some changes around how parameters are encoded; are those required?)

@XMLHexagram
Copy link
Contributor Author

XMLHexagram commented Dec 22, 2025

@mattt, Yes, I believe these code are indeed important.

Cause #67 only fix part of the error. After 0.5.2 published, run swift build --traits MLX can still get an error which caused by swift 6 concurrency check.

❯ swift build --traits MLX
[1/1] Planning build
Building for debugging...
/Users/hexagram/Projects/AnyLanguageModel/Sources/AnyLanguageModel/Models/MLXLanguageModel.swift:377:25: error: type 'Any' does not conform to the 'Sendable' protocol
375 |         return [
376 |             "type": "function",
377 |             "function": [
    |                         `- error: type 'Any' does not conform to the 'Sendable' protocol
378 |                 "name": tool.name,
379 |                 "description": tool.description,
[5/5] Compiling AnyLanguageModel MLXLanguageModel.swift

As a result, 0.5.2 is still broken if developer enable MLX trait.

And this PR fully fix all the errors and I have already completely tested it in my own project.

BTW, next time before merging PR or release new version, please make sure it is worked properly.

@XMLHexagram
Copy link
Contributor Author

And I also fix the error in CoreML trait in this PR.

/Users/hexagram/Projects/AnyLanguageModel/Sources/AnyLanguageModel/Models/CoreMLLanguageModel.swift:219:45: error: value of type 'Instructions' has no member 'segments'
217 |             // Check for image segments in instructions
218 |             if let instructions = session.instructions {
219 |                 for segment in instructions.segments {
    |                                             `- error: value of type 'Instructions' has no member 'segments'
220 |                     if case .image = segment {
221 |                         throw CoreMLLanguageModelError.unsupportedFeature
/Users/hexagram/Projects/AnyLanguageModel/Sources/AnyLanguageModel/Models/CoreMLLanguageModel.swift:219:45: error: value of type 'Instructions' has no member 'segments'
217 |             // Check for image segments in instructions
218 |             if let instructions = session.instructions {
219 |                 for segment in instructions.segments {
    |                                             `- error: value of type 'Instructions' has no member 'segments'
220 |                     if case .image = segment {
221 |                         throw CoreMLLanguageModelError.unsupportedFeature
[75/75] Compiling AnyLanguageModel GenerationID.swift

@noorbhatia
Copy link
Contributor

@mattt, Yes, I believe these code are indeed important.

Cause #67 only fix part of the error. After 0.5.2 published, run swift build --traits MLX can still get an error which caused by swift 6 concurrency check.

❯ swift build --traits MLX
[1/1] Planning build
Building for debugging...
/Users/hexagram/Projects/AnyLanguageModel/Sources/AnyLanguageModel/Models/MLXLanguageModel.swift:377:25: error: type 'Any' does not conform to the 'Sendable' protocol
375 |         return [
376 |             "type": "function",
377 |             "function": [
    |                         `- error: type 'Any' does not conform to the 'Sendable' protocol
378 |                 "name": tool.name,
379 |                 "description": tool.description,
[5/5] Compiling AnyLanguageModel MLXLanguageModel.swift

As a result, 0.5.2 is still broken if developer enable MLX trait.

And this PR fully fix all the errors and I have already completely tested it in my own project.

BTW, next time before merging PR or release new version, please make sure it is worked properly.

Screenshot 2025-12-23 at 4 18 31 PM

Pretty sure it compiled before I raised PR. Also tested in my project.

@XMLHexagram
Copy link
Contributor Author

@mattt, Yes, I believe these code are indeed important.
Cause #67 only fix part of the error. After 0.5.2 published, run swift build --traits MLX can still get an error which caused by swift 6 concurrency check.

❯ swift build --traits MLX
[1/1] Planning build
Building for debugging...
/Users/hexagram/Projects/AnyLanguageModel/Sources/AnyLanguageModel/Models/MLXLanguageModel.swift:377:25: error: type 'Any' does not conform to the 'Sendable' protocol
375 |         return [
376 |             "type": "function",
377 |             "function": [
    |                         `- error: type 'Any' does not conform to the 'Sendable' protocol
378 |                 "name": tool.name,
379 |                 "description": tool.description,
[5/5] Compiling AnyLanguageModel MLXLanguageModel.swift

As a result, 0.5.2 is still broken if developer enable MLX trait.
And this PR fully fix all the errors and I have already completely tested it in my own project.
BTW, next time before merging PR or release new version, please make sure it is worked properly.

Screenshot 2025-12-23 at 4 18 31 PM Pretty sure it compiled before I raised PR. Also tested in my project.

May I ask your swift version? via swift --version

Mine is

❯ swift --version                                   
swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0

@noorbhatia
Copy link
Contributor

@XMLHexagram

~ swift --version
swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx26.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MLXLanguageModel - Cannot find several methods in scope

3 participants