jamesrochabrun / SwiftAnthropic

An open-source Swift package for interacting with Anthropic's public API.
90 stars 29 forks source link

Make MessageResponse and DynamicContent Encodable #12

Closed bcherry closed 5 months ago

bcherry commented 5 months ago

eWe've been using this library in a new app but haven't been able to work with DynamicContent directly in a way that works for us. What did work is taking DynamicContent and turning it back into raw JSON data, then parsing it back into a more specific type.

This PR started by simply implementing the Encodable protocol for DynamicContent so this is possible.

We also found that we wanted access to the raw response from Anthropic in string or JSON format for error logging purposes, so making all of MessageResponse encodable enabled that as well.

bcherry commented 5 months ago

@jamesrochabrun it looks like this change was mostly or partly lost in a bad merge https://github.com/jamesrochabrun/SwiftAnthropic/pull/13/commits/3d09ca38f83deaf4d03aa66d4434dfe74161d637 (MessageResponse is no longer Codable).

jamesrochabrun commented 5 months ago

@bcherry would you like to open a PR for this? thanks!