Class: Ask::Agent::Test::StubProvider
- Inherits:
-
Object
- Object
- Ask::Agent::Test::StubProvider
- Defined in:
- lib/ask/agent/test.rb
Overview
Stub provider that returns canned responses instead of calling an LLM.
Instance Method Summary collapse
- #chat(messages, model: nil, tools: nil, temperature: nil, stream: nil, schema: nil, **params) ⇒ Object
- #headers ⇒ Object
-
#initialize(mode) ⇒ StubProvider
constructor
A new instance of StubProvider.
Constructor Details
#initialize(mode) ⇒ StubProvider
Returns a new instance of StubProvider.
39 40 41 |
# File 'lib/ask/agent/test.rb', line 39 def initialize(mode) @mode = mode end |
Instance Method Details
#chat(messages, model: nil, tools: nil, temperature: nil, stream: nil, schema: nil, **params) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ask/agent/test.rb', line 43 def chat(, model: nil, tools: nil, temperature: nil, stream: nil, schema: nil, **params) stub = @mode.stubs.shift or raise "No more stubs available. Unconsumed messages: #{.length}" case stub[:type] when :tool_call Ask::Message.new( role: :assistant, content: nil, tool_calls: [{ id: "call_test_#{SecureRandom.hex(4)}", type: "function", name: stub[:name], arguments: JSON.generate(stub[:arguments]) }], metadata: { input_tokens: 10, output_tokens: 5 } ) when :text Ask::Message.new( role: :assistant, content: stub[:content], metadata: { input_tokens: 10, output_tokens: 5 } ) else raise "Unknown stub type: #{stub[:type].inspect}" end end |
#headers ⇒ Object
70 71 72 |
# File 'lib/ask/agent/test.rb', line 70 def headers {} end |