Skip to content

Improve ergonomics / efficiency of GeneratedContent coding #105

@mattt

Description

@mattt

As described by @belozierov in #98 (comment):

I receive the LLM response as JSON (decoded using Decodable), which contains the generated Content (decoded via AnyCodable) along with additional metadata. I then: 1. Re-encode the AnyCodable content back into Data 2. Convert that Data into a String 3. Pass it to GeneratedContent.init(json: String), where it is converted back into Data again

To reduce unnecessary transformations (allocations/copies), it would be useful to add GeneratedContent.init(json: Data). It would be even better if GeneratedContent supported Codable directly for JSON data (initially this was a bit confusing, because I assumed this was already how GeneratedContent: Codable worked).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions