mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-21 03:14:35 +00:00
Moved goals and roles before knowledge in the BeyondFacts Lab (#1214)
This commit is contained in:
1 parent
761ec7001d
commit
6cdb0bc551
38 files changed
+334
-186
No files matched your search
@@ -9,10 +9,12 @@ namespace AIStudio.Assistants.BeyondFactsLab;
|
||||
/// new version of AI Studio.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The folder mirrors the files of the lab below Assistants/BeyondFactsLab, e.g., Prompts/steps/02-knowledge.md, so
|
||||
/// The folder mirrors the files of the lab below Assistants/BeyondFactsLab, e.g., Prompts/steps/knowledge.md, so
|
||||
/// that every name stays unique. Only the files of BflPromptLibrary.AllPaths count; the lab leaves any other file in
|
||||
/// the folder alone, and an empty file replaces nothing. The files are instructions of the person, who chose to use
|
||||
/// them, so they bypass the prompt injection filter like the prompts which come with the app.
|
||||
/// the folder alone, and an empty file replaces nothing. A Markdown file which matches no prompt, e.g., the copy of a
|
||||
/// prompt which has a new name in this version, the lab names in a notice, see FindUnknown. The files are
|
||||
/// instructions of the person, who chose to use them, so they bypass the prompt injection filter like the prompts
|
||||
/// which come with the app.
|
||||
/// </remarks>
|
||||
public static class BflPromptOverrides
|
||||
{
|
||||
@@ -21,6 +23,12 @@ public static class BflPromptOverrides
|
||||
/// </summary>
|
||||
public const string DIRECTORY_NAME = "promptOverrides";
|
||||
|
||||
/// <summary>
|
||||
/// Compares the names of two files as the file system does where the lab looks for a prompt: without case on
|
||||
/// Windows and macOS, whose file systems ignore it by default, and with case elsewhere.
|
||||
/// </summary>
|
||||
private static readonly StringComparer FILE_NAME_COMPARER = OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder whose files replace the prompts of the lab, or null while the setting does not allow them.
|
||||
/// </summary>
|
||||
@@ -86,6 +94,32 @@ public static class BflPromptOverrides
|
||||
return replaced;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the Markdown files in the folder which replace no prompt of the lab, e.g., the copy of a prompt which has
|
||||
/// a new name in this version, so that the person learns why such a file changes nothing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only Markdown files count, since every prompt is one; files in other formats, such as notes, belong to the
|
||||
/// person. Hidden files and folders stay out, as do those whose names start with a dot on every system, such as
|
||||
/// the folder of a version control.
|
||||
/// </remarks>
|
||||
/// <param name="directory">The folder for prompt overrides.</param>
|
||||
/// <returns>The files relative to the folder, with forward slashes, e.g., "Prompts/steps/02-knowledge.md", in their order by name; none while the folder is missing.</returns>
|
||||
/// <exception cref="IOException">The folder cannot be read.</exception>
|
||||
/// <exception cref="UnauthorizedAccessException">The folder cannot be read.</exception>
|
||||
public static IReadOnlyList<string> FindUnknown(string directory)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
return [];
|
||||
|
||||
var known = new HashSet<string>(BflPromptLibrary.AllPaths.Select(BflPromptLibrary.RelativePath), FILE_NAME_COMPARER);
|
||||
var options = new EnumerationOptions { RecurseSubdirectories = true, MatchCasing = MatchCasing.CaseInsensitive };
|
||||
return [.. Directory.EnumerateFiles(directory, "*.md", options)
|
||||
.Select(file => Path.GetRelativePath(directory, file).Replace(Path.DirectorySeparatorChar, '/'))
|
||||
.Where(file => !file.Split('/').Any(name => name.StartsWith('.')) && !known.Contains(file))
|
||||
.Order(StringComparer.Ordinal)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the prompts of this version into the folder, so that changes start from them. A file which exists stays
|
||||
/// as it is.
|
||||
|
||||
Reference in new issue
Block a user