Skip to content

Commit 4e167d5

Browse files
Fixed bugs in & related to the web content reader (#549)
Co-authored-by: Thorsten Sommer <mail@tsommer.org>
1 parent f61fe87 commit 4e167d5

File tree

9 files changed

+63
-20
lines changed

9 files changed

+63
-20
lines changed

app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@if (!this.SettingsManager.ConfigurationData.LegalCheck.HideWebContentReader)
55
{
6-
<ReadWebContent @bind-Content="@this.inputLegalDocument" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" Preselect="@(this.SettingsManager.ConfigurationData.LegalCheck.PreselectOptions && this.SettingsManager.ConfigurationData.LegalCheck.PreselectWebContentReader)" PreselectContentCleanerAgent="@(this.SettingsManager.ConfigurationData.LegalCheck.PreselectOptions && this.SettingsManager.ConfigurationData.LegalCheck.PreselectContentCleanerAgent)"/>
6+
<ReadWebContent @bind-Content="@this.inputLegalDocument" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" @bind-Preselect="@this.showWebContentReader" @bind-PreselectContentCleanerAgent="@this.useContentCleanerAgent"/>
77
}
88

99
<ReadFileContent @bind-FileContent="@this.inputLegalDocument"/>

app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,27 @@ protected override void ResetForm()
3737
{
3838
this.inputLegalDocument = string.Empty;
3939
this.inputQuestions = string.Empty;
40-
this.MightPreselectValues();
40+
if (!this.MightPreselectValues())
41+
{
42+
this.showWebContentReader = false;
43+
this.useContentCleanerAgent = false;
44+
}
45+
}
46+
47+
protected override bool MightPreselectValues()
48+
{
49+
if (this.SettingsManager.ConfigurationData.LegalCheck.PreselectOptions)
50+
{
51+
this.showWebContentReader = this.SettingsManager.ConfigurationData.LegalCheck.PreselectWebContentReader;
52+
this.useContentCleanerAgent = this.SettingsManager.ConfigurationData.LegalCheck.PreselectContentCleanerAgent;
53+
return true;
54+
}
55+
56+
return false;
4157
}
42-
43-
protected override bool MightPreselectValues() => false;
4458

59+
private bool showWebContentReader;
60+
private bool useContentCleanerAgent;
4561
private bool isAgentRunning;
4662
private string inputLegalDocument = string.Empty;
4763
private string inputQuestions = string.Empty;

app/MindWork AI Studio/Assistants/TextSummarizer/AssistantTextSummarizer.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@if (!this.SettingsManager.ConfigurationData.TextSummarizer.HideWebContentReader)
55
{
6-
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" Preselect="@(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions && this.SettingsManager.ConfigurationData.TextSummarizer.PreselectWebContentReader)" PreselectContentCleanerAgent="@(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions && this.SettingsManager.ConfigurationData.TextSummarizer.PreselectContentCleanerAgent)"/>
6+
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" @bind-Preselect="@this.showWebContentReader" @bind-PreselectContentCleanerAgent="@this.useContentCleanerAgent"/>
77
}
88

99
<ReadFileContent @bind-FileContent="@this.inputText"/>

app/MindWork AI Studio/Assistants/TextSummarizer/AssistantTextSummarizer.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected override void ResetForm()
4040
this.inputText = string.Empty;
4141
if(!this.MightPreselectValues())
4242
{
43+
this.showWebContentReader = false;
44+
this.useContentCleanerAgent = false;
4345
this.selectedTargetLanguage = CommonLanguages.AS_IS;
4446
this.customTargetLanguage = string.Empty;
4547
this.selectedComplexity = Complexity.NO_CHANGE;
@@ -52,6 +54,8 @@ protected override bool MightPreselectValues()
5254
{
5355
if (this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions)
5456
{
57+
this.showWebContentReader = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectWebContentReader;
58+
this.useContentCleanerAgent = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectContentCleanerAgent;
5559
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedTargetLanguage;
5660
this.customTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedOtherLanguage;
5761
this.selectedComplexity = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedComplexity;
@@ -63,6 +67,8 @@ protected override bool MightPreselectValues()
6367
return false;
6468
}
6569

70+
private bool showWebContentReader;
71+
private bool useContentCleanerAgent;
6672
private string inputText = string.Empty;
6773
private bool isAgentRunning;
6874
private CommonLanguages selectedTargetLanguage;

app/MindWork AI Studio/Assistants/Translation/AssistantTranslation.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@if (!this.SettingsManager.ConfigurationData.Translation.HideWebContentReader)
55
{
6-
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" Preselect="@(this.SettingsManager.ConfigurationData.Translation.PreselectOptions && this.SettingsManager.ConfigurationData.Translation.PreselectWebContentReader)" PreselectContentCleanerAgent="@(this.SettingsManager.ConfigurationData.Translation.PreselectOptions && this.SettingsManager.ConfigurationData.Translation.PreselectContentCleanerAgent)"/>
6+
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" @bind-Preselect="@this.showWebContentReader" @bind-PreselectContentCleanerAgent="@this.useContentCleanerAgent"/>
77
}
88

99
<ReadFileContent @bind-FileContent="@this.inputText"/>

app/MindWork AI Studio/Assistants/Translation/AssistantTranslation.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected override void ResetForm()
4040
this.inputTextLastTranslation = string.Empty;
4141
if (!this.MightPreselectValues())
4242
{
43+
this.showWebContentReader = false;
44+
this.useContentCleanerAgent = false;
4345
this.liveTranslation = false;
4446
this.selectedTargetLanguage = CommonLanguages.AS_IS;
4547
this.customTargetLanguage = string.Empty;
@@ -50,6 +52,8 @@ protected override bool MightPreselectValues()
5052
{
5153
if (this.SettingsManager.ConfigurationData.Translation.PreselectOptions)
5254
{
55+
this.showWebContentReader = this.SettingsManager.ConfigurationData.Translation.PreselectWebContentReader;
56+
this.useContentCleanerAgent = this.SettingsManager.ConfigurationData.Translation.PreselectContentCleanerAgent;
5357
this.liveTranslation = this.SettingsManager.ConfigurationData.Translation.PreselectLiveTranslation;
5458
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectedTargetLanguage;
5559
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectOtherLanguage;
@@ -59,6 +63,8 @@ protected override bool MightPreselectValues()
5963
return false;
6064
}
6165

66+
private bool showWebContentReader;
67+
private bool useContentCleanerAgent;
6268
private bool liveTranslation;
6369
private bool isAgentRunning;
6470
private string inputText = string.Empty;

app/MindWork AI Studio/Components/ReadWebContent.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@inherits MSGComponentBase
22
<MudPaper Class="pa-3 mb-3 border-dashed border rounded-lg">
3-
<MudTextSwitch Label="@T("Read content from web?")" Disabled="@this.AgentIsRunning" @bind-Value="@this.showWebContentReader" LabelOn="@T("Show web content options")" LabelOff="@T("Hide web content options")" />
4-
@if (this.showWebContentReader)
3+
<MudTextSwitch Label="@T("Read content from web?")" Disabled="@this.AgentIsRunning" Value="@this.Preselect" ValueChanged="@this.ShowWebContentReaderChanged" LabelOn="@T("Show web content options")" LabelOff="@T("Hide web content options")" />
4+
@if (this.Preselect)
55
{
6-
<MudTextSwitch Label="@T("Cleanup content by using an LLM agent?")" @bind-Value="@this.useContentCleanerAgent" Validation="@this.ValidateProvider" Disabled="@this.AgentIsRunning" LabelOn="@T("The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used.")" LabelOff="@T("No content cleaning")" />
6+
<MudTextSwitch Label="@T("Cleanup content by using an LLM agent?")" Value="@this.PreselectContentCleanerAgent" ValueChanged="@this.UseContentCleanerAgentChanged" Validation="@this.ValidateProvider" Disabled="@this.AgentIsRunning" LabelOn="@T("The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used.")" LabelOff="@T("No content cleaning")" />
77
<MudStack Row="@true" AlignItems="@AlignItems.Baseline" Class="mb-3">
88
<MudTextField T="string" Label="@T("URL from which to load the content")" @bind-Value="@this.providedURL" Validation="@this.ValidateURL" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Link" Placeholder="https://..." HelperText="@T("Loads the content from your URL. Does not work when the content is hidden behind a paywall.")" Variant="Variant.Outlined" Immediate="@true" Disabled="@this.AgentIsRunning"/>
99
<MudButton Disabled="@(!this.IsReady || this.AgentIsRunning)" Variant="Variant.Filled" Size="Size.Large" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Download" OnClick="() => this.LoadFromWeb()">

app/MindWork AI Studio/Components/ReadWebContent.razor.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ public partial class ReadWebContent : MSGComponentBase
3131
[Parameter]
3232
public bool Preselect { get; set; }
3333

34+
[Parameter]
35+
public EventCallback<bool> PreselectChanged { get; set; }
36+
3437
[Parameter]
3538
public bool PreselectContentCleanerAgent { get; set; }
39+
40+
[Parameter]
41+
public EventCallback<bool> PreselectContentCleanerAgentChanged { get; set; }
3642

3743
private readonly Process<ReadWebContentSteps> process = Process<ReadWebContentSteps>.INSTANCE;
3844
private ProcessStepValue processStep;
3945

40-
private bool showWebContentReader;
41-
private bool useContentCleanerAgent;
4246
private string providedURL = string.Empty;
4347
private bool urlIsValid;
4448
private bool isProviderValid;
@@ -49,13 +53,10 @@ public partial class ReadWebContent : MSGComponentBase
4953

5054
protected override async Task OnInitializedAsync()
5155
{
52-
if(this.Preselect)
53-
this.showWebContentReader = true;
54-
55-
if(this.PreselectContentCleanerAgent)
56-
this.useContentCleanerAgent = true;
57-
5856
this.ProviderSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.AGENT_TEXT_CONTENT_CLEANER, this.ProviderSettings.Id, true);
57+
this.providerSettings = this.ProviderSettings;
58+
this.ValidateProvider(this.PreselectContentCleanerAgent);
59+
5960
await base.OnInitializedAsync();
6061
}
6162

@@ -64,6 +65,7 @@ protected override async Task OnParametersSetAsync()
6465
if (!this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)
6566
this.providerSettings = this.ProviderSettings;
6667

68+
this.ValidateProvider(this.PreselectContentCleanerAgent);
6769
await base.OnParametersSetAsync();
6870
}
6971

@@ -86,7 +88,7 @@ private async Task LoadFromWeb()
8688
this.StateHasChanged();
8789
markdown = this.HTMLParser.ParseToMarkdown(html);
8890

89-
if (this.useContentCleanerAgent && this.providerSettings != AIStudio.Settings.Provider.NONE)
91+
if (this.PreselectContentCleanerAgent && this.providerSettings != AIStudio.Settings.Provider.NONE)
9092
{
9193
this.AgentTextContentCleaner.ProviderSettings = this.providerSettings;
9294
var additionalData = new Dictionary<string, string>
@@ -140,13 +142,23 @@ private bool IsReady
140142
if(!this.urlIsValid)
141143
return false;
142144

143-
if(this.useContentCleanerAgent && !this.isProviderValid)
145+
if(this.PreselectContentCleanerAgent && !this.isProviderValid)
144146
return false;
145147

146148
return true;
147149
}
148150
}
149151

152+
private async Task ShowWebContentReaderChanged(bool state)
153+
{
154+
await this.PreselectChanged.InvokeAsync(state);
155+
}
156+
157+
private async Task UseContentCleanerAgentChanged(bool state)
158+
{
159+
await this.PreselectContentCleanerAgentChanged.InvokeAsync(state);
160+
}
161+
150162
private string? ValidateProvider(bool shouldUseAgent)
151163
{
152164
if(shouldUseAgent && this.providerSettings == AIStudio.Settings.Provider.NONE)

app/MindWork AI Studio/wwwroot/changelog/v0.9.51.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
- Changed the configuration plugin setting name for how often to check for updates from `UpdateBehavior` to `UpdateInterval`.
1313
- Fixed a bug in various assistants where some text fields were not reset when resetting.
1414
- Fixed the input field header in the dialog for naming chats and workspaces.
15-
- Fixed a rare chat-related bug that could occur when a workspace was not created correctly. Thank you, Naomi, for reporting this issue.
15+
- Fixed a rare chat-related bug that could occur when a workspace was not created correctly. Thank you, Naomi, for reporting this issue.
16+
- Fixed a bug in the web content reader where a preconfigured LLM provider was not recognized, resulting in an error message.
17+
- Fixed another bug in the web content reader: the system incorrectly evaluated whether the content cleaning agent was preselected. Users had to first deactivate the agent and then reactivate it to make it work correctly.
18+
- Fixed a bug in the assistants for text summarization, translations, and legal check: the web content reader preferences were not being applied when resetting the assistant.

0 commit comments

Comments
 (0)