Class: Legion::Extensions::Llm::Vllm::Provider

Inherits:
Provider
  • Object
show all
Includes:
Provider::OpenAICompatible
Defined in:
lib/legion/extensions/llm/vllm/provider.rb

Overview

vLLM provider implementation for the Legion::Extensions::Llm base provider contract.

Defined Under Namespace

Modules: Capabilities

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.capabilitiesObject



19
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 19

def capabilities = Capabilities

.configuration_optionsObject



17
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 17

def configuration_options = %i[vllm_api_base vllm_api_key]

.configuration_requirementsObject



18
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 18

def configuration_requirements = []

.local?Boolean

Returns:

  • (Boolean)


16
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 16

def local? = true

.slugObject



15
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 15

def slug = 'vllm'

Instance Method Details

#api_baseObject



42
43
44
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 42

def api_base
  config.vllm_api_base || 'http://localhost:8000'
end

#headersObject



46
47
48
49
50
51
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 46

def headers
  token = config.vllm_api_key
  return {} if token.nil? || token.to_s.empty?

  { 'Authorization' => "Bearer #{token}" }
end

#healthObject



60
61
62
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 60

def health
  connection.get(health_url).body
end

#health_urlObject



53
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 53

def health_url = '/health'

#reset_mm_cacheObject



72
73
74
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 72

def reset_mm_cache
  connection.post(reset_mm_cache_url, {}).body
end

#reset_mm_cache_urlObject



56
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 56

def reset_mm_cache_url = '/reset_mm_cache'

#reset_prefix_cache(reset_running_requests: nil, reset_external: nil) ⇒ Object



68
69
70
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 68

def reset_prefix_cache(reset_running_requests: nil, reset_external: nil)
  connection.post(with_query(reset_prefix_cache_url, reset_running_requests:, reset_external:), {}).body
end

#reset_prefix_cache_urlObject



55
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 55

def reset_prefix_cache_url = '/reset_prefix_cache'

#sleep(level: 1) ⇒ Object



76
77
78
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 76

def sleep(level: 1)
  connection.post(with_query(sleep_url, level:), {}).body
end

#sleep_urlObject



57
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 57

def sleep_url = '/sleep'

#versionObject



64
65
66
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 64

def version
  connection.get(version_url).body
end

#version_urlObject



54
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 54

def version_url = '/version'

#wake_up(tags: nil) ⇒ Object



80
81
82
83
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 80

def wake_up(tags: nil)
  query = Array(tags).map { |tag| ['tags', tag] }
  connection.post(with_query(wake_up_url, query), {}).body
end

#wake_up_urlObject



58
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 58

def wake_up_url = '/wake_up'