Module: Legion::LLM::Call::Dispatch
- Extended by:
- Dispatch, Legion::Logging::Helper
- Included in:
- Dispatch
- Defined in:
- lib/legion/llm/call/dispatch.rb
Instance Method Summary collapse
-
#available?(provider) ⇒ Boolean
Returns true when the provider is registered in Registry.
-
#dispatch_chat(provider:, model:, messages:) ⇒ Hash
Dispatch a chat request to a registered lex-* extension.
-
#dispatch_count_tokens(provider:, model:, messages:) ⇒ Hash
Dispatch a token count request to a registered lex-* extension.
-
#dispatch_embed(provider:, model:, text:) ⇒ Hash
Dispatch an embedding request to a registered lex-* extension.
-
#dispatch_stream(provider:, model:, messages:) ⇒ Hash
Dispatch a streaming chat request to a registered lex-* extension.
Instance Method Details
#available?(provider) ⇒ Boolean
Returns true when the provider is registered in Registry.
91 92 93 |
# File 'lib/legion/llm/call/dispatch.rb', line 91 def available?(provider) Registry.registered?(provider) end |
#dispatch_chat(provider:, model:, messages:) ⇒ Hash
Dispatch a chat request to a registered lex-* extension.
37 38 39 40 41 42 |
# File 'lib/legion/llm/call/dispatch.rb', line 37 def dispatch_chat(provider:, model:, messages:, **) ext = fetch_extension!(provider) log.info("[llm][native] dispatch_chat provider=#{provider} model=#{model} messages=#{.size}") raw = ext.chat(model: model, messages: , **) normalize_response(raw) end |
#dispatch_count_tokens(provider:, model:, messages:) ⇒ Hash
Dispatch a token count request to a registered lex-* extension.
80 81 82 83 84 85 |
# File 'lib/legion/llm/call/dispatch.rb', line 80 def dispatch_count_tokens(provider:, model:, messages:, **) ext = fetch_extension!(provider) log.debug("[llm][native] dispatch_count_tokens provider=#{provider} model=#{model} messages=#{.size}") raw = ext.count_tokens(model: model, messages: , **) normalize_response(raw) end |
#dispatch_embed(provider:, model:, text:) ⇒ Hash
Dispatch an embedding request to a registered lex-* extension.
51 52 53 54 55 56 |
# File 'lib/legion/llm/call/dispatch.rb', line 51 def (provider:, model:, text:, **) ext = fetch_extension!(provider) log.info("[llm][native] dispatch_embed provider=#{provider} model=#{model} text_chars=#{text.to_s.length}") raw = ext.(model: model, text: text, **) normalize_response(raw) end |
#dispatch_stream(provider:, model:, messages:) ⇒ Hash
Dispatch a streaming chat request to a registered lex-* extension.
66 67 68 69 70 71 |
# File 'lib/legion/llm/call/dispatch.rb', line 66 def dispatch_stream(provider:, model:, messages:, **, &) ext = fetch_extension!(provider) log.info("[llm][native] dispatch_stream provider=#{provider} model=#{model} messages=#{.size}") raw = ext.stream(model: model, messages: , **, &) normalize_response(raw) end |