@@ -53,19 +53,34 @@ def output_price_for(model_id)
53
53
def supports_vision? ( model_id )
54
54
# Explicitly match the known vision-capable models
55
55
vision_models = [
56
- 'pixtral-12b-latest ' ,
57
- 'pixtral-large-latest ' ,
58
- 'mistral-medium-latest ' ,
59
- 'mistral-small-latest '
56
+ 'pixtral-12b' ,
57
+ 'pixtral-large' ,
58
+ 'mistral-medium' ,
59
+ 'mistral-small'
60
60
]
61
- vision_models . any? { |id | model_id . include? ( id ) }
61
+ model_id = model_id . to_s . split ( '/' ) . last
62
+ result = vision_models . any? { |id | model_id . match? ( /^#{ Regexp . escape ( id ) } / ) }
63
+ result
62
64
end
63
65
64
66
# Determines if the model supports function calling
65
67
# @param model_id [String] the model identifier
66
68
# @return [Boolean] true if the model supports functions
67
69
def supports_functions? ( model_id )
68
- !model_id . match? ( /embed|moderation/ )
70
+ function_calling_models = [
71
+ 'mistral-large' ,
72
+ 'mistral-medium' ,
73
+ 'mistral-small' ,
74
+ 'codestral' ,
75
+ 'ministral-8b' ,
76
+ 'ministral-3b' ,
77
+ 'pixtral-12b' ,
78
+ 'pixtral-large' ,
79
+ 'mistral-nemo'
80
+ ]
81
+ model_id = model_id . to_s . split ( '/' ) . last
82
+ result = function_calling_models . any? { |id | model_id . match? ( /^#{ Regexp . escape ( id ) } / ) }
83
+ result
69
84
end
70
85
71
86
# Determines if the model supports audio input/output
@@ -168,6 +183,14 @@ def apply_special_formatting(name)
168
183
. gsub ( "Mathstral " , "Mathstral-" )
169
184
. gsub ( "Embed " , "Embed-" )
170
185
end
186
+
187
+ def capabilities_for ( model_id )
188
+ capabilities = [ 'streaming' ]
189
+ capabilities << 'function_calling' if supports_functions? ( model_id )
190
+ capabilities << 'structured_output' if supports_json_mode? ( model_id )
191
+ # Add more as needed (e.g., 'batch', 'caching', etc.)
192
+ capabilities
193
+ end
171
194
end
172
195
end
173
196
end
0 commit comments