Class: RubyLLM::Providers::GitLab

Inherits:
Provider
  • Object
show all
Includes:
Chat
Defined in:
lib/ruby_llm/providers/gitlab.rb,
lib/ruby_llm/providers/gitlab/chat.rb,
lib/ruby_llm/providers/gitlab/capabilities.rb,
lib/ruby_llm/providers/gitlab/token_manager.rb,
lib/ruby_llm/providers/gitlab/openai_delegate.rb,
lib/ruby_llm/providers/gitlab/anthropic_delegate.rb

Defined Under Namespace

Modules: Capabilities, Chat Classes: AnthropicDelegate, ModelIdProxy, OpenAIDelegate, TokenManager

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chat

#render_payload

Constructor Details

#initialize(config) ⇒ GitLab



14
15
16
17
# File 'lib/ruby_llm/providers/gitlab.rb', line 14

def initialize(config)
  @config = config
  ensure_configured!
end

Class Method Details

.assume_models_exist?Boolean



45
# File 'lib/ruby_llm/providers/gitlab.rb', line 45

def assume_models_exist? = true

.configuration_optionsObject



43
# File 'lib/ruby_llm/providers/gitlab.rb', line 43

def configuration_options = i[gitlab_api_key gitlab_instance_url gitlab_gateway_url]

.configuration_requirementsObject



44
# File 'lib/ruby_llm/providers/gitlab.rb', line 44

def configuration_requirements = i[gitlab_api_key]

Instance Method Details

#complete(messages, tools:, temperature:, model:, **kwargs, &block) ⇒ Object



19
20
21
# File 'lib/ruby_llm/providers/gitlab.rb', line 19

def complete(messages, tools:, temperature:, model:, **kwargs, &block)
  delegate_for(model).complete(messages, tools: tools, temperature: temperature, model: model, **kwargs, &block)
end

#list_modelsObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby_llm/providers/gitlab.rb', line 23

def list_models
  GitLab::Capabilities::MODEL_MAPPINGS.map do |gitlab_id, _actual_id|
    RubyLLM::Model::Info.new(
      id: gitlab_id,
      name: gitlab_id.tr('-', ' ').capitalize,
      provider: 'gitlab',
      capabilities: %w[function_calling streaming vision structured_output],
      modalities: { input: %w[text image], output: %w[text] }
    )
  end
end

#test_connectionObject



35
36
37
38
39
40
# File 'lib/ruby_llm/providers/gitlab.rb', line 35

def test_connection
  token_manager.token
  true
rescue StandardError
  false
end