Module: RubyLLM::Protocols::ChatCompletions::Models

Defined in:
lib/ruby_llm/protocols/chat_completions/models.rb

Overview

Models methods of the OpenAI API integration

Class Method Summary collapse

Class Method Details

.model_metadata(model_data) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/ruby_llm/protocols/chat_completions/models.rb', line 28

def (model_data)
   = {
    object: model_data['object'],
    owned_by: model_data['owned_by']
  }
  [:shutdown_date] = model_data['shutdown_date'] if model_data['shutdown_date']
  
end

.models_urlObject



10
11
12
# File 'lib/ruby_llm/protocols/chat_completions/models.rb', line 10

def models_url
  'models'
end

.parse_list_models_response(response, slug) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_llm/protocols/chat_completions/models.rb', line 14

def parse_list_models_response(response, slug)
  Array(response.body['data']).map do |model_data|
    model_id = model_data['id']

    Model.new(
      id: model_id,
      name: model_id,
      provider: slug,
      created_at: model_data['created'] ? Time.at(model_data['created']) : nil,
      metadata: (model_data)
    )
  end
end