Class: ActiveGenie::Comparator::Fight

Inherits:
Debate show all
Defined in:
lib/active_genie/comparator/fight.rb

Overview

The Fight class are comparation specialized in a fight between two fighters, like martial arts, heroes, characters. The fight evaluation process simulate a fight using words, techniques, strategies, and reasoning.

Examples:

Fight usage with two fighters and criteria

Fight.call("Naruto", "Sasuke", "How can win without using jutsu?")

Constant Summary collapse

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

Instance Method Summary collapse

Methods inherited from Debate

#initialize

Methods inherited from BaseModule

call, #config, #initialize, #module_config

Constructor Details

This class inherits a constructor from ActiveGenie::Comparator::Debate

Instance Method Details

#callComparatorResponse

Returns The evaluation result containing the winner and reasoning.

Returns:

  • (ComparatorResponse)

    The evaluation result containing the winner and reasoning



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/active_genie/comparator/fight.rb', line 16

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