Class: Vellum::FunctionDefinition
- Inherits:
-
Object
- Object
- Vellum::FunctionDefinition
- Defined in:
- lib/vellum_ai/types/function_definition.rb
Overview
to.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #cache_config ⇒ Vellum::EphemeralPromptCacheConfig readonly
-
#description ⇒ String
readonly
A description to help guide the model when to invoke this function.
-
#forced ⇒ Object
readonly
function.
-
#name ⇒ String
readonly
The name identifying the function.
-
#parameters ⇒ Hash{String => Object}
readonly
An OpenAPI specification of parameters that are supported by this function.
- #state ⇒ Vellum::PromptBlockState readonly
-
#strict ⇒ Boolean
readonly
Set this option to use strict schema decoding when available.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(state: OMIT, cache_config: OMIT, name: OMIT, description: OMIT, parameters: OMIT, forced: OMIT, strict: OMIT, additional_properties: nil) ⇒ Vellum::FunctionDefinition constructor
- #to_json ⇒ String
Constructor Details
#initialize(state: OMIT, cache_config: OMIT, name: OMIT, description: OMIT, parameters: OMIT, forced: OMIT, strict: OMIT, additional_properties: nil) ⇒ Vellum::FunctionDefinition
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_properties ⇒ OpenStruct (readonly)
Returns 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_config ⇒ Vellum::EphemeralPromptCacheConfig (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/function_definition.rb', line 14 def cache_config @cache_config end |
#description ⇒ String (readonly)
Returns 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 |
#forced ⇒ Object (readonly)
function.
23 24 25 |
# File 'lib/vellum_ai/types/function_definition.rb', line 23 def forced @forced end |
#name ⇒ String (readonly)
Returns The name identifying the function.
16 17 18 |
# File 'lib/vellum_ai/types/function_definition.rb', line 16 def name @name end |
#parameters ⇒ Hash{String => Object} (readonly)
Returns 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 |
#state ⇒ Vellum::PromptBlockState (readonly)
12 13 14 |
# File 'lib/vellum_ai/types/function_definition.rb', line 12 def state @state end |
#strict ⇒ Boolean (readonly)
Returns 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
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
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_json ⇒ String
90 91 92 |
# File 'lib/vellum_ai/types/function_definition.rb', line 90 def to_json @_field_set&.to_json end |