Class: Riffer::Providers::Test
- Defined in:
- lib/riffer/providers/test.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
Instance Method Summary collapse
-
#clear_stubs ⇒ Object
Clears all stubbed responses.
-
#initialize(**options) ⇒ Test
constructor
A new instance of Test.
-
#stub_response(content, tool_calls: []) ⇒ Object
Stubs the next response from the provider Can be called multiple times to queue responses.
Methods inherited from Base
Methods included from Messages::Converter
Constructor Details
#initialize(**options) ⇒ Test
Returns a new instance of Test.
6 7 8 9 10 11 |
# File 'lib/riffer/providers/test.rb', line 6 def initialize(**) @responses = [:responses] || [] @current_index = 0 @calls = [] @stubbed_responses = [] end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
4 5 6 |
# File 'lib/riffer/providers/test.rb', line 4 def calls @calls end |
Instance Method Details
#clear_stubs ⇒ Object
Clears all stubbed responses
34 35 36 |
# File 'lib/riffer/providers/test.rb', line 34 def clear_stubs @stubbed_responses = [] end |
#stub_response(content, tool_calls: []) ⇒ Object
Stubs the next response from the provider Can be called multiple times to queue responses
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/riffer/providers/test.rb', line 21 def stub_response(content, tool_calls: []) formatted_tool_calls = tool_calls.map.with_index do |tc, idx| { id: tc[:id] || "test_id_#{idx}", call_id: tc[:call_id] || tc[:id] || "test_call_#{idx}", name: tc[:name], arguments: tc[:arguments].is_a?(String) ? tc[:arguments] : tc[:arguments].to_json } end @stubbed_responses << {role: "assistant", content: content, tool_calls: formatted_tool_calls} end |