Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apple/TablePro/Models/AI/AIProviderPreset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ struct AIProviderPreset: Identifiable, Equatable, Sendable {
rejectsBadKeyWithForbidden: true
)

static let all: [AIProviderPreset] = [.requesty]
static let runcrate = AIProviderPreset(
id: "runcrate",
displayName: "Runcrate",
endpoint: "https://api.runcrate.ai/v1",
symbolName: "cloud",
authStyle: .apiKey,
rejectsBadKeyWithForbidden: false
)

static let all: [AIProviderPreset] = [.requesty, .runcrate]

static func preset(withID id: String?) -> AIProviderPreset? {
guard let id else { return nil }
Expand Down
22 changes: 22 additions & 0 deletions apple/TableProTests/Core/AI/AIProviderPresetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ struct AIProviderPresetTests {
)
}

@Test("Runcrate needs a key, and its default Base URL resolves to its chat completions and models routes")
func runcratePreset() throws {
let preset = AIProviderPreset.runcrate
#expect(preset.authStyle == .apiKey)
#expect(!preset.rejectsBadKeyWithForbidden)

let config = AIProviderConfig(preset: preset)
#expect(config.type == .custom)
#expect(config.presetID == "runcrate")
#expect(config.name == "Runcrate")
let style = config.type.endpointStyle
#expect(style == .chatCompletions)
#expect(
AIEndpoint(config.endpoint, style: style)?.chatURL(model: "deepseek-ai/DeepSeek-V4.1-Flash", style: style)?.absoluteString
== "https://api.runcrate.ai/v1/chat/completions"
)
#expect(
AIEndpoint(config.endpoint, style: style)?.url(appending: style.modelsResource)?.absoluteString
== "https://api.runcrate.ai/v1/models"
)
}

@Test("Every preset has a unique id and an https endpoint the transport can resolve")
func presetsAreWellFormed() {
#expect(Set(AIProviderPreset.all.map(\.id)).count == AIProviderPreset.all.count)
Expand Down