mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 10:47:21 +00:00
Added an introduction and an onboarding chat to the BeyondFacts Lab (#1178)
This commit is contained in:
1 parent
79e0c80031
commit
22d94eb8fd
35 files changed
+1377
-361
No files matched your search
@@ -8,10 +8,10 @@ namespace AIStudio.Assistants.BeyondFactsLab;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The provenance store keeps what a chat received by the ID of the chat, and its cleanup at the start removes what
|
||||
/// belongs to no chat on the disk. With IDs which follow from the preparation and the step, the cleanup finds the
|
||||
/// chats of the lab from the folders alone, without reading a single chat; see ProvenanceCleanup. A chat started
|
||||
/// over keeps its ID, so what the old conversation received becomes unreferenced and goes at the next cleanup.
|
||||
/// The ID is a version 8 UUID after RFC 9562, built from a SHA-256 hash.
|
||||
/// belongs to no chat on the disk. With IDs which follow from the place of a chat, such as the preparation and the
|
||||
/// step, the cleanup finds the chats of the lab from the folders alone, without reading a single chat; see
|
||||
/// ProvenanceCleanup. A chat started over keeps its ID, so what the old conversation received becomes unreferenced
|
||||
/// and goes at the next cleanup. The ID is a version 8 UUID after RFC 9562, built from a SHA-256 hash.
|
||||
/// </remarks>
|
||||
public static class BflThreadId
|
||||
{
|
||||
@@ -20,17 +20,29 @@ public static class BflThreadId
|
||||
/// </summary>
|
||||
private const string NAMESPACE = "beyondfacts-lab/thread/";
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the conversation in which the lab tells whether it fits a task.
|
||||
/// </summary>
|
||||
public static readonly Guid ONBOARDING = FromName("onboarding");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the chat of a step.
|
||||
/// </summary>
|
||||
/// <param name="projectId">The ID of the preparation.</param>
|
||||
/// <param name="step">The step.</param>
|
||||
/// <returns>The ID, the same on every computer and in every run.</returns>
|
||||
public static Guid Of(Guid projectId, BflStep step)
|
||||
public static Guid Of(Guid projectId, BflStep step) => FromName($"{projectId:D}/{step.FolderName}");
|
||||
|
||||
/// <summary>
|
||||
/// Builds the ID of a chat from the name of its place.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the place, which no other place has.</param>
|
||||
/// <returns>The ID, the same on every computer and in every run.</returns>
|
||||
private static Guid FromName(string name)
|
||||
{
|
||||
var name = Encoding.UTF8.GetBytes($"{NAMESPACE}{projectId:D}/{step.FolderName}");
|
||||
var bytesOfName = Encoding.UTF8.GetBytes($"{NAMESPACE}{name}");
|
||||
Span<byte> hash = stackalloc byte[SHA256.HashSizeInBytes];
|
||||
SHA256.HashData(name, hash);
|
||||
SHA256.HashData(bytesOfName, hash);
|
||||
|
||||
var bytes = hash[..16];
|
||||
bytes[6] = (byte)((bytes[6] & 0x0F) | 0x80);
|
||||
|
||||
Reference in new issue
Block a user