Store the AI-selected data sources to the chat thread so that the user can see the selection

This commit is contained in:
Thorsten Sommer 2025-02-16 23:59:49 +01:00
parent 171a83ba58
commit 906219dd25
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 11 additions and 0 deletions

View File

@ -154,6 +154,9 @@ public sealed class ContentText : IContent
// Transform the selected data sources to the actual data sources.
selectedDataSources = aiSelectedDataSources.Select(x => settings.ConfigurationData.DataSources.FirstOrDefault(ds => ds.Id == x.Id)).Where(ds => ds is not null).ToList()!;
}
// Store the changes in the chat thread:
chatThread.DataSourceOptions.PreselectedDataSourceIds = selectedDataSources.Select(ds => ds.Id).ToList();
}
}
else

View File

@ -481,6 +481,14 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
// Disable the stream state:
this.isStreaming = false;
// Update the data source options. This is useful when
// the AI is responsible for selecting the data source.
// The user can then see the selected data source:
if(this.ChatThread?.DataSourceOptions.AutomaticDataSourceSelection ?? false)
this.dataSourceSelectionComponent?.ChangeOptionWithoutSaving(this.ChatThread!.DataSourceOptions);
// Update the UI:
this.StateHasChanged();
}