Class: RSpec::LLM::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/llm/configuration.rb

Overview

Holds gem-wide configuration: the default client used by specs, the judge model used by LLM-as-judge matchers, an embedder callable used by the similarity matcher, and tunable thresholds/prompts.

Constant Summary collapse

DEFAULT_SIMILARITY_THRESHOLD =
0.8
DEFAULT_JUDGE_PROMPT =
<<~PROMPT
  You are a strict evaluator. Read the response and decide whether it satisfies the criterion.
  Reply with YES or NO on the first line, then a single short sentence explaining your decision.

  Response:
  %<response>s

  Criterion:
  %<criterion>s
PROMPT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
27
# File 'lib/rspec/llm/configuration.rb', line 24

def initialize
  @similarity_threshold = DEFAULT_SIMILARITY_THRESHOLD
  @judge_prompt_template = DEFAULT_JUDGE_PROMPT
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



22
23
24
# File 'lib/rspec/llm/configuration.rb', line 22

def client
  @client
end

#embedderObject

Returns the value of attribute embedder.



22
23
24
# File 'lib/rspec/llm/configuration.rb', line 22

def embedder
  @embedder
end

#judgeObject

Returns the value of attribute judge.



22
23
24
# File 'lib/rspec/llm/configuration.rb', line 22

def judge
  @judge
end

#judge_prompt_templateObject

Returns the value of attribute judge_prompt_template.



22
23
24
# File 'lib/rspec/llm/configuration.rb', line 22

def judge_prompt_template
  @judge_prompt_template
end

#similarity_thresholdObject

Returns the value of attribute similarity_threshold.



22
23
24
# File 'lib/rspec/llm/configuration.rb', line 22

def similarity_threshold
  @similarity_threshold
end

Instance Method Details

#client_adapterObject



29
30
31
32
33
# File 'lib/rspec/llm/configuration.rb', line 29

def client_adapter
  return nil if client.nil?

  Adapters::Base.wrap(client)
end

#judge_adapterObject



35
36
37
38
39
# File 'lib/rspec/llm/configuration.rb', line 35

def judge_adapter
  return nil if judge.nil?

  Adapters::Base.wrap(judge)
end