Class: Anthropic::Helpers::Tools::Runner Private
- Inherits:
-
Object
- Object
- Anthropic::Helpers::Tools::Runner
- Defined in:
- lib/anthropic/helpers/tools/runner.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #each_message {|| ... } ⇒ void private
- #each_streaming {|| ... } ⇒ void private
- #feed_messages(*messages) ⇒ void private
- #finished? ⇒ Boolean private
-
#initialize(client, params:, max_iterations: nil, compaction_control: nil) ⇒ Runner
constructor
private
A new instance of Runner.
- #next_message ⇒ Anthropic::Models::BetaMessage? private
- #run_until_finished ⇒ Array<Anthropic::Models::BetaMessage> private
Constructor Details
#initialize(client, params:, max_iterations: nil, compaction_control: nil) ⇒ Runner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Runner.
249 250 251 252 253 254 255 256 257 258 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 249 def initialize(client, params:, max_iterations: nil, compaction_control: nil) @client = client @params = params.to_h @finished = false @max_iterations = max_iterations @iteration_count = 0 @compaction_control = compaction_control @compaction_warned = false @last_response = nil end |
Instance Attribute Details
#params ⇒ Anthropic::Models::Beta::MessageCreateParams
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 10 def params @params end |
Instance Method Details
#each_message {|| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 43 def (&blk) unless block_given? raise ArgumentError.new("A block must be given to ##{__method__}") end fold do = @client.beta..create(with_helper_header(_1, "runner")) blk.call() [false, ] end end |
#each_streaming {|| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 56 def each_streaming(&blk) unless block_given? raise ArgumentError.new("A block must be given to ##{__method__}") end fold do stream = @client.beta..stream(with_helper_header(_1, "runner")) blk.call(stream) [false, stream.] ensure stream&.close end end |
#feed_messages(*messages) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 16 def (*) self.params = {**params.to_h, messages: params[:messages].to_a + } end |
#finished? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 13 def finished? = @finished |
#next_message ⇒ Anthropic::Models::BetaMessage?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 24 def = nil unless finished? fold do = @client.beta..create(with_helper_header(_1, "runner")) [true, ] end end end |
#run_until_finished ⇒ Array<Anthropic::Models::BetaMessage>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 |
# File 'lib/anthropic/helpers/tools/runner.rb', line 36 def run_until_finished = [] each_streaming { << _1. } end |