diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor b/app/MindWork AI Studio/Components/AttachDocuments.razor
index aea32e75..bc66f9c2 100644
--- a/app/MindWork AI Studio/Components/AttachDocuments.razor
+++ b/app/MindWork AI Studio/Components/AttachDocuments.razor
@@ -68,9 +68,9 @@ else
- @foreach (var filePath in this.DocumentPaths)
+ @foreach (var fileAttachment in this.DocumentPaths)
{
-
+
}
diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
index 942ce861..a647876e 100644
--- a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
+++ b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs
@@ -1,3 +1,4 @@
+using AIStudio.Chat;
using AIStudio.Dialogs;
using AIStudio.Tools.PluginSystem;
using AIStudio.Tools.Rust;
@@ -16,15 +17,15 @@ public partial class AttachDocuments : MSGComponentBase
[Parameter]
public string Name { get; set; } = string.Empty;
-
+
[Parameter]
- public HashSet DocumentPaths { get; set; } = [];
-
+ public HashSet DocumentPaths { get; set; } = [];
+
[Parameter]
- public EventCallback> DocumentPathsChanged { get; set; }
-
+ public EventCallback> DocumentPathsChanged { get; set; }
+
[Parameter]
- public Func, Task> OnChange { get; set; } = _ => Task.CompletedTask;
+ public Func, Task> OnChange { get; set; } = _ => Task.CompletedTask;
///
/// Catch all documents that are hovered over the AI Studio window and not only over the drop zone.
@@ -116,7 +117,7 @@ public partial class AttachDocuments : MSGComponentBase
if(!await FileExtensionValidation.IsExtensionValidWithNotifyAsync(path))
continue;
- this.DocumentPaths.Add(path);
+ this.DocumentPaths.Add(FileAttachment.FromPath(path));
}
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
@@ -160,7 +161,7 @@ public partial class AttachDocuments : MSGComponentBase
if (!await FileExtensionValidation.IsExtensionValidWithNotifyAsync(selectedFilePath))
continue;
- this.DocumentPaths.Add(selectedFilePath);
+ this.DocumentPaths.Add(FileAttachment.FromPath(selectedFilePath));
}
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
@@ -199,23 +200,23 @@ public partial class AttachDocuments : MSGComponentBase
this.StateHasChanged();
}
- private async Task RemoveDocument(string filePath)
+ private async Task RemoveDocument(FileAttachment fileAttachment)
{
- this.DocumentPaths.Remove(filePath);
-
+ this.DocumentPaths.Remove(fileAttachment);
+
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
await this.OnChange(this.DocumentPaths);
}
///
- /// The user might want to check what we actually extract from his file and therefore give the LLM as an input.
+ /// The user might want to check what we actually extract from his file and therefore give the LLM as an input.
///
- /// The file to check.
- private async Task InvestigateFile(string filePath)
+ /// The file to check.
+ private async Task InvestigateFile(FileAttachment fileAttachment)
{
var dialogParameters = new DialogParameters
{
- { x => x.FilePath, filePath },
+ { x => x.FilePath, fileAttachment.FilePath },
};
await this.DialogService.ShowAsync(T("Document Preview"), dialogParameters, DialogOptions.FULLSCREEN);
diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs
index 2562c7b4..44b3dafa 100644
--- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs
+++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs
@@ -57,7 +57,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
private string currentWorkspaceName = string.Empty;
private Guid currentWorkspaceId = Guid.Empty;
private CancellationTokenSource? cancellationTokenSource;
- private HashSet chatDocumentPaths = [];
+ private HashSet chatDocumentPaths = [];
// Unfortunately, we need the input field reference to blur the focus away. Without
// this, we cannot clear the input field.
@@ -464,7 +464,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
lastUserPrompt = new ContentText
{
Text = this.userInput,
- FileAttachments = this.chatDocumentPaths.ToList(),
+ FileAttachments = [..this.chatDocumentPaths],
};
//