DelegateHandler instead of Retry Interface#2
Closed
lemillermicrosoft wants to merge 8 commits intomainfrom
Closed
Conversation
5 tasks
99b9f79 to
deef524
Compare
389a536 to
c492c9b
Compare
…etry policy used by the semantic kernel and its extensions. The main changes are: - Replacing the IRetryMechanism interface with the IDelegatingHandlerFactory interface, which allows more flexibility and control over the retry logic for HTTP requests. - Adding a new DefaultHttpRetryHandler class that inherits from DelegatingHandler and implements the default retry policy using Polly. The policy handles retryable status codes and exceptions, respects the RetryAfter header from the server, and uses exponential backoff if configured. - Adding a new NullHttpRetryHandler class that implements a no-retry policy. - Adding a new HttpRetryConfig class that defines the default retry configuration for the IHttpRetryPolicy. - Adding a new HttpHandlerFactory property to the KernelConfig class, which allows users to specify a custom retry handler factory for the kernel. The class also exposes a SetHttpHandlerFactory and a SetDefaultHttpRetryConfig method to configure these properties. - Updating the OpenAI services to use the HttpHandlerFactory from the KernelConfig, and adding a new parameter to their constructors. - Adding unit tests for the DefaultHttpRetryHandler and NullHttpRetryHandler classes, covering various scenarios of retrying and not retrying HTTP requests. - Adding a new file Example08_RetryHandler.cs that demonstrates how to use different retry policies when making HTTP requests with the semantic kernel. - Removing the PassThroughWithoutRetry class and the Example08_RetryMechanism.cs file, as they are no longer needed. - Properly disposing of the retry handler in the OpenAIClientAbstract class. - Adding a CancellationToken parameter to the CompleteAsync method of the ITextCompletion interface and its implementations, allowing the caller to cancel the request if needed. - Refactoring the OpenAIClientAbstract class to use a delegating handler factory for injecting retry logic, and updating the AzureOpenAIClientAbstract class accordingly. - Modifying some documentation and tests to reflect the changes. - Updating the project file to allow Moq to access internal types for testing purposes. - Fixing some typos and formatting issues in the code.
Summary: This commit changes the version prefix of all nuget packages from 0.9 to 0.8 in the nuget-package.props file. This is done to align with the current release cycle and avoid confusion with the previous versions.
Summary: This commit makes several changes to the HTTP retry handler logic and logging for the Semantic Kernel project. The main changes are: - Pass the logger instance to the retry handler factory instead of the constructor, to allow different loggers for different clients. - Change the log level from warning to error when the max retry count or time is reached, to indicate a more severe problem. - Remove the TimeoutException and WebException from the list of retryable exception types, since they are already handled by the HttpRequestException. - Rename the WithRetryHandler method to WithRetryHandlerFactory, to avoid confusion with the DelegatingHandler class. - Fix a typo in the CloneAsync method comment.
… in the RepoUtils project. It makes the following changes: - Simplifies the creation of retry handler factories by passing the logger as a parameter instead of a constructor dependency. This avoids creating multiple logger instances for each factory. - Removes the unused TimeoutException and WebException types from the retry handler tests, since they are no longer used by the HttpClient. - Changes the logging format to use milliseconds instead of msecs for consistency and clarity. It also fixes the formatting of the time span values. - Adds some missing log messages for the NoRetryPolicy and the DefaultHttpRetryHandler. - Lowers the minimum level for the console logger to show all messages, and adds a filter for the System namespace to only show warnings or higher. This makes the console output more informative and less noisy.
e925c65 to
e15cae2
Compare
Owner
Author
|
Published in microsoft#58 |
dehoward
pushed a commit
that referenced
this pull request
Jun 1, 2023
The translation feature in the Book Creator Sample App doesn't work as expected, due to a bug where a wrong target language is passed in.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit refactors the HTTP retry logic for the kernel and its services by using DelegatingHandler subclasses instead of custom interfaces. It also adds a new HttpRetryConfig class that can be used to configure the default retry parameters for the kernel. The commit uses the Polly library and its extensions to implement the retry policies, and provides some examples of different retry handlers. The commit also updates the tests, the documentation, and the OpenAI clients to reflect these changes.