Skip to content

FIleInput from memory #144

@nodir-t

Description

@nodir-t
Contributor

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.

Activity

64bit

64bit commented on Nov 11, 2023

@64bit
Owner

In current design files are only read from filesystem.

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

monadoid

monadoid commented on Nov 15, 2023

@monadoid
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

64bit commented on Nov 16, 2023

@64bit
Owner

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

nodir-t commented on Nov 16, 2023

@nodir-t
ContributorAuthor

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.

monadoid

monadoid commented on Nov 21, 2023

@monadoid
Contributor

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

64bit commented on Nov 25, 2023

@64bit
Owner

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

ifsheldon commented on Nov 26, 2023

@ifsheldon
Contributor

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.

monadoid

monadoid commented on Nov 26, 2023

@monadoid
Contributor

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

nodir-t

nodir-t commented on Dec 9, 2023

@nodir-t
ContributorAuthor

AsyncRead is even better. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @64bit@ifsheldon@monadoid@nodir-t

        Issue actions

          FIleInput from memory · Issue #144 · 64bit/async-openai