Ensure that the ERI workspace is present & create bias workspace only when needed

This commit is contained in:
Thorsten Sommer 2024-12-31 20:49:49 +01:00
parent f40222ea94
commit 07832061ef
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
5 changed files with 21 additions and 8 deletions

View File

@ -308,7 +308,7 @@ public partial class AssistantERI : AssistantBaseCore
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{ {
SystemPrompt = SystemPrompts.DEFAULT, SystemPrompt = this.SystemPrompt,
}; };
protected override void ResetForm() protected override void ResetForm()
@ -920,7 +920,8 @@ public partial class AssistantERI : AssistantBaseCore
return; return;
} }
this.CreateChatThread(); var now = DateTimeOffset.UtcNow;
this.CreateChatThread(KnownWorkspaces.ERI_SERVER_WORKSPACE_ID, $"{now:yyyy-MM-dd HH:mm} - {this.serverName}");
// //
// --------------------------------- // ---------------------------------
@ -971,5 +972,7 @@ public partial class AssistantERI : AssistantBaseCore
""", true); """, true);
await this.AddAIResponseAsync(time); await this.AddAIResponseAsync(time);
} }
await this.SendToAssistant(Tools.Components.CHAT, default);
} }
} }

View File

@ -3,4 +3,5 @@ namespace AIStudio.Chat;
public static class KnownWorkspaces public static class KnownWorkspaces
{ {
public static readonly Guid BIAS_WORKSPACE_ID = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02"); public static readonly Guid BIAS_WORKSPACE_ID = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02");
public static readonly Guid ERI_SERVER_WORKSPACE_ID = Guid.Parse("8ec09cd3-9da7-4736-b245-2d8b67fc342f");
} }

View File

@ -61,9 +61,6 @@ 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)
@ -88,6 +85,13 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
{ {
this.autoSaveEnabled = true; this.autoSaveEnabled = true;
this.mustStoreChat = true; this.mustStoreChat = true;
// Ensure the workspace exists:
if(this.chatThread.WorkspaceId == KnownWorkspaces.ERI_SERVER_WORKSPACE_ID)
await WorkspaceBehaviour.EnsureERIServerWorkspace();
else if (this.chatThread.WorkspaceId == KnownWorkspaces.BIAS_WORKSPACE_ID)
await WorkspaceBehaviour.EnsureBiasWorkspace();
} }
} }

View File

@ -118,15 +118,19 @@ public static class WorkspaceBehaviour
Directory.Delete(chatDirectory, true); Directory.Delete(chatDirectory, true);
} }
public static async Task EnsureBiasWorkspace() private static async Task EnsureWorkspace(Guid workspaceId, string workspaceName)
{ {
var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", KnownWorkspaces.BIAS_WORKSPACE_ID.ToString()); var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", workspaceId.ToString());
if(Path.Exists(workspacePath)) if(Path.Exists(workspacePath))
return; return;
Directory.CreateDirectory(workspacePath); Directory.CreateDirectory(workspacePath);
var workspaceNamePath = Path.Join(workspacePath, "name"); var workspaceNamePath = Path.Join(workspacePath, "name");
await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8); await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8);
} }
public static async Task EnsureBiasWorkspace() => await EnsureWorkspace(KnownWorkspaces.BIAS_WORKSPACE_ID, "Bias of the Day");
public static async Task EnsureERIServerWorkspace() => await EnsureWorkspace(KnownWorkspaces.ERI_SERVER_WORKSPACE_ID, "ERI Servers");
} }

View File

@ -1,5 +1,6 @@
# 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.
- Improved the creation of the "the bias of the day" workspace; create that workspace only when the bias of the day feature is used.
- 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. - Fixed a bug about the bias of the day workspace when the workspace component was hidden.