Class: Vellum::FunctionDefinition

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

Overview

to.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state: OMIT, cache_config: OMIT, name: OMIT, description: OMIT, parameters: OMIT, forced: OMIT, strict: OMIT, additional_properties: nil) ⇒ Vellum::FunctionDefinition

Parameters:

  • strict (Boolean) (defaults to: OMIT)

    Set this option to use strict schema decoding when available.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(state: OMIT, cache_config: OMIT, name: OMIT, description: OMIT, parameters: OMIT, forced: OMIT, strict: OMIT, additional_properties: nil)
  @state = state if state != OMIT
  @cache_config = cache_config if cache_config != OMIT
  @name = name if name != OMIT
  @description = description if description != OMIT
  @parameters = parameters if parameters != OMIT
  @forced = forced if forced != OMIT
  @strict = strict if strict != OMIT
  @additional_properties = additional_properties
  @_field_set = { "state": state, "cache_config": cache_config, "name": name, "description": description, "parameters": parameters, "forced": forced, "strict": strict }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



27
28
29
# File 'lib/vellum_ai/types/function_definition.rb', line 27

def additional_properties
  @additional_properties
end

#cache_configVellum::EphemeralPromptCacheConfig (readonly)



14
15
16
# File 'lib/vellum_ai/types/function_definition.rb', line 14

def cache_config
  @cache_config
end

#descriptionString (readonly)

Returns A description to help guide the model when to invoke this function.

Returns:

  • (String)

    A description to help guide the model when to invoke this function.



18
19
20
# File 'lib/vellum_ai/types/function_definition.rb', line 18

def description
  @description
end

#forcedObject (readonly)

function.



23
24
25
# File 'lib/vellum_ai/types/function_definition.rb', line 23

def forced
  @forced
end

#nameString (readonly)

Returns The name identifying the function.

Returns:

  • (String)

    The name identifying the function.



16
17
18
# File 'lib/vellum_ai/types/function_definition.rb', line 16

def name
  @name
end

#parametersHash{String => Object} (readonly)

Returns An OpenAPI specification of parameters that are supported by this function.

Returns:

  • (Hash{String => Object})

    An OpenAPI specification of parameters that are supported by this function.



20
21
22
# File 'lib/vellum_ai/types/function_definition.rb', line 20

def parameters
  @parameters
end

#stateVellum::PromptBlockState (readonly)



12
13
14
# File 'lib/vellum_ai/types/function_definition.rb', line 12

def state
  @state
end

#strictBoolean (readonly)

Returns Set this option to use strict schema decoding when available.

Returns:

  • (Boolean)

    Set this option to use strict schema decoding when available.



25
26
27
# File 'lib/vellum_ai/types/function_definition.rb', line 25

def strict
  @strict
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::FunctionDefinition

Parameters:

  • json_object (String)

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vellum_ai/types/function_definition.rb', line 61

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  state = parsed_json["state"]
  unless parsed_json["cache_config"].nil?
    cache_config = parsed_json["cache_config"].to_json
    cache_config = Vellum::EphemeralPromptCacheConfig.from_json(json_object: cache_config)
  else
    cache_config = nil
  end
  name = parsed_json["name"]
  description = parsed_json["description"]
  parameters = parsed_json["parameters"]
  forced = parsed_json["forced"]
  strict = parsed_json["strict"]
  new(
    state: state,
    cache_config: cache_config,
    name: name,
    description: description,
    parameters: parameters,
    forced: forced,
    strict: strict,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


99
100
101
102
103
104
105
106
107
# File 'lib/vellum_ai/types/function_definition.rb', line 99

def self.validate_raw(obj:)
  obj.state&.is_a?(Vellum::PromptBlockState) != false || raise("Passed value for field obj.state is not the expected type, validation failed.")
  obj.cache_config.nil? || Vellum::EphemeralPromptCacheConfig.validate_raw(obj: obj.cache_config)
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.parameters&.is_a?(Hash) != false || raise("Passed value for field obj.parameters is not the expected type, validation failed.")
  obj.forced&.is_a?(Boolean) != false || raise("Passed value for field obj.forced is not the expected type, validation failed.")
  obj.strict&.is_a?(Boolean) != false || raise("Passed value for field obj.strict is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


90
91
92
# File 'lib/vellum_ai/types/function_definition.rb', line 90

def to_json
  @_field_set&.to_json
end