Account for newer OpenAI models in system prompt selection logic

This commit is contained in:
Thorsten Sommer 2025-08-31 17:04:53 +02:00
parent f61fe87181
commit 0691634c4d
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -30,16 +30,20 @@ public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.o
yield break; yield break;
// Unfortunately, OpenAI changed the name of the system prompt based on the model. // Unfortunately, OpenAI changed the name of the system prompt based on the model.
// All models that start with "o" (the omni aka reasoning models) and all GPT4o models // All models that start with "o" (the omni aka reasoning models), all GPT4o models,
// have the system prompt named "developer". All other models have the system prompt // and all newer models have the system prompt named "developer". All other models
// named "system". We need to check this to get the correct system prompt. // have the system prompt named "system". We need to check this to get the correct
// system prompt.
// //
// To complicate it even more: The early versions of reasoning models, which are released // To complicate it even more: The early versions of reasoning models, which are released
// before the 17th of December 2024, have no system prompt at all. We need to check this // before the 17th of December 2024, have no system prompt at all. We need to check this
// as well. // as well.
// Apply the basic rule first: // Apply the basic rule first:
var systemPromptRole = chatModel.Id.StartsWith('o') || chatModel.Id.Contains("4o") ? "developer" : "system"; var systemPromptRole =
chatModel.Id.StartsWith('o') ||
chatModel.Id.StartsWith("gpt-5", StringComparison.Ordinal) ||
chatModel.Id.Contains("4o") ? "developer" : "system";
// Check if the model is an early version of the reasoning models: // Check if the model is an early version of the reasoning models:
systemPromptRole = chatModel.Id switch systemPromptRole = chatModel.Id switch