Keep non-chat models out of the chat lists

This commit is contained in:
Thorsten Sommer committed 2026-09-12 13:52:10 +02:00
1 parent 77130a450a
commit b6defc8b4b
11 files changed
+111 -5

No files matched your search

@@ -0,0 +1,25 @@
using AIStudio.Provider;
namespace AIStudio.Models.Kinds;
/// <summary>
/// The models that work a screen instead of holding a conversation.
/// </summary>
/// <remarks>
/// They are named after the chat model they grew out of -- gemini-2.5-computer-use-preview -- and a
/// name is all they share with it. A request without the computer use tool is refused outright:
/// "This model requires the use of the Computer Use tool." So the resemblance is exactly the trap,
/// and this is the rule that keeps them out of the list a person picks a chat partner from.
/// </remarks>
public sealed class ComputerUseModelsFamily : ModelFamily
{
/// <inheritdoc />
public override ModelVendor Vendor => ModelVendor.UNKNOWN;
/// <inheritdoc />
public override ModelSource Source => new("https://ai.google.dev/gemini-api/docs/computer-use", new DateOnly(2026, 9, 12), "Found while testing the switch-over: the model stood in the chat list although its API refuses every request which does not carry the computer use tool.");
/// <inheritdoc />
protected override void Declare(ModelFamilyBuilder builder) =>
builder.Modifier("computer-use").AsSegment().Kind(ModelKind.COMPUTER_USE);
}
@@ -35,5 +35,8 @@ public sealed class ImageGenerationModelsFamily : ModelFamily
builder.Modifier("midjourney").AsSubstring().Inherits();
builder.Modifier("image").AsSegment().Inherits();
// The other half of Grok Imagine, which the video rule steps aside for:
builder.Modifier("grok-imagine").AsSegment().NotContains("video").Inherits();
}
}
@@ -23,11 +23,20 @@ public sealed class RealtimeModelsFamily : ModelFamily
public override ModelVendor Vendor => ModelVendor.UNKNOWN;
/// <inheritdoc />
public override ModelSource Source => new("https://platform.openai.com/docs/guides/realtime", new DateOnly(2026, 9, 12), "Ported from the realtime marker of Provider/ModelKindExtensions.cs, where the same precedence was written as the order of two if statements.");
public override ModelSource Source => new("https://developers.openai.com/api/docs/models/gpt-live-1", new DateOnly(2026, 9, 12), "Ported from the realtime marker of Provider/ModelKindExtensions.cs, where the same precedence was written as the order of two if statements. GPT-Live was added after it turned up in the chat list while testing.");
/// <inheritdoc />
protected override void Declare(ModelFamilyBuilder builder) =>
protected override void Declare(ModelFamilyBuilder builder)
{
builder.Modifier("realtime").AsSubstring()
.Rank(1, THE_CONNECTION_DECIDES)
.Kind(ModelKind.REALTIME);
//
// The line which dropped the word. GPT-Live listens and speaks at the same time and leaves
// the thinking to a text model behind it, so there is even less of a conversation in it than
// in the realtime models it succeeds -- and nothing in the name says so any more.
//
builder.Modifier("gpt-live").AsSegment().Inherits();
}
}
@@ -18,7 +18,7 @@ public sealed class VideoGenerationModelsFamily : ModelFamily
public override ModelVendor Vendor => ModelVendor.UNKNOWN;
/// <inheritdoc />
public override ModelSource Source => new("https://huggingface.co/models?pipeline_tag=text-to-video", new DateOnly(2026, 9, 12), "Ported from the video generation markers of Provider/ModelKindExtensions.cs, where veo carried a trailing hyphen to say the same thing a name part says here.");
public override ModelSource Source => new("https://huggingface.co/models?pipeline_tag=text-to-video", new DateOnly(2026, 9, 12), "Ported from the video generation markers of Provider/ModelKindExtensions.cs, where veo carried a trailing hyphen to say the same thing a name part says here. Grok Imagine was added after it turned up in the chat list while testing; see https://docs.x.ai/docs/models.");
/// <inheritdoc />
protected override void Declare(ModelFamilyBuilder builder)
@@ -32,5 +32,8 @@ public sealed class VideoGenerationModelsFamily : ModelFamily
builder.Modifier("veo").AsSegment().Inherits();
builder.Modifier("kling").AsSegment().Inherits();
// Grok Imagine makes both stills and film; the word next to it says which:
builder.Modifier("grok-imagine").AsSegment().AlsoContains("video").Inherits();
}
}
@@ -34,6 +34,14 @@ public sealed class GrokFamily : ModelFamily
.Capabilities(TEXT_INPUT | MULTIPLE_IMAGE_INPUT | TEXT_OUTPUT)
.Apis(CHAT_COMPLETION_API);
//
// Grok Build is the agentic coding model behind their CLI. It reads pictures, which the
// family fallback does not know about, and it does not think out loud.
//
builder.Rule("grok-build").AsPrefix()
.Capabilities(TEXT_INPUT | MULTIPLE_IMAGE_INPUT | TEXT_OUTPUT | FUNCTION_CALLING)
.Apis(CHAT_COMPLETION_API);
builder.Rule("grok-3-mini").AsPrefix()
.Capabilities(TEXT_INPUT | TEXT_OUTPUT | FUNCTION_CALLING)
.Apis(CHAT_COMPLETION_API)
@@ -168,9 +168,15 @@ public class ProviderGoogle() : BaseProvider(LLMProviders.GOOGLE, new Uri("https
{
Models =
[
//
// Asking what a model is made for, rather than only ruling out the embedding ones.
// Google names everything after the chat model it grew out of, so the catalog is
// full of names which look like something to talk to and are not: the image models,
// and the computer use model whose API refuses a request without its tool.
//
..result.Models.Where(model =>
model.Id.StartsWith("gemini-", StringComparison.OrdinalIgnoreCase) &&
!model.IsEmbeddingModel())
model.IsChatModel())
.Select(this.WithDisplayNameFallback)
]
};
@@ -76,6 +76,16 @@ public enum ModelKind
/// </remarks>
REALTIME,
/// <summary>
/// The model drives a computer: it looks at a screen and says what to click next.
/// </summary>
/// <remarks>
/// These refuse a plain conversation outright. Google's answer to a request without the computer
/// use tool is "This model requires the use of the Computer Use tool", so the model belongs in no
/// chat list, however much its name looks like the chat model it grew out of.
/// </remarks>
COMPUTER_USE,
/// <summary>
/// The model extracts text from images or scanned documents.
/// </summary>
@@ -79,7 +79,12 @@ public sealed class ProviderX() : BaseProvider(LLMProviders.X, new Uri("https://
var result = await this.LoadModels(SecretStoreType.LLM_PROVIDER, ["grok-"], apiKeyProvisional, token);
return result with
{
Models = [..result.Models.Where(n => !n.Id.Contains("-image", StringComparison.OrdinalIgnoreCase))]
//
// Asking what a model is made for rather than testing its name for a word. The word was
// "-image", which said nothing about grok-imagine-video: that one made films and stood
// in the list of things to chat with.
//
Models = [..result.Models.Where(model => model.IsChatModel())]
};
}