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

feat: Add support for OpenAI client library for .NET #2987

Merged
merged 22 commits into from
Feb 12, 2025

Conversation

tippmar-nr
Copy link
Member

@tippmar-nr tippmar-nr commented Feb 10, 2025

BEGIN_COMMIT_OVERRIDE
feat: Add AI Monitoring instrumentation for OpenAI and Azure.AI.OpenAI (#2987)
END_COMMIT_OVERRIDE

Description

Adds instrumentation for the OpenAI client library for .NET, version 2.0.0 and later. Note that this feature also supports Azure.AI.OpenAI version 2.0.0 and later.

Text chat completions for the following methods are instrumented:
CompleteChatAsync()
CompleteChat()

Includes unit and integration tests.

Thanks to @harrykimpel for the initial implementation work!

Author Checklist

  • Unit tests, Integration tests, and Unbounded tests completed
  • Performance testing completed with satisfactory results (if required)

Reviewer Checklist

  • Perform code review
  • Pull request was adequately tested (new/existing tests, performance tests)

harrykimpel and others added 14 commits January 14, 2025 13:20
* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI AI monitoring capabilities

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI LLM tests

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI tests

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

---------

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>
* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI AI monitoring capabilities

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI wrapper

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI LLM tests

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

* Adding OpenAI tests

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>

---------

Signed-off-by: Harry Kimpel <harrykimpel@hotmail.com>
Co-authored-by: Marty T <120425148+tippmar-nr@users.noreply.github.com>
@tippmar-nr tippmar-nr changed the title **DRAFT** feat: OpenAI Support for ChatClient feat: Add support for OpenAI client library for .NET Feb 11, 2025
@tippmar-nr tippmar-nr marked this pull request as ready for review February 11, 2025 17:02
@tippmar-nr tippmar-nr requested a review from a team as a code owner February 11, 2025 17:02
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 80.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 82.19%. Comparing base (19e8387) to head (7d84ed6).

Files with missing lines Patch % Lines
...sions/Llm/Bedrock/BedrockLlmModelTypeExtensions.cs 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2987      +/-   ##
==========================================
+ Coverage   82.17%   82.19%   +0.01%     
==========================================
  Files         473      475       +2     
  Lines       30391    30450      +59     
  Branches     3392     3407      +15     
==========================================
+ Hits        24975    25027      +52     
- Misses       4617     4621       +4     
- Partials      799      802       +3     
Flag Coverage Δ
Agent 83.16% <80.00%> (+0.01%) ⬆️
Profiler 73.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...sions/NewRelic.Agent.Extensions/Llm/EventHelper.cs 99.25% <100.00%> (-0.75%) ⬇️
...ensions/Llm/OpenAi/OpenAiHeaderDictionaryHelper.cs 100.00% <100.00%> (ø)
...sions/Llm/Bedrock/BedrockLlmModelTypeExtensions.cs 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

@tippmar-nr tippmar-nr merged commit aa06d9d into main Feb 12, 2025
98 checks passed
@tippmar-nr tippmar-nr deleted the feature/openai-instrumentation branch February 12, 2025 20:52
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.

5 participants