Class: RSpec::LLM::Matchers::MatchLlmIntent

Inherits:
PassLlmJudge show all
Defined in:
lib/rspec/llm/matchers/match_llm_intent.rb

Overview

Variant of PassLlmJudge that frames the criterion as an intent the response should satisfy. Sugar — the heavy lifting is identical.

Instance Method Summary collapse

Methods inherited from PassLlmJudge

#matches?, #using

Constructor Details

#initialize(intent) ⇒ MatchLlmIntent

Returns a new instance of MatchLlmIntent.



9
10
11
12
# File 'lib/rspec/llm/matchers/match_llm_intent.rb', line 9

def initialize(intent)
  super("The response matches the following intent: #{intent}")
  @intent = intent
end

Instance Method Details

#descriptionObject



14
15
16
# File 'lib/rspec/llm/matchers/match_llm_intent.rb', line 14

def description
  "match LLM intent: #{@intent.inspect}"
end

#failure_messageObject



18
19
20
21
# File 'lib/rspec/llm/matchers/match_llm_intent.rb', line 18

def failure_message
  "expected response to match intent #{@intent.inspect}, " \
    "but judge said: #{format_reason}\n\nResponse:\n#{@actual}"
end

#failure_message_when_negatedObject



23
24
25
26
# File 'lib/rspec/llm/matchers/match_llm_intent.rb', line 23

def failure_message_when_negated
  "expected response NOT to match intent #{@intent.inspect}, " \
    "but judge said: #{format_reason}\n\nResponse:\n#{@actual}"
end