Class: Vellum::MetadataFilterConfigRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/metadata_filter_config_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil, additional_properties: nil) ⇒ MetadataFilterConfigRequest

Parameters:

  • combinator (METADATA_FILTER_RULE_COMBINATOR) (defaults to: nil)
  • negated (Boolean) (defaults to: nil)
  • rules (Array<MetadataFilterRuleRequest>) (defaults to: nil)
  • field (String) (defaults to: nil)
  • operator (LOGICAL_OPERATOR) (defaults to: nil)
  • value (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 20

def initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil,
               additional_properties: nil)
  # @type [METADATA_FILTER_RULE_COMBINATOR]
  @combinator = combinator
  # @type [Boolean]
  @negated = negated
  # @type [Array<MetadataFilterRuleRequest>]
  @rules = rules
  # @type [String]
  @field = field
  # @type [LOGICAL_OPERATOR]
  @operator = operator
  # @type [String]
  @value = value
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def additional_properties
  @additional_properties
end

#combinatorObject (readonly)

Returns the value of attribute combinator.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def combinator
  @combinator
end

#fieldObject (readonly)

Returns the value of attribute field.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def field
  @field
end

#negatedObject (readonly)

Returns the value of attribute negated.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def negated
  @negated
end

#operatorObject (readonly)

Returns the value of attribute operator.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def operator
  @operator
end

#rulesObject (readonly)

Returns the value of attribute rules.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def rules
  @rules
end

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 10

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ MetadataFilterConfigRequest

Deserialize a JSON object to an instance of MetadataFilterConfigRequest

Parameters:

  • json_object (JSON)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 42

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  combinator = METADATA_FILTER_RULE_COMBINATOR.key(parsed_json["combinator"]) || parsed_json["combinator"]
  negated = struct.negated
  rules = parsed_json["rules"].map do |v|
    v = v.to_json
    MetadataFilterRuleRequest.from_json(json_object: v)
  end
  field = struct.field
  operator = LOGICAL_OPERATOR.key(parsed_json["operator"]) || parsed_json["operator"]
  value = struct.value
  new(combinator: combinator, negated: negated, rules: rules, field: field, operator: operator, value: value,
      additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


76
77
78
79
80
81
82
83
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 76

def self.validate_raw(obj:)
  obj.combinator&.is_a?(METADATA_FILTER_RULE_COMBINATOR) != false || raise("Passed value for field obj.combinator is not the expected type, validation failed.")
  obj.negated&.is_a?(Boolean) != false || raise("Passed value for field obj.negated is not the expected type, validation failed.")
  obj.rules&.is_a?(Array) != false || raise("Passed value for field obj.rules is not the expected type, validation failed.")
  obj.field&.is_a?(String) != false || raise("Passed value for field obj.field is not the expected type, validation failed.")
  obj.operator&.is_a?(LOGICAL_OPERATOR) != false || raise("Passed value for field obj.operator is not the expected type, validation failed.")
  obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of MetadataFilterConfigRequest to a JSON object

Returns:

  • (JSON)


61
62
63
64
65
66
67
68
69
70
# File 'lib/vellum_ai/types/metadata_filter_config_request.rb', line 61

def to_json(*_args)
  {
    "combinator": METADATA_FILTER_RULE_COMBINATOR[@combinator] || @combinator,
    "negated": @negated,
    "rules": @rules,
    "field": @field,
    "operator": LOGICAL_OPERATOR[@operator] || @operator,
    "value": @value
  }.to_json
end