Class: Retab::AnyItemMatchesCondition

Inherits:
Types::BaseModel
  • Object
show all
Defined in:
lib/retab/workflow_evals/any_item_matches_condition.rb

Constant Summary collapse

HASH_ATTRS =
{
  kind: :kind,
  condition: :condition
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ AnyItemMatchesCondition

Returns a new instance of AnyItemMatchesCondition.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/retab/workflow_evals/any_item_matches_condition.rb', line 18

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @kind = hash[:kind].nil? ? "any_item_matches" : hash[:kind]
  @condition = hash[:condition] ? (
    case hash[:condition][:kind]
    when "all_items_match"
      Retab::AllItemsMatchCondition.new(hash[:condition])
    when "any_item_matches"
      Retab::AnyItemMatchesCondition.new(hash[:condition])
    when "array_contains"
      Retab::ArrayContainsCondition.new(hash[:condition])
    when "between"
      Retab::BetweenCondition.new(hash[:condition])
    when "ends_with"
      Retab::EndsWithCondition.new(hash[:condition])
    when "json_schema_valid"
      Retab::JsonSchemaValidCondition.new(hash[:condition])
    when "length_compare"
      Retab::LengthCompareCondition.new(hash[:condition])
    when "llm_judged_as"
      Retab::LlmJudgedAsCondition.new(hash[:condition])
    when "llm_not_judged_as"
      Retab::LlmNotJudgedAsCondition.new(hash[:condition])
    when "not_contains"
      Retab::NotContainsCondition.new(hash[:condition])
    when "not_equals"
      Retab::NotEqualsCondition.new(hash[:condition])
    when "not_exists"
      Retab::NotExistsCondition.new(hash[:condition])
    when "number_compare"
      Retab::NumberCompareCondition.new(hash[:condition])
    when "object_contains"
      Retab::ObjectContainsCondition.new(hash[:condition])
    when "similarity_gte"
      Retab::SimilarityGteCondition.new(hash[:condition])
    else
      hash[:condition]
    end
  ) : nil
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



13
14
15
# File 'lib/retab/workflow_evals/any_item_matches_condition.rb', line 13

def condition
  @condition
end

#kindObject

Returns the value of attribute kind.



13
14
15
# File 'lib/retab/workflow_evals/any_item_matches_condition.rb', line 13

def kind
  @kind
end