2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								using  AIStudio.Chat ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 10:31:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								using  AIStudio.Dialogs.Settings ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-21 06:30:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								namespace  AIStudio.Assistants.TextSummarizer ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 10:31:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								public  partial  class  AssistantTextSummarizer  :  AssistantBaseCore < SettingsDialogTextSummarizer > 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-14 17:20:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  override  Tools . Components  Component  = >  Tools . Components . TEXT_SUMMARIZER_ASSISTANT ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 13:44:23 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  Title  = >  T ( "Text Summarizer" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  Description  = >  T ( "Summarize long text into a shorter version while retaining the main points. You might want to change the language of the summary to make it more readable. It is also possible to change the complexity of the summary to make it easy to understand." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  string  SystemPrompt  = >  
							 
						 
					
						
							
								
									
										
										
										
											2025-08-30 08:35:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $"" "
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         You  get  a  long  text  as  input .  The  text  is  marked  with  ` ` ` .  The  user  wants  to  get  a  summary  of  the  text . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         { this . selectedTargetLanguage . PromptSummarizing ( this . customTargetLanguage ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         { this . selectedComplexity . Prompt ( this . expertInField ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         { this . PromptImportantAspects ( ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         In  any  case ,  only  use  information  that  is  provided  in  the  text  for  the  summary . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         "" ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 19:01:51 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  bool  AllowProfiles  = >  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2024-09-04 13:44:23 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  IReadOnlyList < IButtonData >  FooterButtons  = >  [ ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 10:32:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  SubmitText  = >  T ( "Summarize" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-11 21:08:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  Func < Task >  SubmitAction  = >  this . SummarizeText ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 10:31:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-11 21:08:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  bool  SubmitDisabled  = >  this . isAgentRunning ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  ChatThread  ConvertToChatThread  = >  ( this . chatThread  ? ?  new ( ) )  with 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        SystemPrompt  =  SystemPrompts . DEFAULT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-01-01 14:49:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  void  ResetForm ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        this . inputText  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( ! this . MightPreselectValues ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-01 17:13:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . showWebContentReader  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . useContentCleanerAgent  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . selectedTargetLanguage  =  CommonLanguages . AS_IS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . customTargetLanguage  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . selectedComplexity  =  Complexity . NO_CHANGE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . expertInField  =  string . Empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-30 08:35:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . importantAspects  =  string . Empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  bool  MightPreselectValues ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( this . SettingsManager . ConfigurationData . TextSummarizer . PreselectOptions ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2025-09-01 17:13:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . showWebContentReader  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectWebContentReader ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . useContentCleanerAgent  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectContentCleanerAgent ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . selectedTargetLanguage  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectedTargetLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . customTargetLanguage  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectedOtherLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . selectedComplexity  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectedComplexity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . expertInField  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectedExpertInField ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-30 08:35:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            this . importantAspects  =  this . SettingsManager . ConfigurationData . TextSummarizer . PreselectedImportantAspects ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 19:48:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-09-01 17:13:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  bool  showWebContentReader ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  bool  useContentCleanerAgent ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    private  string  inputText  =  string . Empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 19:53:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  bool  isAgentRunning ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    private  CommonLanguages  selectedTargetLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string  customTargetLanguage  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  Complexity  selectedComplexity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string  expertInField  =  string . Empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-30 08:35:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  string  importantAspects  =  string . Empty ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-28 09:20:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    #region  Overrides  of  ComponentBase 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  async  Task  OnInitializedAsync ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 10:32:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        var  deferredContent  =  MessageBus . INSTANCE . CheckDeferredMessages < string > ( Event . SEND_TO_TEXT_SUMMARIZER_ASSISTANT ) . FirstOrDefault ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( deferredContent  is  not  null ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . inputText  =  deferredContent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2024-07-28 09:20:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        await  base . OnInitializedAsync ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #endregion 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    private  string?  ValidatingText ( string  text ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( string . IsNullOrWhiteSpace ( text ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  T ( "Please provide a text as input. You might copy the desired text from a document or a website." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string?  ValidateCustomLanguage ( string  language ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( this . selectedTargetLanguage  = =  CommonLanguages . OTHER  & &  string . IsNullOrWhiteSpace ( language ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  T ( "Please provide a custom language." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string?  ValidateExpertInField ( string  field ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( this . selectedComplexity  = =  Complexity . SCIENTIFIC_LANGUAGE_OTHER_EXPERTS  & &  string . IsNullOrWhiteSpace ( field ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  T ( "Please provide your field of expertise." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-30 08:35:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    private  string  PromptImportantAspects ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( string . IsNullOrWhiteSpace ( this . importantAspects ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  $"" "
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                Emphasize  the  following  aspects  in  your  summary : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                { this . importantAspects } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                "" ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-14 19:46:17 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    private  async  Task  SummarizeText ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  this . form ! . Validate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! this . inputIsValid ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        this . CreateChatThread ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        var  time  =  this . AddUserRequest ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $"" "
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                Please  summarize  the  following  text : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ` ` ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                { this . inputText } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ` ` ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             "" ");
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  this . AddAIResponseAsync ( time ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}