mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 11:40:21 +00:00 
			
		
		
		
	Fixed a bias of the day workspace bug in case the workspace component was hidden
This commit is contained in:
		
							parent
							
								
									06bd412543
								
							
						
					
					
						commit
						f40222ea94
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using AIStudio.Components;
 | 
					using AIStudio.Chat;
 | 
				
			||||||
using AIStudio.Settings.DataModel;
 | 
					using AIStudio.Settings.DataModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace AIStudio.Assistants.BiasDay;
 | 
					namespace AIStudio.Assistants.BiasDay;
 | 
				
			||||||
@ -124,7 +124,7 @@ public partial class BiasOfTheDayAssistant : AssistantBaseCore
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                var biasChat = new LoadChat
 | 
					                var biasChat = new LoadChat
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    WorkspaceId = Workspaces.WORKSPACE_ID_BIAS,
 | 
					                    WorkspaceId = KnownWorkspaces.BIAS_WORKSPACE_ID,
 | 
				
			||||||
                    ChatId = this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayChatId,
 | 
					                    ChatId = this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayChatId,
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -147,7 +147,7 @@ public partial class BiasOfTheDayAssistant : AssistantBaseCore
 | 
				
			|||||||
            BiasCatalog.ALL_BIAS[this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayId] :
 | 
					            BiasCatalog.ALL_BIAS[this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayId] :
 | 
				
			||||||
            BiasCatalog.GetRandomBias(this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias);
 | 
					            BiasCatalog.GetRandomBias(this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        var chatId = this.CreateChatThread(Workspaces.WORKSPACE_ID_BIAS, this.biasOfTheDay.Name);
 | 
					        var chatId = this.CreateChatThread(KnownWorkspaces.BIAS_WORKSPACE_ID, this.biasOfTheDay.Name);
 | 
				
			||||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayId = this.biasOfTheDay.Id;
 | 
					        this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayId = this.biasOfTheDay.Id;
 | 
				
			||||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayChatId = chatId;
 | 
					        this.SettingsManager.ConfigurationData.BiasOfTheDay.BiasOfTheDayChatId = chatId;
 | 
				
			||||||
        this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.FromDateTime(DateTime.Now);
 | 
					        this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.FromDateTime(DateTime.Now);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								app/MindWork AI Studio/Chat/KnownWorkspaces.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/MindWork AI Studio/Chat/KnownWorkspaces.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					namespace AIStudio.Chat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public static class KnownWorkspaces
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public static readonly Guid BIAS_WORKSPACE_ID = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -39,8 +39,6 @@ public partial class Workspaces : ComponentBase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
 | 
					    private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static readonly Guid WORKSPACE_ID_BIAS = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private readonly List<TreeItemData<ITreeItem>> treeItems = new();
 | 
					    private readonly List<TreeItemData<ITreeItem>> treeItems = new();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    #region Overrides of ComponentBase
 | 
					    #region Overrides of ComponentBase
 | 
				
			||||||
@ -53,8 +51,6 @@ public partial class Workspaces : ComponentBase
 | 
				
			|||||||
        // - Those initial tree items cannot have children
 | 
					        // - Those initial tree items cannot have children
 | 
				
			||||||
        // - When assigning the tree items to the MudTreeViewItem component, we must set the Value property to the value of the item
 | 
					        // - When assigning the tree items to the MudTreeViewItem component, we must set the Value property to the value of the item
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        await this.EnsureBiasWorkspace();
 | 
					 | 
				
			||||||
        await this.LoadTreeItems();
 | 
					        await this.LoadTreeItems();
 | 
				
			||||||
        await base.OnInitializedAsync();
 | 
					        await base.OnInitializedAsync();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -408,18 +404,6 @@ public partial class Workspaces : ComponentBase
 | 
				
			|||||||
        await this.LoadTreeItems();
 | 
					        await this.LoadTreeItems();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private async Task EnsureBiasWorkspace()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", WORKSPACE_ID_BIAS.ToString());
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        if(Path.Exists(workspacePath))
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        Directory.CreateDirectory(workspacePath);
 | 
					 | 
				
			||||||
        var workspaceNamePath = Path.Join(workspacePath, "name");
 | 
					 | 
				
			||||||
        await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    private async Task DeleteWorkspace(string? workspacePath)
 | 
					    private async Task DeleteWorkspace(string? workspacePath)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(workspacePath is null)
 | 
					        if(workspacePath is null)
 | 
				
			||||||
 | 
				
			|||||||
@ -61,6 +61,9 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
 | 
				
			|||||||
        // Configure the spellchecking for the user input:
 | 
					        // Configure the spellchecking for the user input:
 | 
				
			||||||
        this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
 | 
					        this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Ensure the bias workspace exists:
 | 
				
			||||||
 | 
					        await WorkspaceBehaviour.EnsureBiasWorkspace();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT);
 | 
					        this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT);
 | 
				
			||||||
        var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
 | 
					        var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
 | 
				
			||||||
        if (deferredContent is not null)
 | 
					        if (deferredContent is not null)
 | 
				
			||||||
 | 
				
			|||||||
@ -117,4 +117,16 @@ public static class WorkspaceBehaviour
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        Directory.Delete(chatDirectory, true);
 | 
					        Directory.Delete(chatDirectory, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static async Task EnsureBiasWorkspace()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", KnownWorkspaces.BIAS_WORKSPACE_ID.ToString());
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if(Path.Exists(workspacePath))
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        Directory.CreateDirectory(workspacePath);
 | 
				
			||||||
 | 
					        var workspaceNamePath = Path.Join(workspacePath, "name");
 | 
				
			||||||
 | 
					        await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
# v0.9.23, build 198 (2024-12-xx xx:xx UTC)
 | 
					# v0.9.23, build 198 (2024-12-xx xx:xx UTC)
 | 
				
			||||||
- Added an ERI server coding assistant as a preview feature behind the RAG feature flag. This helps you implement an ERI server to gain access to, e.g., your enterprise data from within AI Studio.
 | 
					- Added an ERI server coding assistant as a preview feature behind the RAG feature flag. This helps you implement an ERI server to gain access to, e.g., your enterprise data from within AI Studio.
 | 
				
			||||||
- Improved provider requests by handling rate limits by retrying requests. 
 | 
					- Improved provider requests by handling rate limits by retrying requests. 
 | 
				
			||||||
- Fixed layout issues when selecting `other` items (e.g., programming languages)
 | 
					- Fixed layout issues when selecting `other` items (e.g., programming languages).
 | 
				
			||||||
 | 
					- Fixed a bug about the bias of the day workspace when the workspace component was hidden.
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user