Skip to content

fix(js): support Uint8Array and Buffer JSONL sources in OpenAI batch instrumentation - #2479

Open
Mohd Quamar Tyagi (Tyagiquamar) wants to merge 2 commits into
braintrustdata:mainfrom
Tyagiquamar:fix-openai-batch-uint8array-jsonl-support
Open

Mohd Quamar Tyagi (Tyagiquamar) wants to merge 2 commits into
braintrustdata:mainfrom
Tyagiquamar:fix-openai-batch-uint8array-jsonl-support

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Summary

When \jsonlRecords\ receives a resolved file source as a \Uint8Array, \ArrayBuffer, or Node \Buffer\ (for instance, when files are read via \ s.promises.readFile\ or fetched as array buffers), the previous type check \ ypeof resolvedFile === 'string'\ evaluated to false. As a result, the source reached the fallback check where it logged an invalid JSONL source error.

This PR updates \jsonlRecords\ to check for \Uint8Array, \ArrayBuffer, and \Buffer\ instances and decodes byte buffers using \TextDecoder\ so binary-backed JSONL file sources are parsed correctly.

Testing

  • Tested \jsonlRecords\ stream decoding with \Uint8Array\ and \Buffer\ payload inputs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant