files: CreateFile adds backwards-compatible io.Reader input, Purpose const #590
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR supersedes #577 coincidentally.
Describe the change
I have re-implemented
FileRequest
andCreateFile
so as to support arbitraryio.Reader
inputs which must have priority overFilePath
and also fixed some errors in the implementation. I've also took the liberty of adding aPurpose
enum and testing for it, as fine-tuning requires a particular file format. Perhaps it's worthwhile getting rid ofCreateFormFile
semantics altogether at some later stage as it's, frankly, short-sighted and embarrassing. Thankfully, it hasn't touched the API boundary.Also: I've made some other adjustments in streaming API that have not been included part of this PR. I'm eager to hear feedback on this commit as it's implementing "teeing" of streaming response so as to make proxying so much easier. I reckon a great deal of go-openai use cases will revolve around proxying, in fact that's our primary use-case & if you're supposed to forward the response as well as parse it, then this type of change will be very favourable. My implementation takes advantage of
io.Pipe
andio.TeeReader
and hence the server code is quite straightforward: