summaryrefslogtreecommitdiff
path: root/src/models_toml.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/models_toml.zig')
-rw-r--r--src/models_toml.zig40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/models_toml.zig b/src/models_toml.zig
index 955640d..622bdf6 100644
--- a/src/models_toml.zig
+++ b/src/models_toml.zig
@@ -21,7 +21,8 @@
//!
//! # anthropic_messages-only knobs:
//! api_version = <string> # Anthropic-Version header; default "2023-06-01"
-//! thinking = <string> # disabled | enabled | adaptive (default: disabled)
+//! thinking = <string> # disabled | enabled | adaptive (default: disabled,
+//! # or adaptive when `effort` is present)
//! effort = <string> # low | medium | high | xhigh | max (default: medium)
//! # only used when thinking = "adaptive"
//! thinking_budget_tokens = <int> # max reasoning tokens for thinking = "enabled"
@@ -268,13 +269,15 @@ fn ingestModel(
break :blk null;
};
+ const has_effort = v.get("effort") != null;
+
const thinking: Thinking = blk: {
if (v.get("thinking")) |t| {
if (t.asString()) |s| {
break :blk std.meta.stringToEnum(Thinking, s) orelse .disabled;
}
}
- break :blk .disabled;
+ break :blk if (has_effort) .adaptive else .disabled;
};
const effort: Effort = blk: {
@@ -527,6 +530,39 @@ test "parseInto: anthropic adaptive thinking with effort" {
try testing.expectEqual(false, def.thinking_interleaved); // default
}
+test "parseInto: anthropic effort implies adaptive thinking" {
+ var models = emptyModels(testing.allocator);
+ defer models.deinit();
+
+ const src =
+ \\[anthropic.opus]
+ \\model = "claude-opus-4-8"
+ \\effort = "high"
+ ;
+ try parseInto(&models, src);
+
+ const def = models.defs.get("anthropic", "opus").?;
+ try testing.expectEqual(Thinking.adaptive, def.thinking);
+ try testing.expectEqual(Effort.high, def.effort);
+}
+
+test "parseInto: explicit thinking overrides effort-implied adaptive thinking" {
+ var models = emptyModels(testing.allocator);
+ defer models.deinit();
+
+ const src =
+ \\[anthropic.haiku]
+ \\model = "claude-haiku-4-5-20251001"
+ \\thinking = "disabled"
+ \\effort = "high"
+ ;
+ try parseInto(&models, src);
+
+ const def = models.defs.get("anthropic", "haiku").?;
+ try testing.expectEqual(Thinking.disabled, def.thinking);
+ try testing.expectEqual(Effort.high, def.effort);
+}
+
test "parseInto: anthropic thinking disabled" {
var models = emptyModels(testing.allocator);
defer models.deinit();