mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 02:07:21 +00:00
Added a way to read what the AI received from your sources (#1100)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
e0d8e18f34
commit
cbc4ce5413
229 files changed
+12739
-1269
No files matched your search
@@ -23,17 +23,17 @@ public sealed class TemporaryChatService(ILogger<TemporaryChatService> logger, S
|
||||
return;
|
||||
}
|
||||
|
||||
this.StartMaintenance();
|
||||
await this.StartMaintenanceAsync();
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(CHECK_INTERVAL, stoppingToken);
|
||||
this.StartMaintenance();
|
||||
await this.StartMaintenanceAsync();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void StartMaintenance()
|
||||
internal async Task StartMaintenanceAsync()
|
||||
{
|
||||
logger.LogInformation("Starting maintenance of temporary chat storage.");
|
||||
var temporaryDirectories = Path.Join(SettingsManager.DataDirectory, "tempChats");
|
||||
@@ -65,13 +65,42 @@ public sealed class TemporaryChatService(ILogger<TemporaryChatService> logger, S
|
||||
if(deleteChat)
|
||||
{
|
||||
logger.LogInformation($"Deleting temporary chat storage directory '{tempChatDirPath}' due to maintenance policy.");
|
||||
Directory.Delete(tempChatDirPath, true);
|
||||
WorkspaceBehaviour.InvalidateWorkspaceTreeCache();
|
||||
await this.DeleteTemporaryChatAsync(tempChatDirPath);
|
||||
}
|
||||
}
|
||||
|
||||
logger.LogInformation("Finished maintenance of temporary chat storage.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes one temporary chat the way the user deletes a chat, so that what it received goes along.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A chat which cannot go now, e.g., since another operation holds it or a file of it is open,
|
||||
/// stays until the next maintenance. Its failure must not end this service, nor the app with it.
|
||||
/// </remarks>
|
||||
/// <param name="tempChatDirPath">The directory of the chat.</param>
|
||||
private async Task DeleteTemporaryChatAsync(string tempChatDirPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Guid.TryParse(Path.GetFileName(tempChatDirPath), out var chatId))
|
||||
{
|
||||
if (!await WorkspaceBehaviour.DeleteChatWithoutAskingAsync(Guid.Empty, chatId))
|
||||
logger.LogWarning("The temporary chat '{ChatId}' is busy, so the next maintenance deletes it.", chatId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Not a chat AI Studio made, so nothing else knows about it:
|
||||
Directory.Delete(tempChatDirPath, true);
|
||||
WorkspaceBehaviour.InvalidateWorkspaceTreeCache();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogWarning(exception, "Could not delete the temporary chat storage directory '{Directory}'. The next maintenance tries again.", tempChatDirPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user