AI-Studio/app/MindWork AI Studio/Models/OpenAI/Gpt5Family.cs
2026-09-11 20:01:45 +02:00

58 lines
2.7 KiB
C#

using static AIStudio.Provider.Capability;
namespace AIStudio.Models.OpenAI;
/// <summary>
/// The whole GPT-5 line, from GPT-5 to GPT-5.6.
/// </summary>
/// <remarks>
/// One family rather than six, because the generations differ in one sentence each and stating that
/// sentence is the entire content: GPT-5 reasons always and answers only through the Responses API,
/// GPT-5.1 reasons on request and answers through both, GPT-5.5 reasons unless told not to.
///
/// The dot is what keeps the generations apart. A rule bound to the start of a name ends at a name
/// part, and a dot does not end one, so "gpt-5" does not answer for "gpt-5.1" -- which is exactly
/// what the previous rules spelled out one comparison at a time.
///
/// None of these models writes images itself. They can ask for one through the image generation
/// tool, which is a tool call producing a picture from a separate model, and reporting that as an
/// output modality would have the chat offer to receive images which never arrive.
/// </remarks>
public sealed class Gpt5Family : ModelFamily
{
/// <inheritdoc />
public override ModelVendor Vendor => ModelVendor.OPEN_AI;
/// <inheritdoc />
public override ModelSource Source => new("https://platform.openai.com/docs/models", new DateOnly(2026, 9, 11), "Ported unchanged from the rules in ProviderExtensions.OpenAI.cs, one rule per generation, except that the chat alias no longer inherits the reasoning it is named for not having.");
/// <inheritdoc />
protected override void Declare(ModelFamilyBuilder builder)
{
builder.Rule("gpt-5").AsPrefix()
.Capabilities(TEXT_INPUT | MULTIPLE_IMAGE_INPUT | TEXT_OUTPUT | FUNCTION_CALLING | WEB_SEARCH)
.Apis(RESPONSES_API)
.Reasoning(ReasoningSupport.ALWAYS);
//
// The alias for the model of this generation which does not reason. The previous rules had
// it swallowed by the prefix above and told it that it always reasons, which is the one
// thing its name rules out. Here the longer pattern simply wins.
//
builder.Rule("gpt-5-chat").AsPrefix().Inherits()
.Reasoning(ReasoningSupport.NONE);
builder.Rule("gpt-5.1").AsPrefix().InheritsFrom("gpt-5")
.Apis(CHAT_COMPLETION_API)
.Reasoning(ReasoningSupport.OPTIONAL);
builder.Rule("gpt-5.2").AsPrefix().InheritsFrom("gpt-5.1");
builder.Rule("gpt-5.3").AsPrefix().InheritsFrom("gpt-5.1");
builder.Rule("gpt-5.4").AsPrefix().InheritsFrom("gpt-5.1");
builder.Rule("gpt-5.5").AsPrefix().InheritsFrom("gpt-5.1")
.Reasoning(ReasoningSupport.ON_BY_DEFAULT);
builder.Rule("gpt-5.6").AsPrefix().InheritsFrom("gpt-5.5");
}
}