AI-Studio/app/MindWork AI Studio/Models/IBM/GraniteFamily.cs
Thorsten Sommer d85b4e71b6
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
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
Rebuilt how AI Studio knows what a model can do (#960)
2026-09-13 14:17:25 +02:00

65 lines
2.9 KiB
C#

using AIStudio.Provider;
using static AIStudio.Provider.Capability;
namespace AIStudio.Models.IBM;
/// <summary>
/// Granite, from IBM.
/// </summary>
/// <remarks>
/// The instruct line calls functions with the OpenAI function definition schema, so the family
/// states it and the vision checkpoints say otherwise: for those, IBM documents no tool template.
/// The thinking came in two steps -- 3.2 and 3.3 have a toggle which starts off, 4.2 thinks unless
/// the request says otherwise, and the generations in between do not think at all.
///
/// Each generation is written twice. Ollama serves them as "granite4.2:8b", with the version glued
/// to the family name, while IBM writes "granite-4.2". The previous rules knew only IBM's spelling,
/// so everything anybody actually ran through Ollama quietly lost its thinking.
/// </remarks>
public sealed class GraniteFamily : ModelFamily
{
/// <inheritdoc />
public override ModelVendor Vendor => ModelVendor.IBM;
/// <inheritdoc />
public override ModelSource Source => new("https://www.ibm.com/granite/docs/models/granite/", new DateOnly(2026, 9, 11), "Ported from the Granite block of ProviderExtensions.OpenSource.cs, with the spelling Ollama uses added to each generation.");
/// <inheritdoc />
protected override void Declare(ModelFamilyBuilder builder)
{
builder.Rule("granite").AsSubstring()
.Capabilities(TEXT_INPUT | TEXT_OUTPUT | FUNCTION_CALLING)
.Apis(CHAT_COMPLETION_API);
// The embedding checkpoints turn text into a vector; there is no conversation in them:
builder.Rule("granite-embedding").AsSubstring()
.Capabilities(TEXT_INPUT | EMBEDDING)
.Kind(ModelKind.EMBEDDING);
// The vision checkpoints look at pictures and have nothing to call a function with:
builder.Rule("granite").AsSubstring().AlsoContains("vision")
.Capabilities(TEXT_INPUT | MULTIPLE_IMAGE_INPUT | TEXT_OUTPUT)
.Apis(CHAT_COMPLETION_API);
// From 4.2 on they think unless the request says otherwise:
builder.Rule("granite-4.2").AsSubstring().NotContains("vision")
.Capabilities(TEXT_INPUT | TEXT_OUTPUT | FUNCTION_CALLING)
.Apis(CHAT_COMPLETION_API)
.Reasoning(ReasoningSupport.ON_BY_DEFAULT);
builder.Rule("granite4.2").AsSubstring().NotContains("vision").Inherits();
// 3.2 and 3.3 have to be asked:
builder.Rule("granite-3.2").AsSubstring().NotContains("vision")
.Capabilities(TEXT_INPUT | TEXT_OUTPUT | FUNCTION_CALLING)
.Apis(CHAT_COMPLETION_API)
.Reasoning(ReasoningSupport.OPTIONAL);
builder.Rule("granite3.2").AsSubstring().NotContains("vision").Inherits();
builder.Rule("granite-3.3").AsSubstring().NotContains("vision").Inherits();
builder.Rule("granite3.3").AsSubstring().NotContains("vision").Inherits();
}
}