class RubyLLM
Completion backed by the ruby_llm gem (Brute's default). Calls the LLM with the current conversation, appends the response to the session, and fires events along the way.
Configuration happens at point of use and falls back to env for anything not given, so an Agent's provider/model/tools still flow through when the middleware is used bare:
Brute::Agent.new(provider: :ollama, model: "llama3.2:latest") do use Brute::Middleware::ToolCall run Brute::Middleware::Completion::RubyLLM.new end
or fully configured at point of use:
run Brute::Middleware::Completion::RubyLLM.new( provider: :ollama, model: "llama3.2:latest", tools: [], temperature: 0.7, streaming: true, )
Options:
provider: LLM provider name (falls back to env[:provider]) model: model id (falls back to env[:model]) tools: tools list, any shape Tools::Adapter accepts temperature: sampling temperature (default 0.7) streaming: stream chunks as :content / :reasoning events client: injectable completion client (tests, custom transports); anything responding to complete(messages, **kwargs)
Definitions
def resolve_model(model, provider)
Look the model up in ruby_llm's registry; fall back to the raw id for models the registry doesn't know (custom endpoints, injected clients).
Implementation
def resolve_model(model, provider)
::RubyLLM.models.find(model, provider)
rescue StandardError
model
end