replicate / replicate-swift

Swift client for Replicate
https://replicate.com
Apache License 2.0
157 stars 33 forks source link

Convert codable keys to snake case in Client fetch #43

Closed daneden closed 1 year ago

daneden commented 1 year ago

The Replicate HTTP API expects snake_case properties for JSON keys (e.g. input.system_prompt), which is uncommon in Swift. This change tells the JSON encoder to convert properties to snake_case during encoding for POSTing to the HTTP API.

mattt commented 1 year ago

Hi, @daneden. Thanks for your contribution. My personal preference is to not rely on the behavior of Swift's built-in snake case transformer, and instead specify coding keys manually. That's what we're doing now for all of the attributes we wish to support, so nothing else needs to be done at the moment.

daneden commented 1 year ago

@mattt gotcha, thanks for the feedback! I hadn’t considered adding coding keys to my Predictable.Input but that makes total sense.