Class: AISpec::Core::Providers::Mock
- Defined in:
- lib/aispec/core/providers/mock.rb
Instance Attribute Summary collapse
-
#canned_cost ⇒ Object
Returns the value of attribute canned_cost.
-
#canned_latency_ms ⇒ Object
Returns the value of attribute canned_latency_ms.
-
#canned_response ⇒ Object
Returns the value of attribute canned_response.
-
#canned_tools ⇒ Object
Returns the value of attribute canned_tools.
Attributes inherited from Base
Instance Method Summary collapse
- #generate(prompt, **params) ⇒ Object
-
#initialize(model: "mock-model", canned_response: nil, canned_latency_ms: 120.0, canned_cost: 0.001, canned_tools: [], **options) ⇒ Mock
constructor
A new instance of Mock.
Methods inherited from Base
Constructor Details
#initialize(model: "mock-model", canned_response: nil, canned_latency_ms: 120.0, canned_cost: 0.001, canned_tools: [], **options) ⇒ Mock
Returns a new instance of Mock.
9 10 11 12 13 14 15 |
# File 'lib/aispec/core/providers/mock.rb', line 9 def initialize(model: "mock-model", canned_response: nil, canned_latency_ms: 120.0, canned_cost: 0.001, canned_tools: [], **) super(model: model, **) @canned_response = canned_response @canned_latency_ms = canned_latency_ms @canned_cost = canned_cost @canned_tools = canned_tools end |
Instance Attribute Details
#canned_cost ⇒ Object
Returns the value of attribute canned_cost.
7 8 9 |
# File 'lib/aispec/core/providers/mock.rb', line 7 def canned_cost @canned_cost end |
#canned_latency_ms ⇒ Object
Returns the value of attribute canned_latency_ms.
7 8 9 |
# File 'lib/aispec/core/providers/mock.rb', line 7 def canned_latency_ms @canned_latency_ms end |
#canned_response ⇒ Object
Returns the value of attribute canned_response.
7 8 9 |
# File 'lib/aispec/core/providers/mock.rb', line 7 def canned_response @canned_response end |
#canned_tools ⇒ Object
Returns the value of attribute canned_tools.
7 8 9 |
# File 'lib/aispec/core/providers/mock.rb', line 7 def canned_tools @canned_tools end |
Instance Method Details
#generate(prompt, **params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aispec/core/providers/mock.rb', line 17 def generate(prompt, **params) output = @canned_response || params[:canned_response] || default_mock_output(prompt) latency = params[:latency_ms] || @canned_latency_ms cost = params[:cost] || @canned_cost tools = params[:tools_called] || @canned_tools tokens = (output.to_s.split.length * 1.3).to_i build_response( output: output, latency_ms: latency, tokens: tokens, cost: cost, tools_called: tools, raw: { mock: true } ) end |