class ActiveGenie::Battle::Basic


Basic.call(“Player A content”, “Player B content”, “Evaluate keyword usage and pattern matching”)
@example Basic usage with two players and criteria
and returns detailed feedback including the winner and reasoning for the decision.
The battle evaluation process compares two players’ content against given criteria
analyzing how well each player meets the requirements.
using AI-powered evaluation. It determines a winner based on specified criteria,
The Basic class provides a foundation for evaluating battles between two players

def self.call(...)

def self.call(...)
  new(...).call
end

def call

def call
  messages = [
    {  role: 'system', content: PROMPT },
    {  role: 'user', content: "criteria: #{@criteria}" },
    {  role: 'user', content: "player_1: #{@player_1}" },
    {  role: 'user', content: "player_2: #{@player_2}" },
  ]
  response = ::ActiveGenie::Clients::UnifiedClient.function_calling(
    messages,
    FUNCTION,
    model_tier: 'lower_tier',
    config: @config
  )
  ActiveGenie::Logger.debug({
    code: :battle,
    player_1: @player_1[0..30],
    player_2: @player_2[0..30],
    criteria: @criteria[0..30],
    winner: response['impartial_judge_winner'],
    reasoning: response['impartial_judge_winner_reasoning']
  })
  response_formatted(response)
end

def initialize(player_1, player_2, criteria, config: {})

Returns:
  • (String) - :what_could_be_changed_to_avoid_draw A suggestion on how to avoid a draw
  • (String) - :reasoning Detailed explanation of why the winner was chosen
  • (String) - :winner The winner, either player_1 or player_2
  • (Hash) - The evaluation result containing the winner and reasoning

Parameters:
  • config (Hash) -- Additional configuration options that modify the battle evaluation behavior
  • criteria (String) -- The evaluation criteria or rules to assess against
  • player_2 (String) -- The content or submission from the second player
  • player_1 (String) -- The content or submission from the first player
def initialize(player_1, player_2, criteria, config: {})
  @player_1 = player_1
  @player_2 = player_2
  @criteria = criteria
  @config = ActiveGenie::Configuration.to_h(config)
end

def response_formatted(response)

def response_formatted(response)
  winner = response['impartial_judge_winner']
  loser = case response['impartial_judge_winner']
          when 'player_1' then 'player_2'
          when 'player_2' then 'player_1'
          end
  { 'winner' => winner, 'loser' => loser, 'reasoning' => response['impartial_judge_winner_reasoning'] }
end