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

Add a timeout for getting suggestions from the LMProvider #18234

Open
wants to merge 3 commits into
base: feature/llm
Choose a base branch
from

Conversation

PankajBhojwani
Copy link
Contributor

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

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Nov 22, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Nov 22, 2024
@@ -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 };
Copy link
Member

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.

Comment on lines +157 to +158
const auto response{ co_await sendRequestOperation };
_lastRequest = sendRequestOperation;
Copy link
Member

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.

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.

3 participants