Class: Vapi::OpenAiFunctionParameters
- Inherits:
-
Object
- Object
- Vapi::OpenAiFunctionParameters
- Defined in:
- lib/vapi_server_sdk/types/open_ai_function_parameters.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#properties ⇒ Hash{String => Vapi::JsonSchema}
readonly
This provides a description of the properties required by the function.
-
#required ⇒ Array<String>
readonly
This specifies the properties that are required by the function.
-
#type ⇒ String
readonly
This must be set to ‘object’.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::OpenAiFunctionParameters
Deserialize a JSON object to an instance of OpenAiFunctionParameters.
-
.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.
Instance Method Summary collapse
- #initialize(type:, properties:, required: OMIT, additional_properties: nil) ⇒ Vapi::OpenAiFunctionParameters constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of OpenAiFunctionParameters to a JSON object.
Constructor Details
#initialize(type:, properties:, required: OMIT, additional_properties: nil) ⇒ Vapi::OpenAiFunctionParameters
35 36 37 38 39 40 41 42 43 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 35 def initialize(type:, properties:, required: OMIT, additional_properties: nil) @type = type @properties = properties @required = required if required != OMIT @additional_properties = additional_properties @_field_set = { "type": type, "properties": properties, "required": required }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 19 def additional_properties @additional_properties end |
#properties ⇒ Hash{String => Vapi::JsonSchema} (readonly)
Returns This provides a description of the properties required by the function. JSON Schema can be used to specify expectations for each property. Refer to [this doc](ajv.js.org/json-schema.html#json-data-type) for a comprehensive guide on JSON Schema.
15 16 17 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 15 def properties @properties end |
#required ⇒ Array<String> (readonly)
Returns This specifies the properties that are required by the function.
17 18 19 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 17 def required @required end |
#type ⇒ String (readonly)
Returns This must be set to ‘object’. It instructs the model to return a JSON object containing the function call properties.
10 11 12 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 10 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::OpenAiFunctionParameters
Deserialize a JSON object to an instance of OpenAiFunctionParameters
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) type = parsed_json["type"] properties = parsed_json["properties"]&.transform_values do |value| value = value.to_json Vapi::JsonSchema.from_json(json_object: value) end required = parsed_json["required"] new( type: type, properties: properties, required: required, 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.
79 80 81 82 83 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 79 def self.validate_raw(obj:) obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.properties.is_a?(Hash) != false || raise("Passed value for field obj.properties is not the expected type, validation failed.") obj.required&.is_a?(Array) != false || raise("Passed value for field obj.required is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of OpenAiFunctionParameters to a JSON object
69 70 71 |
# File 'lib/vapi_server_sdk/types/open_ai_function_parameters.rb', line 69 def to_json(*_args) @_field_set&.to_json end |