AI-Studio/app/Tests/Provider/OpenAI/SystemPromptRoleTests.cs
Thorsten Sommer 8dbe459a53
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Fixed GPT-6 Sol and Luna, and the system prompt role of newer OpenAI models (#1010)
2026-09-27 19:13:54 +02:00

48 lines
2.0 KiB
C#

using AIStudio.Models;
using AIStudio.Provider;
using AIStudio.Provider.OpenAI;
using AIStudio.Settings;
namespace AIStudio.Tests.Provider.OpenAI;
/// <summary>
/// Checks which role the OpenAI provider sends the system prompt in, model by model.
/// </summary>
/// <remarks>
/// The role used to be guessed from the model's name: whatever began with an "o" or with "gpt-5",
/// or carried a "4o", got "developer", and everything else got "system". GPT-6 fell through that
/// guess and was sent the oldest role. The families state the role now, and these cases ask for it
/// through the same chain the provider uses, so that a family forgetting it shows up here.
/// </remarks>
[TestFixture]
public sealed class SystemPromptRoleTests
{
[TestCase("gpt-6-luna", "developer")]
[TestCase("gpt-6-astra", "developer")]
[TestCase("gpt-5.6", "developer")]
[TestCase("gpt-4o", "developer")]
[TestCase("o3", "developer")]
[TestCase("gpt-4.1", "developer", Description = "No generation rule knows it, so the baseline for new OpenAI models answers.")]
[TestCase("o1-mini", "user", Description = "An early reasoning model, which takes no system prompt of its own.")]
[TestCase("o1-mini-2024-09-12", "user")]
[TestCase("o1-preview", "user")]
[TestCase("gpt-4", "system")]
[TestCase("gpt-4-turbo", "system")]
[TestCase("gpt-3.5-turbo", "system")]
public void TheSystemPromptGoesInTheRoleTheModelTakes(string modelId, string role)
{
var profile = LLMProviders.OPEN_AI.GetModelProfile(new Model(modelId, null));
Assert.That(profile.SystemPromptRole.ToOpenAIRole(), Is.EqualTo(role));
}
[Test]
public void ARoleNoRuleStatesIsTheOneOpenAIDocumentsToday()
{
//
// A model the rules do not know is almost always a new one, and the older generations which
// still want "system" say so in their families.
//
Assert.That(SystemPromptRole.UNKNOWN.ToOpenAIRole(), Is.EqualTo("developer"));
}
}