Class: RubyLLM::Providers::GitLab::AnthropicDelegate

Inherits:
Anthropic
  • Object
show all
Includes:
Chat
Defined in:
lib/ruby_llm/providers/gitlab/anthropic_delegate.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chat

#render_payload

Class Method Details

.configuration_optionsObject



32
33
34
# File 'lib/ruby_llm/providers/gitlab/anthropic_delegate.rb', line 32

def configuration_options
  i[gitlab_api_key gitlab_instance_url gitlab_gateway_url]
end

.configuration_requirementsObject



28
29
30
# File 'lib/ruby_llm/providers/gitlab/anthropic_delegate.rb', line 28

def configuration_requirements
  i[gitlab_api_key]
end

Instance Method Details

#api_baseObject



9
10
11
# File 'lib/ruby_llm/providers/gitlab/anthropic_delegate.rb', line 9

def api_base
  token_manager.anthropic_base_url
end

#completeObject



20
21
22
23
24
25
# File 'lib/ruby_llm/providers/gitlab/anthropic_delegate.rb', line 20

def complete(...)
  super
rescue RubyLLM::UnauthorizedError
  token_manager.invalidate!
  super
end

#headersObject



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

def headers
  {
    'Authorization' => "Bearer #{token_manager.token}",
    'anthropic-version' => '2023-06-01'
  }.merge(token_manager.gateway_headers)
end