Module: Deja::Judges

Defined in:
lib/deja/judges/base.rb,
lib/deja/judges/anthropic.rb

Overview

Judge adapters teach the ‘meet_requirements` matcher how to judge with a given LLM client. An adapter is selected by the type of the object your `judge_client` returns, so the right defaults follow from the provider you chose rather than being assumed globally.

Today an adapter supplies the default request attrs (model, etc.). The matcher still builds the request and parses the response (both Anthropic-shaped); as more judge providers are added, that construction/parsing is meant to move onto the adapter too — which is why dispatch already happens here.

Defined Under Namespace

Classes: Anthropic, Base

Class Method Summary collapse

Class Method Details

.descriptionsObject



40
41
42
# File 'lib/deja/judges/base.rb', line 40

def descriptions
  @registered.map(&:client_description).join(", ")
end

.for_client(client) ⇒ Object

The adapter for the client your ‘judge_client` returned. Raises a helpful error when no registered adapter handles it.



29
30
31
32
33
34
35
36
37
38
# File 'lib/deja/judges/base.rb', line 29

def for_client(client)
  klass = @registered.find {|k| k.handles?(client) }
  klass or raise Deja::Error, <<~MSG
    No Deja judge adapter handles #{client.class} (the object your
    judge_client returned). Deja can judge with: #{descriptions}.
    Point judge_client at one of those, or add a Deja::Judges::Base
    subclass that handles your client.
  MSG
  klass.new(client)
end

.register(klass) ⇒ Object

Built-in judge adapters register themselves. Newest-first, so a more specific adapter registered later can shadow a more general one.



19
20
21
# File 'lib/deja/judges/base.rb', line 19

def register(klass)
  @registered.unshift(klass)
end

.registeredObject



23
24
25
# File 'lib/deja/judges/base.rb', line 23

def registered
  @registered
end