-
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
Allow OpenAI to be used with Terminal Chat #17540
Conversation
@@ -56,6 +56,9 @@ | |||
<ClInclude Include="AzureLLMProvider.h"> | |||
<DependentUpon>AzureLLMProvider.idl</DependentUpon> | |||
</ClInclude> | |||
<ClInclude Include="OpenAILLMProvider.h"> |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
_NotifyChanges(L"IsOpenAIKeySet"); | ||
} | ||
|
||
bool AISettingsViewModel::AzureOpenAIIsActive() |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
@@ -0,0 +1,129 @@ | |||
// Copyright (c) Microsoft Corporation. |
Check failure
Code scanning / check-spelling
Check File Path
@@ -0,0 +1,48 @@ | |||
// Copyright (c) Microsoft Corporation. |
Check failure
Code scanning / check-spelling
Check File Path
@@ -0,0 +1,17 @@ | |||
// Copyright (c) Microsoft Corporation. |
Check failure
Code scanning / check-spelling
Check File Path
@@ -96,6 +102,9 @@ | |||
<Midl Include="AzureLLMProvider.idl"> | |||
<SubType>Code</SubType> | |||
</Midl> | |||
<Midl Include="OpenAILLMProvider.idl"> |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
</Button> | ||
<Button Click="SetAzureOpenAIActive_Click" | ||
HorizontalAlignment="Center" | ||
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(ViewModel.AzureOpenAIIsActive), Mode=OneWay}"> |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
</Button> | ||
<Button Click="SetOpenAIActive_Click" | ||
HorizontalAlignment="Center" | ||
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(ViewModel.OpenAIIsActive), Mode=OneWay}"> |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
void AISettingsViewModel::SetAzureOpenAIActive() | ||
{ | ||
_Settings.GlobalSettings().AIInfo().ActiveProvider(Model::LLMProvider::AzureOpenAI); | ||
_NotifyChanges(L"AzureOpenAIIsActive"); |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
{ | ||
_Settings.GlobalSettings().AIInfo().ActiveProvider(Model::LLMProvider::AzureOpenAI); | ||
_NotifyChanges(L"AzureOpenAIIsActive"); | ||
_NotifyChanges(L"OpenAIIsActive"); |
Check failure
Code scanning / check-spelling
Unrecognized Spelling
This comment has been minimized.
This comment has been minimized.
const auto val{ _getActiveProviderImpl() }; | ||
if (val) | ||
{ | ||
// an active provider was explicitly set, return that | ||
return *val; | ||
} |
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.
This does mean that you can set an active provider even if you have not configured that provider - in this case when you try to use the Chat the provider will return the appropriate error. For example, the OpenAI provider will still make the http request and we get an error message back that no api key was provided.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…nto dev/pabhoj/llm_provider_interface
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.
Biggest concern: The strong-this issue. Otherwise, it seems fine - just some smaller issues.
{ | ||
enum LLMProvider | ||
{ | ||
AzureOpenAI, |
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 need a None
option to return in case none are set - otherwise, the zero value is AzureOpenAI
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.
Yeah I realized this in #18095 and added it there, I'll bring that change forward to here
} | ||
else | ||
{ | ||
return LLMProvider{}; |
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.
(The note about having a zero value applies here!)
OpenAILLMProvider
, which is an implementation ofILMProvider
that uses OpenAIAIConfig
on the settings model side, to allow the user to specify which AI provider to use as their current active one (in the case that they have configured more than one LMProvider)The OpenAI implementation is largely the same as the Azure OpenAI one. The more "new" change in this PR is the
AIConfig
struct on the settings model side that allows the user to specify which provider is the active one, as well as the logic inTerminalPage
for how we update the current active provider based on settings changesValidation Steps Performed