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

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

Overview

vLLM provider implementation for the LexLLM 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



33
34
35
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 33

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

#headersObject



37
38
39
40
41
42
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 37

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

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

#healthObject



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

def health
  connection.get(health_url).body
end

#health_urlObject



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

def health_url = '/health'

#reset_mm_cacheObject



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

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

#reset_mm_cache_urlObject



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

def reset_mm_cache_url = '/reset_mm_cache'

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



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

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



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

def reset_prefix_cache_url = '/reset_prefix_cache'

#sleep(level: 1) ⇒ Object



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

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

#sleep_urlObject



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

def sleep_url = '/sleep'

#versionObject



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

def version
  connection.get(version_url).body
end

#version_urlObject



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

def version_url = '/version'

#wake_up(tags: nil) ⇒ Object



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

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



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

def wake_up_url = '/wake_up'