Module: RubyLLM::Pollinations::Provider::Capabilities

Defined in:
lib/ruby_llm/pollinations/provider/capabilities.rb

Constant Summary collapse

DEFAULT_CONTEXT_WINDOW =
128_000
DEFAULT_MAX_TOKENS =
16_384
CHAT_MODEL_FAMILIES =
%w[gemini claude openai].freeze

Class Method Summary collapse

Class Method Details

.capabilities_for(model_id) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 90

def capabilities_for(model_id)
  capabilities = []
  capabilities << 'streaming' if model_type(model_id) == 'chat'
  capabilities << 'function_calling' if supports_functions?(model_id)
  capabilities << 'structured_output' if supports_structured_output?(model_id)
  capabilities
end

.context_window_for(model_id) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 34

def context_window_for(model_id)
  case model_family(model_id)
  when 'gemini' then 1_000_000
  when 'claude' then 200_000
  else DEFAULT_CONTEXT_WINDOW
  end
end

.format_display_name(model_id) ⇒ Object



73
74
75
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 73

def format_display_name(model_id)
  model_id.tr('-', ' ').split.map(&:capitalize).join(' ')
end

.input_price_for(_model_id) ⇒ Object



65
66
67
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 65

def input_price_for(_model_id)
  0.0
end

.max_tokens_for(model_id) ⇒ Object



42
43
44
45
46
47
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 42

def max_tokens_for(model_id)
  case model_family(model_id)
  when 'gemini', 'claude' then 8_192
  else DEFAULT_MAX_TOKENS
  end
end

.modalities_for(model_id) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 77

def modalities_for(model_id)
  case model_type(model_id)
  when 'image'
    { input: ['text'], output: ['image'] }
  when 'audio'
    { input: %w[text audio], output: ['audio'] }
  else
    modalities = { input: ['text'], output: ['text'] }
    modalities[:input] << 'image' if supports_vision?(model_id)
    modalities
  end
end

.model_family(model_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 13

def model_family(model_id)
  case model_id
  when /^openai/ then 'openai'
  when /^gemini/ then 'gemini'
  when /^claude/ then 'claude'
  when /^flux|^zimage|^gptimage|^seedream|^nanobanana|^kontext|^imagen|^klein|^wan/ then 'image'
  when /^veo|^seedance|^grok-video|^ltx/ then 'video'
  when /^whisper/ then 'transcription'
  when /^tts|^elevenmusic|^music/ then 'audio'
  else 'other'
  end
end

.model_type(model_id) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 26

def model_type(model_id)
  case model_family(model_id)
  when 'image', 'video' then 'image'
  when 'transcription', 'audio' then 'audio'
  else 'chat'
  end
end

.output_price_for(_model_id) ⇒ Object



69
70
71
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 69

def output_price_for(_model_id)
  0.0
end

.pricing_for(model_id) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 98

def pricing_for(model_id)
  {
    text_tokens: {
      standard: {
        input_per_million: input_price_for(model_id),
        output_per_million: output_price_for(model_id)
      }
    }
  }
end

.supports_functions?(model_id) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 53

def supports_functions?(model_id)
  CHAT_MODEL_FAMILIES.include?(model_family(model_id))
end

.supports_json_mode?(model_id) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 61

def supports_json_mode?(model_id)
  supports_structured_output?(model_id)
end

.supports_structured_output?(model_id) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 57

def supports_structured_output?(model_id)
  CHAT_MODEL_FAMILIES.include?(model_family(model_id))
end

.supports_vision?(model_id) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ruby_llm/pollinations/provider/capabilities.rb', line 49

def supports_vision?(model_id)
  CHAT_MODEL_FAMILIES.include?(model_family(model_id))
end