mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 10:47:21 +00:00
Added the guided chat to the BeyondFacts Lab (#1177)
This commit is contained in:
1 parent
e77645f44c
commit
79e0c80031
55 files changed
+3481
-72
No files matched your search
@@ -0,0 +1,60 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AIStudio.Assistants.BeyondFactsLab;
|
||||
|
||||
/// <summary>
|
||||
/// Fills the placeholders of a prompt of the BeyondFacts Lab, written as {{NAME}} in upper case.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A prompt with a placeholder nobody fills is an error, not a prompt with a gap: the model would read the
|
||||
/// placeholder as text. The values are inserted in one pass, so a value which contains a placeholder itself, such
|
||||
/// as a detail the person entered, stays as it is.
|
||||
/// </remarks>
|
||||
public static partial class BflPromptTemplate
|
||||
{
|
||||
/// <summary>
|
||||
/// The language the model answers in.
|
||||
/// </summary>
|
||||
public const string RESPONSE_LANGUAGE = "RESPONSE_LANGUAGE";
|
||||
|
||||
/// <summary>
|
||||
/// How the model addresses the person.
|
||||
/// </summary>
|
||||
public const string ADDRESS_FORM = "ADDRESS_FORM";
|
||||
|
||||
/// <summary>
|
||||
/// The guide of the lab.
|
||||
/// </summary>
|
||||
public const string KNOWLEDGE = "KNOWLEDGE";
|
||||
|
||||
/// <summary>
|
||||
/// The prompt of the step the chat belongs to.
|
||||
/// </summary>
|
||||
public const string STEP = "STEP";
|
||||
|
||||
/// <summary>
|
||||
/// What the person entered into the forms.
|
||||
/// </summary>
|
||||
public const string DETAILS = "DETAILS";
|
||||
|
||||
/// <summary>
|
||||
/// The key details the forms still lack.
|
||||
/// </summary>
|
||||
public const string MISSING_DETAILS = "MISSING_DETAILS";
|
||||
|
||||
/// <summary>
|
||||
/// Fills every placeholder of a template.
|
||||
/// </summary>
|
||||
/// <param name="template">The template.</param>
|
||||
/// <param name="values">The value of each placeholder, by its name.</param>
|
||||
/// <returns>The prompt.</returns>
|
||||
/// <exception cref="FormatException">The template has a placeholder without a value.</exception>
|
||||
public static string Fill(string template, IReadOnlyDictionary<string, string> values) => PlaceholderPattern().Replace(template, match =>
|
||||
{
|
||||
var name = match.Groups["name"].Value;
|
||||
return values.TryGetValue(name, out var value) ? value : throw new FormatException($"The prompt has the placeholder '{name}', which has no value.");
|
||||
});
|
||||
|
||||
[GeneratedRegex(@"\{\{\s*(?<name>[^{}]*?)\s*\}\}")]
|
||||
private static partial Regex PlaceholderPattern();
|
||||
}
|
||||
Reference in new issue
Block a user