-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add a timeout for getting suggestions from the LMProvider #18234
base: feature/llm
Are you sure you want to change the base?
Conversation
@@ -38,6 +38,7 @@ namespace winrt::Microsoft::Terminal::Query::Extension::implementation | |||
winrt::hstring _AIKey; | |||
winrt::Windows::Web::Http::HttpClient _httpClient{ nullptr }; | |||
IBrandingData _brandingData{ winrt::make<OpenAIBranding>() }; | |||
winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Web::Http::HttpResponseMessage, winrt::Windows::Web::Http::HttpProgress> _lastRequest{ nullptr }; |
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.
You can just make this a local variable that you capture in the cancellationToken
lambda. This avoids cancelling the wrong request.
const auto response{ co_await sendRequestOperation }; | ||
_lastRequest = sendRequestOperation; |
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.
I don't think this is effective if you set it after the wait on the request. The .get()
below should IMO also be replaced with a _lastRequest = ...
and co_await
.
Summary of the Pull Request
Adds a 5-second timeout to get a response from the LMProvider so we don't loop forever in the case of network issues/the service being unavailable
Validation Steps Performed
User receives an error message if we don't get a response within 5 seconds
PR Checklist