dylanshine / openai-kit

A community Swift package used to interact with the OpenAI API
https://platform.openai.com/docs/api-reference
MIT License
703 stars 109 forks source link

Add content setter for Chat.Message #49

Closed ftp27 closed 1 year ago

ftp27 commented 1 year ago

I believe that this feature can be quite useful, particularly when using the stream for response and preserving the original structures from the framework to display chat in UI. With this feature, whenever a new update is received, you can simply add the new content to the previous message. Anyway, it's just a suggestion to improve usability.

dylanshine commented 1 year ago

@ftp27 You're essentially trying to reduce the Stream of content? The streaming API uses ChatStream.Choice.Message over Chat.Message. Would it make more sense to add it there, or extend the AsyncStream with a custom reduce method?

ftp27 commented 1 year ago

@dylanshine It's just a setter for the content variable. It does not disrupt any logic associated with ChatStream.Choice. Since you already have a getter for the content variable, it makes sense also to have a setter.