mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-14 22:03:36 +00:00
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
47 lines
2.0 KiB
C#
47 lines
2.0 KiB
C#
namespace AIStudio.Provider.Reasoning.Dialects;
|
|
|
|
/// <summary>
|
|
/// The reasoning mode and budget of the llama.cpp server.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Its "reasoning" key is a mode rather than an object, and one of its three values means neither
|
|
/// yes nor no: "auto" hands the decision to the model's own template, which is exactly the case
|
|
/// where nobody has decided anything.
|
|
/// </remarks>
|
|
public sealed class LlamaCppReasoningDialect : IReasoningDialect
|
|
{
|
|
/// <inheritdoc />
|
|
public ReasoningDialect Dialect => ReasoningDialect.LLAMA_CPP;
|
|
|
|
/// <inheritdoc />
|
|
public ReasoningConfigurationState Detect(IDictionary<string, object> parameters)
|
|
{
|
|
var states = new List<ReasoningConfigurationState>();
|
|
|
|
if (ReasoningParameters.TryGet(parameters, "reasoning", out var reasoning))
|
|
states.Add(ModeOf(reasoning));
|
|
|
|
if (ReasoningParameters.TryGet(parameters, "reasoning_budget", out var reasoningBudget))
|
|
states.Add(ReasoningParameters.BudgetOf(reasoningBudget));
|
|
|
|
if (ReasoningParameters.TryGet(parameters, "chat_template_kwargs", out var chatTemplateKwargs) &&
|
|
chatTemplateKwargs is IDictionary<string, object> chatTemplateKwargsObject)
|
|
states.Add(QwenThinkingDialect.In(chatTemplateKwargsObject));
|
|
|
|
return ReasoningParameters.Merge(states);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads the reasoning mode.
|
|
/// </summary>
|
|
/// <param name="value">The configured mode.</param>
|
|
/// <returns>What it says, which for "auto" is nothing.</returns>
|
|
private static ReasoningConfigurationState ModeOf(object? value) => value switch
|
|
{
|
|
string text when text.Equals("on", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.EXPLICITLY_ENABLED,
|
|
string text when text.Equals("off", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.EXPLICITLY_DISABLED,
|
|
string text when text.Equals("auto", StringComparison.OrdinalIgnoreCase) => ReasoningConfigurationState.NOT_CONFIGURED,
|
|
|
|
_ => ReasoningParameters.LevelOf(value),
|
|
};
|
|
} |