mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 02:39:00 +00:00
Add agenda assistant (#69)
This commit is contained in:
1 parent
1ec86ec1a6
commit
6b7800b615
60 files changed
+1873
-582
No files matched your search
@@ -1,4 +1,7 @@
|
||||
using System.Text.Json;
|
||||
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Settings.DataModel.PreviousModels;
|
||||
|
||||
using Host = AIStudio.Provider.SelfHosted.Host;
|
||||
|
||||
@@ -6,24 +9,57 @@ namespace AIStudio.Settings;
|
||||
|
||||
public static class SettingsMigrations
|
||||
{
|
||||
public static Data Migrate(Data previousData)
|
||||
public static Data Migrate(Version previousVersion, string configData, JsonSerializerOptions jsonOptions)
|
||||
{
|
||||
switch (previousData.Version)
|
||||
switch (previousVersion)
|
||||
{
|
||||
case Version.V1:
|
||||
previousData = MigrateV1ToV2(previousData);
|
||||
return MigrateV2ToV3(previousData);
|
||||
var configV1 = JsonSerializer.Deserialize<DataV1V3>(configData, jsonOptions);
|
||||
if (configV1 is null)
|
||||
{
|
||||
Console.WriteLine("Error: failed to parse the configuration. Using default values.");
|
||||
return new();
|
||||
}
|
||||
|
||||
configV1 = MigrateV1ToV2(configV1);
|
||||
configV1 = MigrateV2ToV3(configV1);
|
||||
return MigrateV3ToV4(configV1);
|
||||
|
||||
case Version.V2:
|
||||
return MigrateV2ToV3(previousData);
|
||||
|
||||
var configV2 = JsonSerializer.Deserialize<DataV1V3>(configData, jsonOptions);
|
||||
if (configV2 is null)
|
||||
{
|
||||
Console.WriteLine("Error: failed to parse the configuration. Using default values.");
|
||||
return new();
|
||||
}
|
||||
|
||||
configV2 = MigrateV2ToV3(configV2);
|
||||
return MigrateV3ToV4(configV2);
|
||||
|
||||
case Version.V3:
|
||||
var configV3 = JsonSerializer.Deserialize<DataV1V3>(configData, jsonOptions);
|
||||
if (configV3 is null)
|
||||
{
|
||||
Console.WriteLine("Error: failed to parse the configuration. Using default values.");
|
||||
return new();
|
||||
}
|
||||
|
||||
return MigrateV3ToV4(configV3);
|
||||
|
||||
default:
|
||||
Console.WriteLine("No migration needed.");
|
||||
return previousData;
|
||||
Console.WriteLine("No configuration migration needed.");
|
||||
var configV4 = JsonSerializer.Deserialize<Data>(configData, jsonOptions);
|
||||
if (configV4 is null)
|
||||
{
|
||||
Console.WriteLine("Error: failed to parse the configuration. Using default values.");
|
||||
return new();
|
||||
}
|
||||
|
||||
return configV4;
|
||||
}
|
||||
}
|
||||
|
||||
private static Data MigrateV1ToV2(Data previousData)
|
||||
private static DataV1V3 MigrateV1ToV2(DataV1V3 previousData)
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
@@ -45,7 +81,7 @@ public static class SettingsMigrations
|
||||
};
|
||||
}
|
||||
|
||||
private static Data MigrateV2ToV3(Data previousData)
|
||||
private static DataV1V3 MigrateV2ToV3(DataV1V3 previousData)
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
@@ -73,4 +109,89 @@ public static class SettingsMigrations
|
||||
WorkspaceStorageTemporaryMaintenancePolicy = previousData.WorkspaceStorageTemporaryMaintenancePolicy,
|
||||
};
|
||||
}
|
||||
|
||||
private static Data MigrateV3ToV4(DataV1V3 previousConfig)
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// We grouped the settings into different categories.
|
||||
//
|
||||
|
||||
Console.WriteLine("Migrating from v3 to v4...");
|
||||
return new()
|
||||
{
|
||||
Version = Version.V4,
|
||||
Providers = previousConfig.Providers,
|
||||
NextProviderNum = previousConfig.NextProviderNum,
|
||||
|
||||
App = new()
|
||||
{
|
||||
EnableSpellchecking = previousConfig.EnableSpellchecking,
|
||||
IsSavingEnergy = previousConfig.IsSavingEnergy,
|
||||
UpdateBehavior = previousConfig.UpdateBehavior,
|
||||
NavigationBehavior = previousConfig.NavigationBehavior,
|
||||
},
|
||||
|
||||
Chat = new()
|
||||
{
|
||||
ShortcutSendBehavior = previousConfig.ShortcutSendBehavior,
|
||||
PreselectOptions = previousConfig.PreselectChatOptions,
|
||||
PreselectedProvider = previousConfig.PreselectedChatProvider,
|
||||
},
|
||||
|
||||
Workspace = new()
|
||||
{
|
||||
StorageBehavior = previousConfig.WorkspaceStorageBehavior,
|
||||
StorageTemporaryMaintenancePolicy = previousConfig.WorkspaceStorageTemporaryMaintenancePolicy,
|
||||
},
|
||||
|
||||
IconFinder = new()
|
||||
{
|
||||
PreselectOptions = previousConfig.PreselectIconOptions,
|
||||
PreselectedProvider = previousConfig.PreselectedIconProvider,
|
||||
PreselectedSource = previousConfig.PreselectedIconSource,
|
||||
},
|
||||
|
||||
Translation = new()
|
||||
{
|
||||
PreselectLiveTranslation = previousConfig.PreselectLiveTranslation,
|
||||
DebounceIntervalMilliseconds = previousConfig.LiveTranslationDebounceIntervalMilliseconds,
|
||||
PreselectOptions = previousConfig.PreselectTranslationOptions,
|
||||
PreselectedProvider = previousConfig.PreselectedTranslationProvider,
|
||||
PreselectedTargetLanguage = previousConfig.PreselectedTranslationTargetLanguage,
|
||||
PreselectOtherLanguage = previousConfig.PreselectTranslationOtherLanguage,
|
||||
HideWebContentReader = previousConfig.HideWebContentReaderForTranslation,
|
||||
PreselectContentCleanerAgent = previousConfig.PreselectContentCleanerAgentForTranslation,
|
||||
PreselectWebContentReader = previousConfig.PreselectWebContentReaderForTranslation,
|
||||
},
|
||||
|
||||
Coding = new()
|
||||
{
|
||||
PreselectOptions = previousConfig.PreselectCodingOptions,
|
||||
PreselectedProvider = previousConfig.PreselectedCodingProvider,
|
||||
PreselectedProgrammingLanguage = previousConfig.PreselectedCodingLanguage,
|
||||
PreselectedOtherProgrammingLanguage = previousConfig.PreselectedCodingOtherLanguage,
|
||||
PreselectCompilerMessages = previousConfig.PreselectCodingCompilerMessages,
|
||||
},
|
||||
|
||||
TextSummarizer = new()
|
||||
{
|
||||
PreselectOptions = previousConfig.PreselectTextSummarizerOptions,
|
||||
PreselectedComplexity = previousConfig.PreselectedTextSummarizerComplexity,
|
||||
PreselectedProvider = previousConfig.PreselectedTextSummarizerProvider,
|
||||
PreselectedTargetLanguage = previousConfig.PreselectedTextSummarizerTargetLanguage,
|
||||
PreselectedOtherLanguage = previousConfig.PreselectedTextSummarizerOtherLanguage,
|
||||
PreselectedExpertInField = previousConfig.PreselectedTextSummarizerExpertInField,
|
||||
HideWebContentReader = previousConfig.HideWebContentReaderForTextSummarizer,
|
||||
PreselectContentCleanerAgent = previousConfig.PreselectContentCleanerAgentForTextSummarizer,
|
||||
PreselectWebContentReader = previousConfig.PreselectWebContentReaderForTextSummarizer,
|
||||
},
|
||||
|
||||
TextContentCleaner = new()
|
||||
{
|
||||
PreselectAgentOptions = previousConfig.PreselectAgentTextContentCleanerOptions,
|
||||
PreselectedAgentProvider = previousConfig.PreselectedAgentTextContentCleanerProvider,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user