Module: RubyLLM::Pollinations::Provider::Models

Included in:
Pollinations
Defined in:
lib/ruby_llm/pollinations/provider/models.rb

Class Method Summary collapse

Class Method Details

.build_metadata(model_data) ⇒ Object



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

def (model_data)
  {
    object: model_data['object'],
    owned_by: model_data['owned_by']
  }.compact
end

.build_model_info(model_data, slug, capabilities) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_llm/pollinations/provider/models.rb', line 19

def build_model_info(model_data, slug, capabilities)
  model_id = model_data['id']

  RubyLLM::Model::Info.new(
    id: model_id,
    name: capabilities.format_display_name(model_id),
    provider: slug,
    family: capabilities.model_family(model_id),
    created_at: parse_created_at(model_data['created']),
    context_window: capabilities.context_window_for(model_id),
    max_output_tokens: capabilities.max_tokens_for(model_id),
    modalities: capabilities.modalities_for(model_id),
    capabilities: capabilities.capabilities_for(model_id),
    pricing: capabilities.pricing_for(model_id),
    metadata: (model_data)
  )
end

.models_url ⇒ Object



9
10
11
# File 'lib/ruby_llm/pollinations/provider/models.rb', line 9

def models_url
  'v1/models'
end

.parse_created_at(created) ⇒ Object



37
38
39
40
41
# File 'lib/ruby_llm/pollinations/provider/models.rb', line 37

def parse_created_at(created)
  return nil unless created

  Time.at(created)
end

.parse_list_models_response(response, slug, capabilities) ⇒ Object



13
14
15
16
17
# File 'lib/ruby_llm/pollinations/provider/models.rb', line 13

def parse_list_models_response(response, slug, capabilities)
  Array(response.body['data']).map do |model_data|
    build_model_info(model_data, slug, capabilities)
  end
end