Skip to content
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

[feature] Surface apim-request-id #722

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

iseabock
Copy link
Contributor

@iseabock iseabock commented Mar 25, 2024

Motivation and Context

Surface apim-request-id for better debugging in streaming and non-streaming responses

Description

Added a headers key with a dictionary containing the key/value for apim-request-id. Currently, this is viewable in the result object in the frontend. The task however, requires that this value be in the HAR file. I'm still trying to get that to show up.

スクリーンショット 2024-04-11 112518

Contribution Checklist

  • I have built and tested the code locally and in a deployed app
  • For frontend changes, I have pulled the latest code from main, built the frontend, and committed all static files.
  • This is a change for all users of this app. No code or asset is specific to my use case or my organization.
  • I didn't break any existing functionality 😄

@iseabock iseabock self-assigned this Mar 25, 2024
@sarah-widder
Copy link
Contributor

@iseabock what about non-streaming?

@iseabock
Copy link
Contributor Author

iseabock commented Mar 27, 2024

what about non-streaming?

I'm not sure how to retrieve the apim-request-id for non-streaming. For some reason, send_chat_request in complete_chat_request doesn't return a header.

@iseabock iseabock requested a review from sarah-widder March 28, 2024 17:12
@iseabock iseabock marked this pull request as ready for review March 28, 2024 17:12
@abhahn
Copy link
Member

abhahn commented Apr 1, 2024

what about non-streaming?

I'm not sure how to retrieve the apim-request-id for non-streaming. For some reason, send_chat_request in complete_chat_request doesn't return a header.

what about non-streaming?

I'm not sure how to retrieve the apim-request-id for non-streaming. For some reason, send_chat_request in complete_chat_request doesn't return a header.

I think the problem with the non-streaming response is that it is being returned as a plain ChatCompletion object, which doesn't include the raw response.

I got some inspiration from this StackOverflow thread to try using with_raw_response, and running in the debugger found that the response from that does have the headers (including apim-request-id), but the content would need to be deserialized to ChatCompletion before returning it. I'm not sure what other implications there are (particularly for streaming) but maybe you could try it out to see? https://stackoverflow.com/questions/77605691/how-to-get-headers-from-openai-api

@iseabock iseabock force-pushed the 27084332-feature-surface-apim-request-id branch from 76e84a6 to 645fa61 Compare April 11, 2024 18:05
@iseabock iseabock merged commit 9bfb621 into main Apr 16, 2024
5 checks passed
@iseabock iseabock deleted the 27084332-feature-surface-apim-request-id branch April 16, 2024 18:02
rafaelbaum pushed a commit to rafaelbaum/sample that referenced this pull request May 6, 2024
Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
sudo-init pushed a commit to sudo-init/sample-app-chatGPT that referenced this pull request Sep 20, 2024
Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
nikhilnagaraj pushed a commit to Admin-bh-Edge/Edge-Comp-Policies that referenced this pull request Oct 2, 2024
Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
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.

3 participants