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.") }
