mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-10 22:13:47 +00:00
Added an agent to select the appropriate data sources for any prompt (#284)
This commit is contained in:
1 parent
657fda4961
commit
98810ce884
23 files changed
+802
-21
No files matched your search
@@ -25,6 +25,9 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<DataSourceOptions> DataSourceOptionsChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public IReadOnlyList<DataSourceAgentSelected> DataSourcesAISelected { get; set; } = [];
|
||||
|
||||
[Parameter]
|
||||
public string ConfigurationHeaderMessage { get; set; } = string.Empty;
|
||||
@@ -58,7 +61,7 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.MessageBus.RegisterComponent(this);
|
||||
this.MessageBus.ApplyFilters(this, [], [ Event.COLOR_THEME_CHANGED ]);
|
||||
this.MessageBus.ApplyFilters(this, [], [ Event.COLOR_THEME_CHANGED, Event.RAG_AUTO_DATA_SOURCES_SELECTED ]);
|
||||
|
||||
//
|
||||
// Load the settings:
|
||||
@@ -129,9 +132,17 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I
|
||||
|
||||
#endregion
|
||||
|
||||
public void ChangeOptionWithoutSaving(DataSourceOptions options)
|
||||
private SelectionMode GetListSelectionMode() => this.aiBasedSourceSelection ? MudBlazor.SelectionMode.SingleSelection : MudBlazor.SelectionMode.MultiSelection;
|
||||
|
||||
private IReadOnlyCollection<DataSourceAgentSelected> GetSelectedDataSourcesWithAI() => this.DataSourcesAISelected.Where(n => n.Selected).ToList();
|
||||
|
||||
private string GetAIReasoning(DataSourceAgentSelected source) => $"AI reasoning (confidence {source.AIDecision.Confidence:P0}): {source.AIDecision.Reason}";
|
||||
|
||||
public void ChangeOptionWithoutSaving(DataSourceOptions options, IReadOnlyList<DataSourceAgentSelected>? aiSelectedDataSources = null)
|
||||
{
|
||||
this.DataSourceOptions = options;
|
||||
this.DataSourcesAISelected = aiSelectedDataSources ?? [];
|
||||
|
||||
this.aiBasedSourceSelection = this.DataSourceOptions.AutomaticDataSourceSelection;
|
||||
this.aiBasedValidation = this.DataSourceOptions.AutomaticValidation;
|
||||
this.areDataSourcesEnabled = !this.DataSourceOptions.DisableDataSources;
|
||||
@@ -237,6 +248,13 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I
|
||||
this.showDataSourceSelection = false;
|
||||
this.StateHasChanged();
|
||||
break;
|
||||
|
||||
case Event.RAG_AUTO_DATA_SOURCES_SELECTED:
|
||||
if(data is IReadOnlyList<DataSourceAgentSelected> aiSelectedDataSources)
|
||||
this.DataSourcesAISelected = aiSelectedDataSources;
|
||||
|
||||
this.StateHasChanged();
|
||||
break;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
Reference in new issue
Block a user