Class: Vellum::PromptTemplateBlockProperties

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chat_role: nil, chat_message_unterminated: nil, chat_source: nil, template: nil, template_type: nil, function_name: nil, function_description: nil, function_parameters: nil, function_forced: nil, blocks: nil, additional_properties: nil) ⇒ PromptTemplateBlockProperties

Parameters:

  • chat_role (CHAT_MESSAGE_ROLE) (defaults to: nil)
  • chat_message_unterminated (Boolean) (defaults to: nil)
  • chat_source (String) (defaults to: nil)
  • template (String) (defaults to: nil)
  • template_type (VELLUM_VARIABLE_TYPE) (defaults to: nil)
  • function_name (String) (defaults to: nil)
  • function_description (String) (defaults to: nil)
  • function_parameters (Hash{String => String}) (defaults to: nil)
  • function_forced (Boolean) (defaults to: nil)
  • blocks (Array<PromptTemplateBlock>) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vellum_ai/types/prompt_template_block_properties.rb', line 25

def initialize(chat_role: nil, chat_message_unterminated: nil, chat_source: nil, template: nil, template_type: nil,
               function_name: nil, function_description: nil, function_parameters: nil, function_forced: nil, blocks: nil, additional_properties: nil)
  # @type [CHAT_MESSAGE_ROLE]
  @chat_role = chat_role
  # @type [Boolean]
  @chat_message_unterminated = chat_message_unterminated
  # @type [String]
  @chat_source = chat_source
  # @type [String]
  @template = template
  # @type [VELLUM_VARIABLE_TYPE]
  @template_type = template_type
  # @type [String]
  @function_name = function_name
  # @type [String]
  @function_description = function_description
  # @type [Hash{String => String}]
  @function_parameters = function_parameters
  # @type [Boolean]
  @function_forced = function_forced
  # @type [Array<PromptTemplateBlock>]
  @blocks = blocks
  # @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/prompt_template_block_properties.rb', line 10

def additional_properties
  @additional_properties
end

#blocksObject (readonly)

Returns the value of attribute blocks.



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

def blocks
  @blocks
end

#chat_message_unterminatedObject (readonly)

Returns the value of attribute chat_message_unterminated.



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

def chat_message_unterminated
  @chat_message_unterminated
end

#chat_roleObject (readonly)

Returns the value of attribute chat_role.



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

def chat_role
  @chat_role
end

#chat_sourceObject (readonly)

Returns the value of attribute chat_source.



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

def chat_source
  @chat_source
end

#function_descriptionObject (readonly)

Returns the value of attribute function_description.



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

def function_description
  @function_description
end

#function_forcedObject (readonly)

Returns the value of attribute function_forced.



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

def function_forced
  @function_forced
end

#function_nameObject (readonly)

Returns the value of attribute function_name.



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

def function_name
  @function_name
end

#function_parametersObject (readonly)

Returns the value of attribute function_parameters.



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

def function_parameters
  @function_parameters
end

#templateObject (readonly)

Returns the value of attribute template.



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

def template
  @template
end

#template_typeObject (readonly)

Returns the value of attribute template_type.



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

def template_type
  @template_type
end

Class Method Details

.from_json(json_object:) ⇒ PromptTemplateBlockProperties

Deserialize a JSON object to an instance of PromptTemplateBlockProperties

Parameters:

  • json_object (JSON)

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vellum_ai/types/prompt_template_block_properties.rb', line 55

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  chat_role = CHAT_MESSAGE_ROLE.key(parsed_json["chat_role"]) || parsed_json["chat_role"]
  chat_message_unterminated = struct.chat_message_unterminated
  chat_source = struct.chat_source
  template = struct.template
  template_type = VELLUM_VARIABLE_TYPE.key(parsed_json["template_type"]) || parsed_json["template_type"]
  function_name = struct.function_name
  function_description = struct.function_description
  function_parameters = struct.function_parameters
  function_forced = struct.function_forced
  blocks = parsed_json["blocks"].map do |v|
    v = v.to_json
    PromptTemplateBlock.from_json(json_object: v)
  end
  new(chat_role: chat_role, chat_message_unterminated: chat_message_unterminated, chat_source: chat_source,
      template: template, template_type: template_type, function_name: function_name, function_description: function_description, function_parameters: function_parameters, function_forced: function_forced, blocks: blocks, 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)


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

def self.validate_raw(obj:)
  obj.chat_role&.is_a?(CHAT_MESSAGE_ROLE) != false || raise("Passed value for field obj.chat_role is not the expected type, validation failed.")
  obj.chat_message_unterminated&.is_a?(Boolean) != false || raise("Passed value for field obj.chat_message_unterminated is not the expected type, validation failed.")
  obj.chat_source&.is_a?(String) != false || raise("Passed value for field obj.chat_source is not the expected type, validation failed.")
  obj.template&.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.")
  obj.template_type&.is_a?(VELLUM_VARIABLE_TYPE) != false || raise("Passed value for field obj.template_type is not the expected type, validation failed.")
  obj.function_name&.is_a?(String) != false || raise("Passed value for field obj.function_name is not the expected type, validation failed.")
  obj.function_description&.is_a?(String) != false || raise("Passed value for field obj.function_description is not the expected type, validation failed.")
  obj.function_parameters&.is_a?(Hash) != false || raise("Passed value for field obj.function_parameters is not the expected type, validation failed.")
  obj.function_forced&.is_a?(Boolean) != false || raise("Passed value for field obj.function_forced is not the expected type, validation failed.")
  obj.blocks&.is_a?(Array) != false || raise("Passed value for field obj.blocks is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of PromptTemplateBlockProperties to a JSON object

Returns:

  • (JSON)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vellum_ai/types/prompt_template_block_properties.rb', line 78

def to_json(*_args)
  {
    "chat_role": CHAT_MESSAGE_ROLE[@chat_role] || @chat_role,
    "chat_message_unterminated": @chat_message_unterminated,
    "chat_source": @chat_source,
    "template": @template,
    "template_type": VELLUM_VARIABLE_TYPE[@template_type] || @template_type,
    "function_name": @function_name,
    "function_description": @function_description,
    "function_parameters": @function_parameters,
    "function_forced": @function_forced,
    "blocks": @blocks
  }.to_json
end