-
Notifications
You must be signed in to change notification settings - Fork 317
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
handles _thenUnwrap for OpenAI's custom APIPromise class #5233
Conversation
Hi @sabrenner, I saw that you’re the main author of this file—would you be open to reviewing this PR when you have a moment? Thanks a lot! |
Hi @josemussa! Yes, I'll be taking a look at this today, thanks for the ping! |
This change LGTM, although I'll refactor the test a bit. Unfortunately CI for community PRs isn't great here haha - I will cherry pick your commits into a new PR to run against CI and merge 🙌 just also wanna note as an FYI that since it's technically on the beta client, we generally won't be as quick to update support if its behavior changes at all from what we assume, and once the functionality that is supported here (I'm guessing structured output) is passed onto the official client, we'll advertise tracing through the official client instead. |
Thanks, @sabrenner! Appreciate you handling the CI situation and the refactor. Let me know if anything else is needed! 🚀 |
Hi @josemussa, the PR with the cherry picks has been merged! We should be tracing those beta chat completions now. Will follow up with the release it lands in (it might not be the next patch release, but probably 5.38.0 instead) |
Great news! Thank you @sabrenner 🙇 |
What does this PR do?
Tracing is failing for requests that include a call to the OpenAI
this.client.beta.chat.completions.parse
method.This happens because OpenAI uses a custom promise class. The Datadog team is already aware of this issue, as it was previously addressed for the OpenAI
this.client.chat.completions.create
method. I'm reusing that logic to resolve the current issue.This PR implements the same unwrap logic and response handler that is used for the
parse
method, but for the_thenUnwrap
method.Motivation
When using the OpenAI Node SDK and calling
await this.client.beta.chat.completions.parse
, traces completely break.This happens because OpenAI uses a custom promise. This issue was previously fixed for
this.client.chat.completions.create
(the non-beta version). To address this, I abstracted that fix and applied it to_thenUnwrap
.The issue is reported here openai/openai-node#1307
Plugin Checklist
Additional Notes