Class: Vellum::RegisterPromptPromptInfoRequest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prompt_block_data:, input_variables:, additional_properties: nil) ⇒ RegisterPromptPromptInfoRequest

Parameters:



15
16
17
18
19
20
21
22
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 15

def initialize(prompt_block_data:, input_variables:, additional_properties: nil)
  # @type [PromptTemplateBlockDataRequest]
  @prompt_block_data = prompt_block_data
  # @type [Array<RegisteredPromptInputVariableRequest>] The input variables specified in the prompt template.
  @input_variables = input_variables
  # @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.



9
10
11
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 9

def additional_properties
  @additional_properties
end

#input_variablesObject (readonly)

Returns the value of attribute input_variables.



9
10
11
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 9

def input_variables
  @input_variables
end

#prompt_block_dataObject (readonly)

Returns the value of attribute prompt_block_data.



9
10
11
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 9

def prompt_block_data
  @prompt_block_data
end

Class Method Details

.from_json(json_object:) ⇒ RegisterPromptPromptInfoRequest

Deserialize a JSON object to an instance of RegisterPromptPromptInfoRequest

Parameters:

  • json_object (JSON)

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 28

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["prompt_block_data"].nil?
    prompt_block_data = nil
  else
    prompt_block_data = parsed_json["prompt_block_data"].to_json
    prompt_block_data = PromptTemplateBlockDataRequest.from_json(json_object: prompt_block_data)
  end
  input_variables = parsed_json["input_variables"].map do |v|
    v = v.to_json
    RegisteredPromptInputVariableRequest.from_json(json_object: v)
  end
  new(prompt_block_data: prompt_block_data, input_variables: input_variables, 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)


55
56
57
58
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 55

def self.validate_raw(obj:)
  PromptTemplateBlockDataRequest.validate_raw(obj: obj.prompt_block_data)
  obj.input_variables.is_a?(Array) != false || raise("Passed value for field obj.input_variables is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of RegisterPromptPromptInfoRequest to a JSON object

Returns:

  • (JSON)


47
48
49
# File 'lib/vellum_ai/types/register_prompt_prompt_info_request.rb', line 47

def to_json(*_args)
  { "prompt_block_data": @prompt_block_data, "input_variables": @input_variables }.to_json
end