googleapis / googleapis/java-genai
FR: Streaming `Part` (from `InputStream`) instead of `byte[]`
- Dominant language
- Java
- Stars
- 397
- Forks
- 125
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 41
Description
**Is your feature request related to a problem? Please describe.**
https://github.com/enola-dev/enola/pull/1867#discussion_r2415141422,
for https://docs.enola.dev/use/ai/#attach, motivates this Feature Request (FR) :
For client-side JVM memory use efficiency, it would be useful if `com.google.genai.types.Part` (or perhaps its "companion class" `com.google.genai.types.Blob` ?) had a "streaming" API, to avoid having to load a file for requests into `byte[]` entirely in memory.
**Describe the solution you'd like**
Perhaps something similar to:
```java
Part fromBytes(byte[] bytes, String mimeType) {
```
but using some sort of streaming API, ideally perhaps not directly an `InputStream`, but how about [a Guava `ByteSource`](https://github.com/google/guava/wiki/IOExplained), so:
```java
Part fromStream(ByteSource byteSource, String mimeType) {
```
**Describe alternatives you've considered**
The alternative is to use the existing `byte[] bytes` API. It works, of course - but is not great for memory use.
Contributor guide
Assessment
This issue has not been assessed yet.