Class: Legion::Extensions::Llm::Gemini::Actor::GeminiCallable
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::Gemini::Actor::GeminiCallable
- Defined in:
- lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb
Overview
Callable wrapper for a Gemini provider instance. Implements the fleet dispatch ops (chat/stream_chat/embed/count_tokens) by delegating to a per-instance Gemini::Provider, plus the disconnect and normalize_dispatch_error contracts required by Inventory::CallableHandle and Routing::ProviderOutcome. Dispatch errors propagate untouched so normalize_dispatch_error can classify them.
Instance Method Summary collapse
-
#chat(messages:, model:, **rest) ⇒ Object
Fleet and SelectionDispatch pass model as a RAW STRING (the offering's model id).
- #count_tokens(messages:, model:, **rest) ⇒ Object
- #disconnect ⇒ Object
- #disconnected? ⇒ Boolean
- #embed(text:, model:, **rest) ⇒ Object
-
#initialize(instance_cfg:, logger:, provider: nil) ⇒ GeminiCallable
constructor
A new instance of GeminiCallable.
- #normalize_dispatch_error(error:) ⇒ Object
- #stream_chat(messages:, model:, **rest) ⇒ Object
Constructor Details
#initialize(instance_cfg:, logger:, provider: nil) ⇒ GeminiCallable
Returns a new instance of GeminiCallable.
940 941 942 943 944 945 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 940 def initialize(instance_cfg:, logger:, provider: nil) @instance_cfg = instance_cfg @logger = logger @provider = provider @disconnected = false end |
Instance Method Details
#chat(messages:, model:, **rest) ⇒ Object
Fleet and SelectionDispatch pass model as a RAW STRING (the offering's model id). Gemini's render path calls model.id (MessageFormatter#render_payload), so a raw string must be wrapped before delegation; Model::Info instances pass through.
959 960 961 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 959 def chat(messages:, model:, **rest) provider.chat(messages: , model: llm_model(model), **rest) end |
#count_tokens(messages:, model:, **rest) ⇒ Object
971 972 973 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 971 def count_tokens(messages:, model:, **rest) provider.count_tokens(messages: , model: llm_model(model), **rest) end |
#disconnect ⇒ Object
949 950 951 952 953 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 949 def disconnect @disconnected = true @provider&.disconnect @logger.debug { '[gemini][callable] disconnected' } end |
#disconnected? ⇒ Boolean
947 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 947 def disconnected? = @disconnected |
#embed(text:, model:, **rest) ⇒ Object
967 968 969 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 967 def (text:, model:, **rest) provider.(text: text, model: llm_model(model), **rest) end |
#normalize_dispatch_error(error:) ⇒ Object
975 976 977 978 979 980 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 975 def normalize_dispatch_error(error:) reason = error..to_s[0, 512] Legion::Extensions::Llm::Routing::ProviderOutcome.new( kind: classify_dispatch_error(error: error), reason: reason.empty? ? 'unknown dispatch error' : reason ) end |
#stream_chat(messages:, model:, **rest) ⇒ Object
963 964 965 |
# File 'lib/legion/extensions/llm/gemini/actors/discovery_refresh.rb', line 963 def stream_chat(messages:, model:, **rest, &) provider.stream_chat(messages: , model: llm_model(model), **rest, &) end |