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

Support for OpenAI's .with_raw_response. #1138

Merged
merged 12 commits into from
Jun 10, 2024
Merged

Support for OpenAI's .with_raw_response. #1138

merged 12 commits into from
Jun 10, 2024

Conversation

lrafeei
Copy link
Contributor

@lrafeei lrafeei commented May 10, 2024

This PR adds support for .with_raw_response. prepending to HTTP method calls in OpenAI.

Currently, the New Relic instrumentation will instrument this, but during the collection of custom AI event attributes, this modified response type (LegacyAPIResponse) will result in a crash.

This is part 1 of two PRs. The second part will cover the streaming version of this functionality, .with_streaming_response.

Copy link

github-actions bot commented May 10, 2024

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON bandit 1 0 5.71s
✅ PYTHON black 7 1 0 2.4s
✅ PYTHON flake8 7 0 0.84s
✅ PYTHON isort 7 1 0 0.23s
❌ PYTHON pylint 7 31 6.0s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.66%. Comparing base (2ab12c5) to head (77bd146).

Files Patch % Lines
newrelic/hooks/mlmodel_openai.py 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1138      +/-   ##
==========================================
- Coverage   81.67%   81.66%   -0.02%     
==========================================
  Files         193      193              
  Lines       21334    21341       +7     
  Branches     3717     3721       +4     
==========================================
+ Hits        17425    17428       +3     
+ Misses       2826     2825       -1     
- Partials     1083     1088       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lrafeei lrafeei marked this pull request as ready for review May 13, 2024 16:45
@lrafeei lrafeei requested a review from a team as a code owner May 13, 2024 16:45
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had one requested change to the implementation otherwise looks good.

newrelic/hooks/mlmodel_openai.py Show resolved Hide resolved
@lrafeei lrafeei requested a review from hmstepanek June 4, 2024 16:21
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it manually and things show up in the UI. Couple additional fixes but after that I think we're good to merge this one.

newrelic/hooks/mlmodel_openai.py Outdated Show resolved Hide resolved
newrelic/hooks/mlmodel_openai.py Outdated Show resolved Hide resolved
newrelic/hooks/mlmodel_openai.py Show resolved Hide resolved
newrelic/hooks/mlmodel_openai.py Outdated Show resolved Hide resolved
newrelic/hooks/mlmodel_openai.py Outdated Show resolved Hide resolved
newrelic/hooks/mlmodel_openai.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the tests-failing label Jun 6, 2024
@lrafeei lrafeei requested a review from hmstepanek June 6, 2024 20:36
@lrafeei lrafeei merged commit 60c5549 into main Jun 10, 2024
50 of 51 checks passed
@lrafeei lrafeei deleted the openai-legacy-response branch June 10, 2024 18:13
@umaannamalai umaannamalai added this to the v9.11.0 milestone Jun 13, 2024
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.

None yet

4 participants