mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-28 18:02:57 +00:00
add a new component for the extraction of arbitrary file data
This commit is contained in:
parent
2ce863ebd6
commit
9fc3213603
4
app/MindWork AI Studio/Components/ReadFileContent.razor
Normal file
4
app/MindWork AI Studio/Components/ReadFileContent.razor
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@inherits MSGComponentBase
|
||||||
|
<MudButton StartIcon="@Icons.Material.Filled.Description" OnClick="async () => await this.SelectFile()" Variant="Variant.Filled" Class="mb-3">
|
||||||
|
Use PDF content as input"
|
||||||
|
</MudButton>
|
32
app/MindWork AI Studio/Components/ReadFileContent.razor.cs
Normal file
32
app/MindWork AI Studio/Components/ReadFileContent.razor.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using AIStudio.Tools.Rust;
|
||||||
|
using AIStudio.Tools.Services;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
|
public partial class ReadFileContent : MSGComponentBase
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public string FileContent { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<string> FileContentChanged { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
|
private async Task SelectFile()
|
||||||
|
{
|
||||||
|
var txtFile = await this.RustService.SelectFile("Select Text file");
|
||||||
|
if (txtFile.UserCancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!File.Exists(txtFile.SelectedFilePath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var txtContent = await this.RustService.ReadArbitraryFileData(txtFile.SelectedFilePath, int.MaxValue);
|
||||||
|
|
||||||
|
await this.FileContentChanged.InvokeAsync(txtContent);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user