newrelic / newrelic-python-agent

New Relic Python Agent
https://docs.newrelic.com/docs/agents/python-agent
Apache License 2.0
176 stars 99 forks source link

Support for OpenAI's .with_raw_response. #1138

Closed lrafeei closed 3 months ago

lrafeei commented 4 months ago

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.

github-actions[bot] commented 4 months ago

🦙 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 commented 4 months ago

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 :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.