Class: Brute::Providers::ShellResponse
- Inherits:
-
Object
- Object
- Brute::Providers::ShellResponse
- Includes:
- LLM::Contract::Completion
- Defined in:
- lib/brute/providers/shell_response.rb
Overview
Synthetic completion response returned by Brute::Providers::Shell.
When command is present, the response contains a single assistant message with a “shell” tool call. The orchestrator picks it up and executes Brute::Tools::Shell through the normal pipeline.
When command is nil (tool results round-trip), the response contains an empty assistant message with no tool calls, causing the orchestrator loop to exit.
Instance Method Summary collapse
- #content ⇒ Object
- #content! ⇒ Object
-
#initialize(command: nil, model: "bash", tools: []) ⇒ ShellResponse
constructor
A new instance of ShellResponse.
- #input_tokens ⇒ Object
- #messages ⇒ Object (also: #choices)
- #model ⇒ Object
- #output_tokens ⇒ Object
- #reasoning_content ⇒ Object
- #reasoning_tokens ⇒ Object
- #total_tokens ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(command: nil, model: "bash", tools: []) ⇒ ShellResponse
Returns a new instance of ShellResponse.
23 24 25 26 27 |
# File 'lib/brute/providers/shell_response.rb', line 23 def initialize(command: nil, model: "bash", tools: []) @command = command @model_name = model @tools = tools || [] end |
Instance Method Details
#content ⇒ Object
73 74 75 |
# File 'lib/brute/providers/shell_response.rb', line 73 def content .find(&:assistant?)&.content end |
#content! ⇒ Object
77 78 79 |
# File 'lib/brute/providers/shell_response.rb', line 77 def content! LLM.json.load(content) end |
#input_tokens ⇒ Object
57 58 59 |
# File 'lib/brute/providers/shell_response.rb', line 57 def input_tokens 0 end |
#messages ⇒ Object Also known as: choices
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/brute/providers/shell_response.rb', line 29 def return [empty_assistant] if @command.nil? call_id = "shell_#{SecureRandom.hex(8)}" tool_call = LLM::Object.from( id: call_id, name: "shell", arguments: { "command" => @command }, ) original = [{ "type" => "tool_use", "id" => call_id, "name" => "shell", "input" => { "command" => @command }, }] [LLM::Message.new(:assistant, "", { tool_calls: [tool_call], original_tool_calls: original, tools: @tools, })] end |
#model ⇒ Object
53 54 55 |
# File 'lib/brute/providers/shell_response.rb', line 53 def model @model_name end |
#output_tokens ⇒ Object
61 62 63 |
# File 'lib/brute/providers/shell_response.rb', line 61 def output_tokens 0 end |
#reasoning_content ⇒ Object
81 82 83 |
# File 'lib/brute/providers/shell_response.rb', line 81 def reasoning_content nil end |
#reasoning_tokens ⇒ Object
65 66 67 |
# File 'lib/brute/providers/shell_response.rb', line 65 def reasoning_tokens 0 end |
#total_tokens ⇒ Object
69 70 71 |
# File 'lib/brute/providers/shell_response.rb', line 69 def total_tokens 0 end |
#usage ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/brute/providers/shell_response.rb', line 85 def usage LLM::Usage.new( input_tokens: 0, output_tokens: 0, reasoning_tokens: 0, total_tokens: 0, ) end |