Skip to content
System One

ainame/swift-typesafe

Unofficial Swift 6.4 SDK for TypeSafe that follows the Python SDK's 0.6.0 API, with macro-based question sets for Choice, Noul and Score. Supports macOS 26+, iOS 26+, tvOS, watchOS, visionOS and Linux, and tracks the upstream version it mirrors.

ainame/swift-typesafe on GitHub

Stars
15
Forks
1
Language
Swift
License
MIT
Last push
23 Sep 2026

Read from GitHub on . Counts change daily.

How it uses Jev

public func systemOne(
    state: JSONValue, questions: [String: Question], model: String? = nil,
    extraBody: [String: JSONValue] = [:], options: RequestOptions = RequestOptions()
) async throws -> SystemOneResponse {
    guard state.isContent else { throw TypeSafeError.configuration("state must be text, an object, or an array.") }
    guard !questions.isEmpty else { throw TypeSafeError.configuration("At least one question is required.") }
    for (name, question) in questions { try question.validate(name: name) }
    var body: [String: JSONValue] = [
        "state": state, "model": .string(model ?? self.model),
        "questions": .object(questions.mapValues { .object($0.payload) }),
    ]
    body.merge(extraBody, uniquingKeysWith: { _, last in last })
    let data: Data
    do { data = try JSONEncoder().encode(body) }
    catch { throw TypeSafeError.encoding("The request body could not be encoded as JSON.") }

View in Sources/TypeSafe/TypeSafeClient.swift

Open on GitHub

PrimitivesChoiceScoreNoul

More like this

Keep browsing