mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 08:19:47 +00:00
Added a function to load a text file
This commit is contained in:
parent
b632854cd4
commit
01eb99096e
@ -8,6 +8,9 @@
|
|||||||
<PreviewExperimental ApplyInnerScrollingFix="true"/>
|
<PreviewExperimental ApplyInnerScrollingFix="true"/>
|
||||||
|
|
||||||
<ProviderSelection @bind-ProviderSettings="@this.providerSettings"/>
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings"/>
|
||||||
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Download" OnClick="@(() => this.LoadTextFile())" Color="Color.Primary" Class="mb-2">
|
||||||
|
Load a text file
|
||||||
|
</MudButton>
|
||||||
<InnerScrolling>
|
<InnerScrolling>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<MudTextField
|
<MudTextField
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Components;
|
using AIStudio.Components;
|
||||||
using AIStudio.Provider;
|
using AIStudio.Provider;
|
||||||
|
using AIStudio.Tools.Services;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
@ -14,6 +17,9 @@ public partial class Writer : MSGComponentBase, IAsyncDisposable
|
|||||||
[Inject]
|
[Inject]
|
||||||
private ILogger<Chat> Logger { get; init; } = null!;
|
private ILogger<Chat> Logger { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
||||||
|
|
||||||
@ -56,6 +62,19 @@ public partial class Writer : MSGComponentBase, IAsyncDisposable
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private bool IsProviderSelected => this.providerSettings.UsedLLMProvider != LLMProviders.NONE;
|
private bool IsProviderSelected => this.providerSettings.UsedLLMProvider != LLMProviders.NONE;
|
||||||
|
|
||||||
|
private async Task LoadTextFile()
|
||||||
|
{
|
||||||
|
var result = await this.RustService.SelectFile("Load a text file");
|
||||||
|
if(result.UserCancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!File.Exists(result.SelectedFilePath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var text = await File.ReadAllTextAsync(result.SelectedFilePath, Encoding.UTF8);
|
||||||
|
this.userInput = text;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task InputKeyEvent(KeyboardEventArgs keyEvent)
|
private async Task InputKeyEvent(KeyboardEventArgs keyEvent)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user