mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 21:59:48 +00:00
Handling of llm provider selection based on configured behavior
This commit is contained in:
parent
11b78a7bf3
commit
50c15994ec
@ -64,7 +64,6 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
// Configure the spellchecking for the user input:
|
// Configure the spellchecking for the user input:
|
||||||
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
||||||
|
|
||||||
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
|
||||||
this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT);
|
this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT);
|
||||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
|
||||||
if (deferredContent is not null)
|
if (deferredContent is not null)
|
||||||
@ -106,7 +105,8 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.loadChat = deferredLoading;
|
this.loadChat = deferredLoading;
|
||||||
this.mustLoadChat = true;
|
this.mustLoadChat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.SelectProviderWhenLoadingChat();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +126,11 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.chatThread = await WorkspaceBehaviour.LoadChat(this.loadChat);
|
this.chatThread = await WorkspaceBehaviour.LoadChat(this.loadChat);
|
||||||
|
|
||||||
if(this.chatThread is not null)
|
if(this.chatThread is not null)
|
||||||
|
{
|
||||||
this.currentWorkspaceName = await WorkspaceBehaviour.LoadWorkspaceName(this.chatThread.WorkspaceId);
|
this.currentWorkspaceName = await WorkspaceBehaviour.LoadWorkspaceName(this.chatThread.WorkspaceId);
|
||||||
|
this.SelectProviderWhenLoadingChat();
|
||||||
|
}
|
||||||
|
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +396,19 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.isStreaming = false;
|
this.isStreaming = false;
|
||||||
this.hasUnsavedChanges = false;
|
this.hasUnsavedChanges = false;
|
||||||
this.userInput = string.Empty;
|
this.userInput = string.Empty;
|
||||||
|
|
||||||
|
switch (this.SettingsManager.ConfigurationData.Chat.AddChatProviderBehavior)
|
||||||
|
{
|
||||||
|
case AddChatProviderBehavior.ADDED_CHATS_USE_DEFAULT_PROVIDER:
|
||||||
|
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER:
|
||||||
|
if(this.providerSettings == default)
|
||||||
|
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!useSameWorkspace)
|
if (!useSameWorkspace)
|
||||||
{
|
{
|
||||||
@ -404,6 +420,7 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
{
|
{
|
||||||
this.chatThread = new()
|
this.chatThread = new()
|
||||||
{
|
{
|
||||||
|
SelectedProvider = this.providerSettings.Id,
|
||||||
WorkspaceId = this.currentWorkspaceId,
|
WorkspaceId = this.currentWorkspaceId,
|
||||||
ChatId = Guid.NewGuid(),
|
ChatId = Guid.NewGuid(),
|
||||||
Name = string.Empty,
|
Name = string.Empty,
|
||||||
@ -486,7 +503,9 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.userInput = string.Empty;
|
this.userInput = string.Empty;
|
||||||
this.currentWorkspaceId = this.chatThread?.WorkspaceId ?? Guid.Empty;
|
this.currentWorkspaceId = this.chatThread?.WorkspaceId ?? Guid.Empty;
|
||||||
this.currentWorkspaceName = this.chatThread is null ? string.Empty : await WorkspaceBehaviour.LoadWorkspaceName(this.chatThread.WorkspaceId);
|
this.currentWorkspaceName = this.chatThread is null ? string.Empty : await WorkspaceBehaviour.LoadWorkspaceName(this.chatThread.WorkspaceId);
|
||||||
|
|
||||||
|
this.SelectProviderWhenLoadingChat();
|
||||||
|
|
||||||
this.userInput = string.Empty;
|
this.userInput = string.Empty;
|
||||||
if (this.SettingsManager.ConfigurationData.Chat.ShowLatestMessageAfterLoading)
|
if (this.SettingsManager.ConfigurationData.Chat.ShowLatestMessageAfterLoading)
|
||||||
{
|
{
|
||||||
@ -506,6 +525,27 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.chatThread = null;
|
this.chatThread = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SelectProviderWhenLoadingChat()
|
||||||
|
{
|
||||||
|
var chatProvider = this.chatThread?.SelectedProvider;
|
||||||
|
switch (this.SettingsManager.ConfigurationData.Chat.LoadingProviderBehavior)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case LoadingChatProviderBehavior.USE_CHAT_PROVIDER_IF_AVAILABLE:
|
||||||
|
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT, chatProvider);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LoadingChatProviderBehavior.ALWAYS_USE_DEFAULT_CHAT_PROVIDER:
|
||||||
|
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LoadingChatProviderBehavior.ALWAYS_USE_LATEST_CHAT_PROVIDER:
|
||||||
|
if(this.providerSettings == default)
|
||||||
|
this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Overrides of MSGComponentBase
|
#region Overrides of MSGComponentBase
|
||||||
|
|
||||||
public override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
public override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
||||||
|
Loading…
Reference in New Issue
Block a user