Skip to content

fix: do not crash isWrapped on plain OpenAI-compatible clients - #214

Open
Yuzhong Zhang (BetterAndBetterII) wants to merge 1 commit into
braintrustdata:mainfrom
BetterAndBetterII:fix/iswrapped-plain-client
Open

fix: do not crash isWrapped on plain OpenAI-compatible clients#214
Yuzhong Zhang (BetterAndBetterII) wants to merge 1 commit into
braintrustdata:mainfrom
BetterAndBetterII:fix/iswrapped-plain-client

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

isWrapped reconstructs a clean client then compares chat.completions.create.

When the Braintrust wrap global is set, a plain-object OpenAI-compatible client crashes isWrapped with TypeError reading completions.

Fix

Optional-chain both sides of the comparison so a non-reconstructible client is treated as not wrapped.

Tests

js/oai.test.ts covers the wrap-global set and unset cases for a plain-object client.

Fixes #205

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.

isWrapped crashes on custom OpenAI-compatible clients when the braintrust SDK is loaded (TypeError: reading 'completions')

1 participant