mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 04:00:21 +00:00 
			
		
		
		
	Add a PDF content reader component with file selection support
This commit is contained in:
		
							parent
							
								
									7d64767cd3
								
							
						
					
					
						commit
						4c88e8a63b
					
				@ -631,6 +631,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can
 | 
				
			|||||||
-- Provider
 | 
					-- Provider
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Use PDF content as input
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T2849276709"] = "Use PDF content as input"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Select PDF file
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T63272795"] = "Select PDF file"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- 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.
 | 
					-- 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.
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "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."
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "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."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								app/MindWork AI Studio/Components/ReadPDFContent.razor
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								app/MindWork AI Studio/Components/ReadPDFContent.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">
 | 
				
			||||||
 | 
					    @T("Use PDF content as input")
 | 
				
			||||||
 | 
					</MudButton>
 | 
				
			||||||
							
								
								
									
										33
									
								
								app/MindWork AI Studio/Components/ReadPDFContent.razor.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								app/MindWork AI Studio/Components/ReadPDFContent.razor.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					using AIStudio.Tools.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Microsoft.AspNetCore.Components;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace AIStudio.Components;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public partial class ReadPDFContent : MSGComponentBase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [Parameter]
 | 
				
			||||||
 | 
					    public string PDFContent { get; set; } = string.Empty;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    [Parameter]
 | 
				
			||||||
 | 
					    public EventCallback<string> PDFContentChanged { get; set; }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    [Inject]
 | 
				
			||||||
 | 
					    private RustService RustService { get; init; } = null!;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private async Task SelectFile()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        var pdfFile = await this.RustService.SelectFile(T("Select PDF file"));
 | 
				
			||||||
 | 
					        if (pdfFile.UserCancelled)
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!pdfFile.SelectedFilePath.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase))
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if(!File.Exists(pdfFile.SelectedFilePath))
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        var pdfText = await this.RustService.GetPDFText(pdfFile.SelectedFilePath);
 | 
				
			||||||
 | 
					        await this.PDFContentChanged.InvokeAsync(pdfText);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
@inherits MSGComponentBase
 | 
					@inherits MSGComponentBase
 | 
				
			||||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
 | 
					<MudPaper Class="pa-3 mb-3 border-dashed border rounded-lg">
 | 
				
			||||||
    <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")" />
 | 
					    <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")" />
 | 
				
			||||||
    @if (this.showWebContentReader)
 | 
					    @if (this.showWebContentReader)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -633,6 +633,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "Hier ka
 | 
				
			|||||||
-- Provider
 | 
					-- Provider
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Anbieter"
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Anbieter"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Use PDF content as input
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T2849276709"] = "PDF-Inhalt als Eingabe verwenden"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Select PDF file
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T63272795"] = "PDF-Datei auswählen"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- 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.
 | 
					-- 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.
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "Der Inhalt wird mithilfe eines LLM-Agents bereinigt: Der Hauptinhalt wird extrahiert, Werbung und andere irrelevante Elemente werden nach Möglichkeit entfernt. Relative Links werden nach Möglichkeit in absolute Links umgewandelt, damit sie verwendet werden können."
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "Der Inhalt wird mithilfe eines LLM-Agents bereinigt: Der Hauptinhalt wird extrahiert, Werbung und andere irrelevante Elemente werden nach Möglichkeit entfernt. Relative Links werden nach Möglichkeit in absolute Links umgewandelt, damit sie verwendet werden können."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -633,6 +633,12 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can
 | 
				
			|||||||
-- Provider
 | 
					-- Provider
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Use PDF content as input
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T2849276709"] = "Use PDF content as input"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Select PDF file
 | 
				
			||||||
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READPDFCONTENT::T63272795"] = "Select PDF file"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- 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.
 | 
					-- 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.
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "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."
 | 
					UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T1164201762"] = "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."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2519,3 +2525,4 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T3948127789"] = "Suggestion"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- Your stage directions
 | 
					-- Your stage directions
 | 
				
			||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
 | 
					UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user