Class: ActiveGenie::Comparator::Debate

Inherits:
BaseModule
  • Object
show all
Defined in:
lib/active_genie/comparator/debate.rb

Overview

The Debate class provides a foundation for evaluating comparators between two players using AI-powered evaluation. It determines a winner based on specified criteria, analyzing how well each player meets the requirements.

The comparator evaluation process compares two players’ content against given criteria and returns detailed feedback including the winner and reasoning for the decision.

Examples:

Debate usage with two players and criteria

Debate.call("Player A content", "Player B content", "Evaluate keyword usage and pattern matching")

Direct Known Subclasses

Fight

Constant Summary collapse

PROMPT =
File.read(File.join(__dir__, 'debate.prompt.md'))
FUNCTION =
JSON.parse(File.read(File.join(__dir__, 'debate.json')), symbolize_names: true)

Instance Method Summary collapse

Methods inherited from BaseModule

call, #config

Constructor Details

#initialize(player_a, player_b, criteria, config: {}) ⇒ ComparatorResponse

Returns The evaluation result containing the winner and reasoning @return [String] :winner The winner, either player_a or player_b @return [String] :reasoning Detailed explanation of why the winner was chosen @return [String] :what_could_be_changed_to_avoid_draw A suggestion on how to avoid a draw.

Parameters:

  • player_a (String)

    The content or submission from the first player

  • player_b (String)

    The content or submission from the second player

  • criteria (String)

    The evaluation criteria or rules to assess against

  • config (Hash) (defaults to: {})

    Additional configuration options that modify the comparator evaluation behavior



26
27
28
29
30
31
# File 'lib/active_genie/comparator/debate.rb', line 26

def initialize(player_a, player_b, criteria, config: {})
  @player_a = player_a
  @player_b = player_b
  @criteria = criteria
  super(config:)
end

Instance Method Details

#callComparatorResponse

Returns The evaluation result containing the winner and reasoning.

Returns:

  • (ComparatorResponse)

    The evaluation result containing the winner and reasoning



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_genie/comparator/debate.rb', line 34

def call
  messages = [
    {  role: 'system', content: PROMPT },
    {  role: 'user', content: "player_a: #{@player_a}" },
    {  role: 'user', content: "player_b: #{@player_b}" },
    {  role: 'user', content: "criteria: #{@criteria}" }
  ]

  provider_response = ::ActiveGenie::Providers::UnifiedProvider.function_calling(messages, FUNCTION, config:)

  response_formatted(provider_response)
end