forked from admin/VolcanicAgenticCore
59 lines
2.6 KiB
C#
59 lines
2.6 KiB
C#
using Volcanic.AgenticCore.Abstractions.Providers;
|
|
|
|
namespace Volcanic.AgenticCore.Extensions.ClaudeCode;
|
|
|
|
/// <summary>
|
|
/// The model aliases Claude Code serves on a subscription. Cost is zero (the subscription pays), the
|
|
/// context windows are Claude Code's own, and <c>MaxTokens</c> is Claude Code's default output cap per alias.
|
|
/// </summary>
|
|
public static class ClaudeCodeModels
|
|
{
|
|
public const string ProviderId = "claude-code";
|
|
public const string ApiId = "claude-code-headless";
|
|
public const string BaseUrl = "claude-code://local";
|
|
public const string ProviderName = "Claude Code (subscription)";
|
|
|
|
/// <summary>Thinking level to <c>--effort</c> value. <c>null</c> omits the flag and keeps Claude Code's default.</summary>
|
|
public static readonly IReadOnlyDictionary<ThinkingLevel, string?> EffortLevels = new Dictionary<ThinkingLevel, string?>
|
|
{
|
|
[ThinkingLevel.Off] = null,
|
|
[ThinkingLevel.Minimal] = null,
|
|
[ThinkingLevel.Low] = "low",
|
|
[ThinkingLevel.Medium] = "medium",
|
|
[ThinkingLevel.High] = "high",
|
|
[ThinkingLevel.XHigh] = "xhigh",
|
|
[ThinkingLevel.Max] = "max",
|
|
};
|
|
|
|
public static readonly Model Sonnet = Create("sonnet", "Claude Code Sonnet", 1_000_000, 64_000, reasoning: true);
|
|
public static readonly Model Opus = Create("opus", "Claude Code Opus", 1_000_000, 128_000, reasoning: true);
|
|
// Haiku has no effort control; Claude Code still owns its thinking default.
|
|
public static readonly Model Haiku = Create("haiku", "Claude Code Haiku", 200_000, 32_000, reasoning: false);
|
|
public static readonly Model Fable = Create("fable", "Claude Code Fable", 1_000_000, 64_000, reasoning: true);
|
|
|
|
public static IReadOnlyList<Model> All { get; } = [Sonnet, Opus, Haiku, Fable];
|
|
|
|
/// <summary>The <c>--effort</c> value for a request, or null to omit the flag.</summary>
|
|
public static string? EffortFor(Model model, ThinkingLevel? level)
|
|
{
|
|
if (!model.Reasoning || level is null) return null;
|
|
var map = model.ThinkingLevelMap ?? EffortLevels;
|
|
return map.TryGetValue(level.Value, out var effort) ? effort : null;
|
|
}
|
|
|
|
private static Model Create(string id, string name, int contextWindow, int maxTokens, bool reasoning) => new()
|
|
{
|
|
Id = id,
|
|
Name = name,
|
|
Provider = ProviderId,
|
|
Api = ApiId,
|
|
BaseUrl = BaseUrl,
|
|
Reasoning = reasoning,
|
|
Input = [ModelInput.Text, ModelInput.Image],
|
|
Cost = ModelCost.Zero,
|
|
ContextWindow = contextWindow,
|
|
MaxTokens = maxTokens,
|
|
ThinkingLevelMap = reasoning ? EffortLevels : null,
|
|
};
|
|
}
|