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 7 commits into
base: feature/llm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/cascadia/QueryExtension/ExtensionPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ namespace winrt::Microsoft::Terminal::Query::Extension::implementation

if (_lmProvider)
{
result = _lmProvider.GetResponseAsync(promptCopy).get();
const auto asyncOperation = _lmProvider.GetResponseAsync(promptCopy);
if (asyncOperation.wait_for(std::chrono::seconds(5)) == AsyncStatus::Completed)
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
{
result = asyncOperation.GetResults();
}
else
{
result = winrt::make<SystemResponse>(RS_(L"UnknownErrorMessage"), ErrorTypes::Unknown, winrt::hstring{});
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/QueryExtension/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<comment>The message presented to the user when they attempt to use the AI chat feature without providing an AI endpoint and key.</comment>
</data>
<data name="UnknownErrorMessage" xml:space="preserve">
<value>An error occurred. Your AI provider might not be correctly configured, or the service might be temporarily unavailable.</value>
<value>An error occurred. The service might be temporarily unavailable or there might be network connectivity issues.</value>
<comment>The error message presented to the user when we were unable to query the provided endpoint.</comment>
</data>
<data name="InvalidModelMessage" xml:space="preserve">
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/QueryExtension/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ TRACELOGGING_DECLARE_PROVIDER(g_hQueryExtensionProvider);

#include <winrt/Windows.Data.Json.h>

#include <chrono>

// Manually include til after we include Windows.Foundation to give it winrt superpowers
#include "til.h"

Expand Down
Loading