Class: BruteCLI::Providers::ShellResponse
- Inherits:
-
Object
- Object
- BruteCLI::Providers::ShellResponse
- Defined in:
- lib/brute_cli/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 agent loop 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 agent 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.
21 22 23 24 25 |
# File 'lib/brute_cli/providers/shell_response.rb', line 21 def initialize(command: nil, model: "bash", tools: []) @command = command @model_name = model @tools = tools || [] end |
Instance Method Details
#content ⇒ Object
67 68 69 70 |
# File 'lib/brute_cli/providers/shell_response.rb', line 67 def content msg = .find { |m| m.role == :assistant } msg&.content end |
#content! ⇒ Object
72 73 74 |
# File 'lib/brute_cli/providers/shell_response.rb', line 72 def content! JSON.parse(content) end |
#input_tokens ⇒ Object
51 52 53 |
# File 'lib/brute_cli/providers/shell_response.rb', line 51 def input_tokens 0 end |
#messages ⇒ Object Also known as: choices
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/brute_cli/providers/shell_response.rb', line 27 def return [empty_assistant] if @command.nil? call_id = "shell_#{SecureRandom.hex(8)}" tool_calls = { call_id => RubyLLM::ToolCall.new( id: call_id, name: "shell", arguments: { "command" => @command }, ) } [RubyLLM::Message.new( role: :assistant, content: "", tool_calls: tool_calls, )] end |
#model ⇒ Object
47 48 49 |
# File 'lib/brute_cli/providers/shell_response.rb', line 47 def model @model_name end |
#output_tokens ⇒ Object
55 56 57 |
# File 'lib/brute_cli/providers/shell_response.rb', line 55 def output_tokens 0 end |
#reasoning_content ⇒ Object
76 77 78 |
# File 'lib/brute_cli/providers/shell_response.rb', line 76 def reasoning_content nil end |
#reasoning_tokens ⇒ Object
59 60 61 |
# File 'lib/brute_cli/providers/shell_response.rb', line 59 def reasoning_tokens 0 end |
#total_tokens ⇒ Object
63 64 65 |
# File 'lib/brute_cli/providers/shell_response.rb', line 63 def total_tokens 0 end |
#usage ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/brute_cli/providers/shell_response.rb', line 80 def usage RubyLLM::Tokens.new( input: 0, output: 0, reasoning: 0, ) end |