Class: Brute::MessageTransport::OpenRouter
- Inherits:
-
MessageTransport
- Object
- MessageTransport
- Brute::MessageTransport::OpenRouter
- Defined in:
- lib/brute/message_transport/open_router.rb
Overview
MessageTransport for the open_router_enhanced gem (https://github.com/estiens/open_router_enhanced). Brute does not require it — you do:
require "open_router"
Class Method Summary collapse
- .dump(message) ⇒ Object
-
.usage_metrics(response) ⇒ Object
What the provider reported about this call — the transport knows its own library's shape, so it knows which detector to ask.
Instance Method Summary collapse
-
#messages ⇒ Object
An OpenRouter::Response's messages (one per choice; in practice OpenRouter returns exactly one).
Class Method Details
.dump(message) ⇒ Object
22 23 24 |
# File 'lib/brute/message_transport/open_router.rb', line 22 def self.dump() .to_h end |
.usage_metrics(response) ⇒ Object
What the provider reported about this call — the transport knows its own library's shape, so it knows which detector to ask.
19 20 21 |
# File 'lib/brute/message_transport/open_router.rb', line 19 def self.usage_metrics(response) Brute::UsageDetection::OpenRouter.detect(response) end |
Instance Method Details
#messages ⇒ Object
An OpenRouter::Response's messages (one per choice; in practice OpenRouter returns exactly one).
28 29 30 31 32 |
# File 'lib/brute/message_transport/open_router.rb', line 28 def return @result.choices.map { |choice| choice["message"] || choice[:message] } if @result.respond_to?(:choices) super end |