-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08dd951
commit 1934b30
Showing
11 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "AIConfig.h" | ||
#include "AIConfig.g.cpp" | ||
|
||
#include "TerminalSettingsSerializationHelpers.h" | ||
#include "JsonUtils.h" | ||
|
||
using namespace Microsoft::Terminal::Settings::Model; | ||
using namespace winrt::Microsoft::Terminal::Settings::Model::implementation; | ||
|
||
static constexpr std::string_view AIConfigKey{ "aiConfig" }; | ||
|
||
winrt::com_ptr<AIConfig> AIConfig::CopyAIConfig(const AIConfig* source) | ||
{ | ||
auto aiConfig{ winrt::make_self<AIConfig>() }; | ||
|
||
#define AI_SETTINGS_COPY(type, name, jsonKey, ...) \ | ||
aiConfig->_##name = source->_##name; | ||
MTSM_AI_SETTINGS(AI_SETTINGS_COPY) | ||
#undef AI_SETTINGS_COPY | ||
|
||
return aiConfig; | ||
} | ||
|
||
Json::Value AIConfig::ToJson() const | ||
{ | ||
Json::Value json{ Json::ValueType::objectValue }; | ||
|
||
#define AI_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ | ||
JsonUtils::SetValueForKey(json, jsonKey, _##name); | ||
MTSM_AI_SETTINGS(AI_SETTINGS_TO_JSON) | ||
#undef AI_SETTINGS_TO_JSON | ||
|
||
return json; | ||
} | ||
|
||
void AIConfig::LayerJson(const Json::Value& json) | ||
{ | ||
const auto aiConfigJson = json[JsonKey(AIConfigKey)]; | ||
|
||
#define AI_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ | ||
JsonUtils::GetValueForKey(aiConfigJson, jsonKey, _##name); | ||
MTSM_AI_SETTINGS(AI_SETTINGS_LAYER_JSON) | ||
#undef AI_SETTINGS_LAYER_JSON | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
Module Name: | ||
- AIConfig | ||
Abstract: | ||
- The implementation of the AIConfig winrt class. Provides settings related | ||
to the AI settings of the terminal | ||
Author(s): | ||
- Pankaj Bhojwani - June 2024 | ||
--*/ | ||
|
||
#pragma once | ||
|
||
#include "pch.h" | ||
#include "AIConfig.g.h" | ||
#include "IInheritable.h" | ||
#include "JsonUtils.h" | ||
#include "MTSMSettings.h" | ||
#include <DefaultSettings.h> | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Model::implementation | ||
{ | ||
struct AIConfig : AIConfigT<AIConfig>, IInheritable<AIConfig> | ||
{ | ||
public: | ||
AIConfig() = default; | ||
static winrt::com_ptr<AIConfig> CopyAIConfig(const AIConfig* source); | ||
Json::Value ToJson() const; | ||
void LayerJson(const Json::Value& json); | ||
|
||
#define AI_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ | ||
INHERITABLE_SETTING(Model::AIConfig, type, name, ##__VA_ARGS__) | ||
MTSM_AI_SETTINGS(AI_SETTINGS_INITIALIZE) | ||
#undef AI_SETTINGS_INITIALIZE | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "IInheritable.idl.h" | ||
|
||
namespace Microsoft.Terminal.Settings.Model | ||
{ | ||
enum LLMProvider | ||
{ | ||
AzureOpenAI, | ||
OpenAI | ||
}; | ||
|
||
[default_interface] runtimeclass AIConfig { | ||
INHERITABLE_SETTING(LLMProvider, ActiveProvider); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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