-
Notifications
You must be signed in to change notification settings - Fork 825
Support response caching for safety evaluators #6277
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
Merged
Conversation
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
peterwald
reviewed
Apr 10, 2025
peterwald
approved these changes
Apr 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same instance of ContentSafetyService can now be used for any annotationTask and evaluator that use the same ContentSafetyServiceConfiguration.
…of messages The evaluated model response, is now concatenated to the messages in the history.
And introduce a function on EvaluationContext to decompose its contents into constituent its AIContents.
Introduce an IChatClient for Safety evaluators to enable response caching.
Even though service urls do not include the annotation task, we only cache service urls after we check that the supplied annotation task is available in the service instance. Not considering the annotation task when caching service urls meant that if the first annotation task that we checked for happened to be available, we would skip availablity checks for all other annotations requested on the same service instance. However, not all annotations may be available on a give service instance (depending on region). Hence, we update the url caching code to also consider the annotation task.
We also embed the service configuration parameters into the provider name to ensure that the cached responses will no longer be used if the parameters change.
664c5c5
to
74e4631
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Introduce an
IChatClient
for Safety evaluators so that we can support response caching in the same way as we do for other LLM-based evaluators.Also includes some changes to introduce a
GetContents
API on theEvaluationContext
type. This aids with some of changes in this PR and should also help for #6033 in a subsequent PR.Here's a screenshot that shows how this improves the run time of
SafetyEvaluatorTests
when cached responses are available.TODO:
Fixes #6260
Microsoft Reviewers: Open in CodeFlow