2024-09-15 20:06:22 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								using  AIStudio.Chat ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 10:31:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								using  AIStudio.Dialogs.Settings ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								using  AIStudio.Settings ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  AIStudio.Assistants.MyTasks ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-12 10:31:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								public  partial  class  AssistantMyTasks  :  AssistantBaseCore < SettingsDialogMyTasks > 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-14 17:20:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  override  Tools . Components  Component  = >  Tools . Components . MY_TASKS_ASSISTANT ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  Title  = >  T ( "My Tasks" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  Description  = >  T ( "You received a cryptic email that was sent to many recipients and you are now wondering if you need to do something? Copy the email into the input field. You also need to select a personal profile. In this profile, you should describe your role in the organization. The AI will then try to give you hints on what your tasks might be." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  string  SystemPrompt  = >  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $"" "
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        You  are  a  friendly  and  professional  business  expert .  You  receive  business  emails ,  protocols , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        reports ,  etc .  as  input .  Additionally ,  you  know  the  user ' s  role  in  the  organization .  The  user 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        wonders  if  any  tasks  arise  for  them  in  their  role  based  on  the  text .  You  now  try  to  give  hints 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        and  advice  on  whether  and  what  the  user  should  do .  When  you  believe  there  are  no  tasks  for  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        user ,  you  tell  them  this .  You  consider  typical  business  etiquette  in  your  advice . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        You  write  your  advice  in  the  following  language :  { this . SystemPromptLanguage ( ) } . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "" ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  IReadOnlyList < IButtonData >  FooterButtons  = >  [ ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-11 21:08:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  string  SubmitText  = >  T ( "Analyze text" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-11 21:08:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  Func < Task >  SubmitAction  = >  this . AnalyzeText ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  bool  ShowProfileSelection  = >  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-15 20:06:22 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  ChatThread  ConvertToChatThread  = >  ( this . chatThread  ? ?  new ( ) )  with 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        SystemPrompt  =  SystemPrompts . DEFAULT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-01 14:49:27 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    protected  override  void  ResetForm ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        this . inputText  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! this . MightPreselectValues ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . selectedTargetLanguage  =  CommonLanguages . AS_IS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . customTargetLanguage  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  bool  MightPreselectValues ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( this . SettingsManager . ConfigurationData . MyTasks . PreselectOptions ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . selectedTargetLanguage  =  this . SettingsManager . ConfigurationData . MyTasks . PreselectedTargetLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . customTargetLanguage  =  this . SettingsManager . ConfigurationData . MyTasks . PreselectOtherLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string  inputText  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  CommonLanguages  selectedTargetLanguage  =  CommonLanguages . AS_IS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string  customTargetLanguage  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #region  Overrides  of  ComponentBase 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    protected  override  async  Task  OnInitializedAsync ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        var  deferredContent  =  MessageBus . INSTANCE . CheckDeferredMessages < string > ( Event . SEND_TO_MY_TASKS_ASSISTANT ) . FirstOrDefault ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( deferredContent  is  not  null ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            this . inputText  =  deferredContent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  base . OnInitializedAsync ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    #endregion 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string?  ValidatingText ( string  text ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( string . IsNullOrWhiteSpace ( text ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  T ( "Please provide some text as input. For example, an email." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string?  ValidateProfile ( Profile  profile ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( profile  = =  default  | |  profile  = =  Profile . NO_PROFILE ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-27 07:06:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return  T ( "Please select one of your profiles." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 13:08:16 +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-09-09 13:08:16 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  string  SystemPromptLanguage ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( this . selectedTargetLanguage  is  CommonLanguages . AS_IS ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  "Use the same language as the input" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if ( this . selectedTargetLanguage  is  CommonLanguages . OTHER ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  this . customTargetLanguage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  this . selectedTargetLanguage . Name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    private  async  Task  AnalyzeText ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  this . form ! . Validate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( ! this . inputIsValid ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        this . CreateChatThread ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        var  time  =  this . AddUserRequest ( this . inputText ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        await  this . AddAIResponseAsync ( time ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}