Files
AI-Studio/app/MindWork AI Studio/Assistants/LastContentModeService.cs
T

30 lines
1.4 KiB
C#

using System.Collections.Concurrent;
namespace AIStudio.Assistants;
/// <summary>
/// Keeps what the user last chose to work on in each assistant which works on documents as well as on texts.
/// </summary>
/// <remarks>
/// It keeps the choices only until AI Studio quits, for the start option "Start with the last choice": an assistant
/// continues with what the user worked on before and asks again after a restart. A text which another assistant or
/// a chat sent to an assistant is no choice of the user.
/// </remarks>
public sealed class LastContentModeService
{
private readonly ConcurrentDictionary<Tools.Components, AssistantContentMode> lastModes = new();
/// <summary>
/// Notes what the user chose to work on in an assistant.
/// </summary>
/// <param name="assistant">The assistant.</param>
/// <param name="mode">What the user chose to work on.</param>
public void Remember(Tools.Components assistant, AssistantContentMode mode) => this.lastModes[assistant] = mode;
/// <summary>
/// Gets what the user last chose to work on in an assistant; undecided while the user chose nothing there since
/// AI Studio started.
/// </summary>
/// <param name="assistant">The assistant.</param>
public AssistantContentMode LastOf(Tools.Components assistant) => this.lastModes.GetValueOrDefault(assistant, AssistantContentMode.UNDECIDED);
}