mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 05:07:22 +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
@@ -0,0 +1,51 @@
|
||||
using System.Text.Json;
|
||||
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Tools;
|
||||
|
||||
namespace AIStudio.Tests.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the augmented data of the classic RAG process stays with the request it was made for.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The process writes it anew for every message, so a stored copy was never read again, while it
|
||||
/// often made up the largest part of a chat file. What the AI read of it is kept with the answer as
|
||||
/// its passages.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class ChatThreadAugmentedDataTests
|
||||
{
|
||||
[Test]
|
||||
public void TheAugmentedDataIsNotSaved()
|
||||
{
|
||||
var thread = new ChatThread { ChatId = Guid.NewGuid(), AugmentedData = "# Retrieval context 1 of 1\nThe mixing console is described here." };
|
||||
|
||||
var json = JsonSerializer.Serialize(thread, WorkspaceBehaviour.JSON_OPTIONS);
|
||||
using var document = JsonDocument.Parse(json);
|
||||
|
||||
Assert.That(document.RootElement.TryGetProperty("augmented_data", out _), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AChatSavedWithAugmentedDataLoadsWithout()
|
||||
{
|
||||
const string CHAT_WITH_AUGMENTED_DATA = """
|
||||
{
|
||||
"chat_id": "2b7c9e1f-4a6d-4c8b-9e3f-1d5a7c9b2e4f",
|
||||
"name": "An older chat",
|
||||
"augmented_data": "# Retrieval context 1 of 1\nThe mixing console is described here.",
|
||||
"blocks": []
|
||||
}
|
||||
""";
|
||||
|
||||
var loaded = JsonSerializer.Deserialize<ChatThread>(CHAT_WITH_AUGMENTED_DATA, WorkspaceBehaviour.JSON_OPTIONS);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(loaded, Is.Not.Null, "An older chat file must still load.");
|
||||
Assert.That(loaded!.AugmentedData, Is.Empty, "It belonged to a request long over; the next message retrieves anew.");
|
||||
Assert.That(loaded.Name, Is.EqualTo("An older chat"));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user