mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-11-23 07:50:20 +00:00
Working on it
This commit is contained in:
parent
ce04a17145
commit
01c48e14df
@ -25,7 +25,7 @@ else
|
||||
<MudList T="DataDocumentAnalysisPolicy" Class="mb-1" SelectedValue="@this.selectedPolicy" SelectedValueChanged="@this.SelectedPolicyChanged">
|
||||
@foreach (var policy in this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies)
|
||||
{
|
||||
<MudListItem T="DataDocumentAnalysisPolicy" Icon="@Icons.Material.Filled.Settings" Value="@policy">
|
||||
<MudListItem T="DataDocumentAnalysisPolicy" Icon="@Icons.Material.Filled.Policy" Value="@policy">
|
||||
@policy.PolicyName
|
||||
</MudListItem>
|
||||
}
|
||||
@ -42,7 +42,7 @@ else
|
||||
</MudStack>
|
||||
|
||||
<MudExpansionPanels Class="mb-3 mt-6" MultiExpansion="@false">
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Settings" HeaderText="@T("Policy definition")" IsExpanded="@(!this.selectedPolicy?.IsProtected ?? true)">
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Policy" HeaderText="@T("Policy definition")" IsExpanded="@(!this.selectedPolicy?.IsProtected ?? true)">
|
||||
<MudText Typo="Typo.h4" Class="mb-1">
|
||||
@T("Common settings")
|
||||
</MudText>
|
||||
@ -69,7 +69,7 @@ else
|
||||
@T("Preparation for enterprise distribution")
|
||||
</MudText>
|
||||
|
||||
<MudButton StartIcon="@Icons.Material.Filled.FileDownload" Disabled="@this.IsNoPolicySelectedOrProtected" Variant="Variant.Filled" Color="Color.Primary">
|
||||
<MudButton StartIcon="@Icons.Material.Filled.FileDownload" Disabled="@this.IsNoPolicySelectedOrProtected" Variant="Variant.Filled" Color="Color.Primary" OnClick="@this.ExportPolicyAsConfiguration">
|
||||
@T("Export policy as configuration section")
|
||||
</MudButton>
|
||||
|
||||
@ -90,7 +90,7 @@ else
|
||||
@T("Documents for the analysis")
|
||||
</MudText>
|
||||
|
||||
<AttachDocuments Name="Document Analysis Files Drop" @bind-DocumentPaths="@this.loadedDocumentPaths"/>
|
||||
<AttachDocuments Name="Document Analysis Files Drop" @bind-DocumentPaths="@this.loadedDocumentPaths" CatchAllDocuments="true"/>
|
||||
|
||||
</ExpansionPanel>
|
||||
|
||||
|
||||
@ -29,21 +29,21 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.Append("# Task description");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
|
||||
if (this.loadedDocumentPaths.Count > 1)
|
||||
{
|
||||
sb.Append($"Your task is to analyse {this.loadedDocumentPaths.Count} documents.");
|
||||
sb.Append("Different Documents are divided by a horizontal rule in markdown formatting followed by the name of the document.");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("Your task is to analyse a single document.");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
var taskDescription = $"""
|
||||
var taskDescription = """
|
||||
The analysis should be done using the policy analysis rules.
|
||||
The output should be formatted according to the policy output rules.
|
||||
The rule sets should be followed strictly.
|
||||
@ -55,10 +55,9 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
""";
|
||||
|
||||
sb.Append(taskDescription);
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
|
||||
sb.Append(this.PromptGetActivePolicy());
|
||||
sb.Append(Environment.NewLine);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
@ -304,20 +303,18 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
private async Task<string> PromptLoadDocumentsContent()
|
||||
{
|
||||
if (this.loadedDocumentPaths.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var count = 1;
|
||||
foreach(var documentPath in this.loadedDocumentPaths)
|
||||
{
|
||||
sb.Append("---");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
sb.Append($"Document {count} file path: {documentPath}");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
sb.Append($"Document {count} content:");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
|
||||
var fileContent = await this.RustService.ReadArbitraryFileData(documentPath, int.MaxValue);
|
||||
sb.Append($"""
|
||||
@ -325,8 +322,8 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
{fileContent}
|
||||
```
|
||||
""");
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
count += 1;
|
||||
}
|
||||
|
||||
@ -335,8 +332,8 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
|
||||
private async Task Analyze()
|
||||
{
|
||||
if (this.IsNoPolicySelectedOrProtected)
|
||||
return;
|
||||
// if (this.IsNoPolicySelectedOrProtected)
|
||||
// return;
|
||||
|
||||
await this.AutoSave();
|
||||
await this.form!.Validate();
|
||||
@ -352,4 +349,18 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<SettingsDialo
|
||||
|
||||
await this.AddAIResponseAsync(userRequest);
|
||||
}
|
||||
|
||||
private async Task ExportPolicyAsConfiguration()
|
||||
{
|
||||
return;
|
||||
|
||||
# warning Implement the export function
|
||||
// do not allow the export of a protected policy
|
||||
if (this.IsNoPolicySelectedOrProtected)
|
||||
return;
|
||||
|
||||
await this.AutoSave();
|
||||
await this.form!.Validate();
|
||||
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,12 @@ public partial class AttachDocuments : MSGComponentBase
|
||||
[Parameter]
|
||||
public Func<HashSet<string>, Task> OnChange { get; set; } = _ => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Catch all documents that are hovered over the AI Studio window and not only over the drop zone.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool CatchAllDocuments { get; set; }
|
||||
|
||||
[Inject]
|
||||
private ILogger<AttachDocuments> Logger { get; set; } = null!;
|
||||
|
||||
@ -38,7 +44,7 @@ public partial class AttachDocuments : MSGComponentBase
|
||||
switch (triggeredEvent)
|
||||
{
|
||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_HOVERED }:
|
||||
if(!this.isComponentHovered)
|
||||
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
||||
{
|
||||
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop hovered event.", this.Name);
|
||||
return;
|
||||
@ -49,7 +55,7 @@ public partial class AttachDocuments : MSGComponentBase
|
||||
break;
|
||||
|
||||
case Event.TAURI_EVENT_RECEIVED when data is TauriEvent { EventType: TauriEventType.FILE_DROP_DROPPED, Payload: var paths }:
|
||||
if(!this.isComponentHovered)
|
||||
if(!this.isComponentHovered && !this.CatchAllDocuments)
|
||||
{
|
||||
this.Logger.LogDebug("Attach documents component '{Name}' is not hovered, ignoring file drop dropped event.", this.Name);
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user