-
-
Notifications
You must be signed in to change notification settings - Fork 347
feat(ai-providers): add llama.cpp and MLX as local providers #1938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
TableProTests/Core/AI/LocalProviderRegistrationTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // | ||
| // LocalProviderRegistrationTests.swift | ||
| // TableProTests | ||
| // | ||
|
|
||
| import Foundation | ||
| @testable import TablePro | ||
| import Testing | ||
|
|
||
| @Suite("Local OpenAI-compatible provider registration") | ||
| struct LocalProviderRegistrationTests { | ||
| init() { | ||
| AIProviderRegistration.registerAll() | ||
| } | ||
|
|
||
| private func descriptor(for type: AIProviderType) -> AIProviderDescriptor? { | ||
| AIProviderRegistry.shared.descriptor(for: type.rawValue) | ||
| } | ||
|
|
||
| @Test("llama.cpp is a known local provider with no auth and the default llama-server endpoint") | ||
| func llamaCppType() { | ||
| #expect(AIProviderType.llamaCpp.authStyle == .none) | ||
| #expect(AIProviderType.allCases.contains(.llamaCpp)) | ||
| #expect(AIProviderType(rawValue: "llamaCpp") == .llamaCpp) | ||
| #expect(AIProviderType.llamaCpp.displayName == "llama.cpp") | ||
| #expect(AIProviderType.llamaCpp.defaultEndpoint == "http://localhost:8080") | ||
| } | ||
|
|
||
| @Test("MLX is a known local provider with no auth and the default mlx_lm.server endpoint") | ||
| func mlxType() { | ||
| #expect(AIProviderType.mlx.authStyle == .none) | ||
| #expect(AIProviderType.allCases.contains(.mlx)) | ||
| #expect(AIProviderType(rawValue: "mlx") == .mlx) | ||
| #expect(AIProviderType.mlx.displayName == "MLX") | ||
| #expect(AIProviderType.mlx.defaultEndpoint == "http://localhost:8080") | ||
| } | ||
|
|
||
| @Test("Local providers register OpenAI-compatible descriptors that fetch models and take an endpoint") | ||
| func descriptorCapabilities() { | ||
| for type in [AIProviderType.llamaCpp, .mlx] { | ||
| let provider = descriptor(for: type) | ||
| #expect(provider != nil) | ||
| #expect(provider?.allowsEndpointConfiguration == true) | ||
| #expect(provider?.allowsMaxOutputTokens == true) | ||
| #expect(provider?.fetchesModelList == true) | ||
| #expect(provider?.allowsNameConfiguration == false) | ||
| #expect(provider?.supportsReasoning == false) | ||
| #expect(provider?.supportsImages == false) | ||
| } | ||
| } | ||
|
|
||
| @Test("Local providers build the OpenAI-compatible transport, not a bespoke one") | ||
| func makeProviderUsesOpenAICompatible() { | ||
| for type in [AIProviderType.llamaCpp, .mlx] { | ||
| let config = AIProviderConfig(type: type, model: "local-model") | ||
| #expect(descriptor(for: type)?.makeProvider(config, nil) is OpenAICompatibleProvider) | ||
| } | ||
| } | ||
|
|
||
| @Test("The default local endpoint resolves to the OpenAI chat-completions path") | ||
| func defaultEndpointResolvesToOpenAIPath() { | ||
| for type in [AIProviderType.llamaCpp, .mlx] { | ||
| let config = AIProviderConfig(type: type) | ||
| #expect(config.endpoint == "http://localhost:8080") | ||
| #expect(config.endpoint.openAIPath("chat/completions") == "http://localhost:8080/v1/chat/completions") | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user adds either new preset, this
.noneauth style makesAIProviderDetailSheet.authSectionrenderEmptyView; the only existingTest Connectioncontrols are inside the API-key/Cursor/xAI auth sections. Thus llama.cpp and MLX have no way to run the connection test that the new provider instructions explicitly tell users to perform, even after choosing a model. Add an unauthenticated test control (for example in the connection section) or remove that workflow from the provider documentation.Useful? React with 👍 / 👎.