Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIleInput from memory #144

Open
nodir-t opened this issue Nov 10, 2023 · 9 comments
Open

FIleInput from memory #144

nodir-t opened this issue Nov 10, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@nodir-t
Copy link
Contributor

nodir-t commented Nov 10, 2023

I am trying to understand how to upload a file with contents from memory and can't figure out how. It appears that file input is only from a file? Do I have to save my bytes to file system to read them back?

My overall goal is to upload a file my program receives, from an incoming network request to an assistant thread.

@64bit
Copy link
Owner

64bit commented Nov 11, 2023

In current design files are only read from filesystem.

File uploads from in-memory sounds like a good feature to add.

@prosammer
Copy link
Contributor

@64bit I am looking for the ability to add audio data vecs to AudioInput instead of having to write them to a file first, would this be something you'd be interested in a PR for?

@64bit
Copy link
Owner

64bit commented Nov 16, 2023

Absolutely interested!I think having this feature would work same for bunch of inputs: FileInput, ImageInput, AudioInput. Looks like they need to be enum to support paths and bytes?

Regarding PR: for non trivial features like this one it really helps to have a new self contained example because it becomes easy to test new feature and old examples.

@nodir-t
Copy link
Contributor Author

nodir-t commented Nov 16, 2023

Could you accept io::Read instead, not a Vec? I'd like to be able to pipe data from a network request to OpenAI without having it buffer it neither in the file system, nor memory.

@64bit 64bit added the enhancement New feature or request label Nov 17, 2023
@prosammer
Copy link
Contributor

prosammer commented Nov 21, 2023

Hey @nodir-t @64bit , I put up a PR which works for in-memory files (Bytes and vec[u8] as that's what reqwest::Body accepts), but I wasn't able to figure out a way to get these inputs to take an io::Read as it seems reqwest::Body wants AsyncRead. I tried having these Inputs accept a generic that was AsyncRead but got confused as to how that would work with the derive_builder builder which would require the AsyncRead instance to be Clone as well. I'm fairly new to Rust and open source PRs so any feedback would be much appreciated!

@64bit
Copy link
Owner

64bit commented Nov 25, 2023

hey @prosammer , thank you I was able to check it out today and it looks good given that its backward compatible change for consumers of library happy to merge it.

I'll keep this issue open for the context and if someone wants to continue work on AsyncRead and io:Read suggested in this thread.

@ifsheldon
Copy link
Contributor

ifsheldon commented Nov 26, 2023

This seems coincidentally solve some issues for wasm support, as I was planning to do this here. Thanks @prosammer! If you have some time and interest, you can take a look at the experiment branch and help mature the wasm support.

@prosammer
Copy link
Contributor

@ifsheldon haha awesome, I'm not very familiar with wasm but I will take a look!

@nodir-t
Copy link
Contributor Author

nodir-t commented Dec 9, 2023

AsyncRead is even better. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants