Repository navigation
Expand file tree
/
Copy pathreasoning.go
More file actions
116 lines (105 loc) · 3.55 KB
/
Copy pathreasoning.go
File metadata and controls
116 lines (105 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) 2026 Matthew Winter
//
// This source code is licensed under the MIT license found in the LICENSE file
// in the root directory of this source tree.
package sigma
// SupportsInput reports whether model metadata allows a request content kind.
// Models with no explicit input list are treated as text-only for backwards
// compatibility with earlier metadata.
func (model Model) SupportsInput(kind ContentBlockType) bool {
if kind == "" {
return false
}
if len(model.SupportedInputs) == 0 {
return kind == ContentBlockText
}
for _, supported := range model.SupportedInputs {
if supported == kind {
return true
}
}
return false
}
// SupportsReasoning reports whether model metadata advertises provider
// reasoning or thinking support.
func (model Model) SupportsReasoning() bool {
return model.SupportsThinking ||
len(model.ThinkingLevels) > 0 ||
len(model.ThinkingLevelMap) > 0
}
// SupportsThinkingLevel reports whether level can be requested for model.
// For models that advertise SupportsThinking, ThinkingLevelMap overrides
// provider values: unmapped levels up to high stay supported, while xhigh and
// max require an explicit entry. Use UnsupportedThinkingLevels to reject a
// level. Without SupportsThinking, ThinkingLevelMap lists every supported level.
func (model Model) SupportsThinkingLevel(level ThinkingLevel) bool {
if level == "" {
return false
}
if model.unsupportedThinkingLevel(level) {
return false
}
if level == ThinkingLevelOff {
return true
}
if len(model.ThinkingLevelMap) > 0 {
if _, ok := model.ThinkingLevelMap[level]; ok {
return true
}
return model.SupportsThinking && level != ThinkingLevelXHigh && level != ThinkingLevel("max")
}
if len(model.ThinkingLevels) > 0 {
for _, supported := range model.ThinkingLevels {
if supported == level {
return true
}
}
return false
}
return model.SupportsThinking
}
func (model Model) unsupportedThinkingLevel(level ThinkingLevel) bool {
for _, unsupported := range model.UnsupportedThinkingLevels {
if unsupported == level {
return true
}
}
return false
}
// ProviderThinkingLevel returns the provider-specific value for level.
// Levels without a ThinkingLevelMap entry use the level text.
func (model Model) ProviderThinkingLevel(level ThinkingLevel) (string, bool) {
if !model.SupportsThinkingLevel(level) {
return "", false
}
if level == ThinkingLevelOff {
return "", true
}
if value, ok := model.ThinkingLevelMap[level]; ok {
return value, true
}
return string(level), true
}
// SupportsImages reports whether model accepts image content as input.
func (model Model) SupportsImages() bool {
return model.SupportsInput(ContentBlockImage)
}
// SupportsDocuments reports whether model accepts document content as input.
func (model Model) SupportsDocuments() bool {
return model.SupportsInput(ContentBlockDocument)
}
// CacheEnabled reports whether this retention requests provider-side prompt
// caching. Empty retention and CacheRetentionNone both mean no cache.
func (retention CacheRetention) CacheEnabled() bool {
return retention != "" && retention != CacheRetentionNone
}
// CacheShortLived reports whether this retention asks for a short-lived prompt
// cache entry.
func (retention CacheRetention) CacheShortLived() bool {
return retention == CacheRetentionShort || retention == CacheRetentionEphemeral
}
// CacheLongLived reports whether this retention asks for a long-lived prompt
// cache entry.
func (retention CacheRetention) CacheLongLived() bool {
return retention == CacheRetentionLong || retention == CacheRetentionPersistent
}