mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 06:08:19 +00:00
Fixed and improved the system prompt of chats started from assistants (#1172)
This commit is contained in:
1 parent
bbf4dc2231
commit
31862f5ecd
50 files changed
+1112
-107
No files matched your search
@@ -0,0 +1,49 @@
|
||||
using AIStudio.Assistants;
|
||||
using AIStudio.Chat;
|
||||
|
||||
namespace AIStudio.Tests.Assistants;
|
||||
|
||||
/// <summary>
|
||||
/// Checks which system prompt a chat gets for each choice an assistant can make.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public sealed class ChatSystemPromptChoiceTests
|
||||
{
|
||||
private const string PROMPT_OF_ASSISTANT = "You are a translation engine. Only translate the text.";
|
||||
private const string PROMPT_FOR_THE_CHAT = "You are an expert in German and answer questions about a translation.";
|
||||
|
||||
[Test]
|
||||
public void TheDefaultChoiceGivesTheDefaultPromptOfAIStudio() => Assert.That(ChatSystemPromptChoice.AI_STUDIO_DEFAULT.CreatePrompt(PROMPT_OF_ASSISTANT), Is.EqualTo(SystemPrompts.DEFAULT));
|
||||
|
||||
[Test]
|
||||
public void TheAssistantChoiceGivesThePromptOfTheAssistant() => Assert.That(ChatSystemPromptChoice.ASSISTANT.CreatePrompt(PROMPT_OF_ASSISTANT), Is.EqualTo(PROMPT_OF_ASSISTANT));
|
||||
|
||||
[Test]
|
||||
public void ACustomChoiceGivesThePromptTheAssistantWroteForTheChat()
|
||||
{
|
||||
var choice = ChatSystemPromptChoice.Custom(() => PROMPT_FOR_THE_CHAT);
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(choice.Source, Is.EqualTo(ChatSystemPromptSource.CUSTOM));
|
||||
Assert.That(choice.CreatePrompt(PROMPT_OF_ASSISTANT), Is.EqualTo(PROMPT_FOR_THE_CHAT));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACustomPromptIsBuiltOnlyWhenTheChatNeedsIt()
|
||||
{
|
||||
var builds = 0;
|
||||
var choice = ChatSystemPromptChoice.Custom(() =>
|
||||
{
|
||||
builds++;
|
||||
return PROMPT_FOR_THE_CHAT;
|
||||
});
|
||||
|
||||
Assert.That(choice.Source, Is.EqualTo(ChatSystemPromptSource.CUSTOM));
|
||||
Assert.That(builds, Is.Zero, "Reading the choice must not build the prompt, which may need the state of the assistant.");
|
||||
|
||||
choice.CreatePrompt(PROMPT_OF_ASSISTANT);
|
||||
Assert.That(builds, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user