Class: Legion::Extensions::Llm::Vllm::Provider
- Inherits:
-
LexLLM::Provider
- Object
- LexLLM::Provider
- Legion::Extensions::Llm::Vllm::Provider
- 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
- .capabilities ⇒ Object
- .configuration_options ⇒ Object
- .configuration_requirements ⇒ Object
- .local? ⇒ Boolean
- .slug ⇒ Object
Instance Method Summary collapse
- #api_base ⇒ Object
- #headers ⇒ Object
- #health ⇒ Object
- #health_url ⇒ Object
- #reset_mm_cache ⇒ Object
- #reset_mm_cache_url ⇒ Object
- #reset_prefix_cache(reset_running_requests: nil, reset_external: nil) ⇒ Object
- #reset_prefix_cache_url ⇒ Object
- #sleep(level: 1) ⇒ Object
- #sleep_url ⇒ Object
- #version ⇒ Object
- #version_url ⇒ Object
- #wake_up(tags: nil) ⇒ Object
- #wake_up_url ⇒ Object
Class Method Details
.capabilities ⇒ Object
19 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 19 def capabilities = Capabilities |
.configuration_options ⇒ Object
17 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 17 def = %i[vllm_api_base vllm_api_key] |
.configuration_requirements ⇒ Object
18 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 18 def configuration_requirements = [] |
.local? ⇒ Boolean
16 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 16 def local? = true |
.slug ⇒ Object
15 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 15 def slug = 'vllm' |
Instance Method Details
#api_base ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 33 def api_base config.vllm_api_base || 'http://localhost:8000' end |
#headers ⇒ Object
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 |
#health ⇒ Object
51 52 53 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 51 def health connection.get(health_url).body end |
#health_url ⇒ Object
44 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 44 def health_url = '/health' |
#reset_mm_cache ⇒ Object
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_url ⇒ Object
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_url ⇒ Object
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_url ⇒ Object
48 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 48 def sleep_url = '/sleep' |
#version ⇒ Object
55 56 57 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 55 def version connection.get(version_url).body end |
#version_url ⇒ Object
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().map { |tag| ['tags', tag] } connection.post(with_query(wake_up_url, query), {}).body end |
#wake_up_url ⇒ Object
49 |
# File 'lib/legion/extensions/llm/vllm/provider.rb', line 49 def wake_up_url = '/wake_up' |