Class: MockServer::LLM::LlmMockBuilder
- Inherits:
-
Object
- Object
- MockServer::LLM::LlmMockBuilder
- Defined in:
- lib/mockserver/llm.rb
Overview
LlmMockBuilder — a single completion or embedding mock.
Instance Method Summary collapse
-
#apply_to(client) ⇒ Array<Expectation>
Build and register the expectation via
client.upsert. -
#build ⇒ Hash
A single expectation.
-
#initialize(path) ⇒ LlmMockBuilder
constructor
A new instance of LlmMockBuilder.
- #responding_with(response) ⇒ self
- #with_model(model) ⇒ self
- #with_provider(provider) ⇒ self
Constructor Details
#initialize(path) ⇒ LlmMockBuilder
Returns a new instance of LlmMockBuilder.
449 450 451 452 453 454 455 |
# File 'lib/mockserver/llm.rb', line 449 def initialize(path) @path = path @provider = nil @model = nil @completion = nil @embedding = nil end |
Instance Method Details
#apply_to(client) ⇒ Array<Expectation>
Build and register the expectation via client.upsert.
492 493 494 |
# File 'lib/mockserver/llm.rb', line 492 def apply_to(client) client.upsert(RawExpectation.new(build)) end |
#build ⇒ Hash
Returns a single expectation.
483 484 485 486 487 488 |
# File 'lib/mockserver/llm.rb', line 483 def build { 'httpRequest' => LLM.post_matcher(@path), 'httpLlmResponse' => LLM.build_llm_response(@provider, @model, @completion, @embedding, nil, nil) } end |
#responding_with(response) ⇒ self
471 472 473 474 475 476 477 478 479 480 |
# File 'lib/mockserver/llm.rb', line 471 def responding_with(response) if response.is_a?(EmbeddingResponse) @embedding = response @completion = nil else @completion = response @embedding = nil end self end |
#with_model(model) ⇒ self
464 465 466 467 |
# File 'lib/mockserver/llm.rb', line 464 def with_model(model) @model = model self end |
#with_provider(provider) ⇒ self
458 459 460 461 |
# File 'lib/mockserver/llm.rb', line 458 def with_provider(provider) @provider = provider self end |