-
Notifications
You must be signed in to change notification settings - Fork 4k
.Net: Add model diagnostics to non-streaming APIs #6150
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
Merged
TaoChenOSU
merged 16 commits into
microsoft:main
from
TaoChenOSU:taochen/add-model-diagnostics-to-non-streaming-apis
May 10, 2024
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
15d3e1c
Add model diagnostics class
TaoChenOSU 5b88eee
Add model diagnostics to OpenAI text & chat completions
TaoChenOSU fec726a
Add model diagnostics to Gemini and HuggingFace text & chat completions
TaoChenOSU e25e26d
Typo
TaoChenOSU e0f4bfd
Format
TaoChenOSU 9f93127
Fix build
TaoChenOSU 6a1d367
Fix build
TaoChenOSU 34608bb
Fix build
TaoChenOSU b8f73ab
Exclude ActivityExtensions from code coverage report
TaoChenOSU 037139f
Small fixes
TaoChenOSU 8c414f4
Address comments
TaoChenOSU 1375d09
Formatting
TaoChenOSU 1ee1451
Formatting
TaoChenOSU 7f2c81b
Revert csproj file auto-format
TaoChenOSU 0d5ad18
Optimize string join
TaoChenOSU 08bdfd0
Merge branch 'main' into taochen/add-model-diagnostics-to-non-streami…
TaoChenOSU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
dotnet/src/InternalUtilities/src/Diagnostics/ActivityExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Microsoft.SemanticKernel.Diagnostics; | ||
|
||
[ExcludeFromCodeCoverage] | ||
internal static class ActivityExtensions | ||
{ | ||
public static Activity? StartActivityWithTags(this ActivitySource source, string name, List<KeyValuePair<string, object?>> tags) | ||
{ | ||
return source.StartActivity( | ||
name, | ||
ActivityKind.Internal, | ||
TaoChenOSU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Activity.Current?.Context ?? new ActivityContext(), | ||
TaoChenOSU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tags); | ||
} | ||
|
||
public static Activity AddTags(this Activity activity, List<KeyValuePair<string, object?>> tags) | ||
{ | ||
tags.ForEach(tag => | ||
{ | ||
activity.SetTag(tag.Key, tag.Value); | ||
}); | ||
TaoChenOSU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return activity; | ||
} | ||
|
||
public static Activity AttachSensitiveDataAsEvent(this Activity activity, string name, List<KeyValuePair<string, object?>> tags) | ||
{ | ||
activity.AddEvent(new ActivityEvent( | ||
TaoChenOSU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name, | ||
tags: new ActivityTagsCollection(tags) | ||
)); | ||
|
||
return activity; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.