Class: Vellum::VariablePromptBlock
- Inherits:
-
Object
- Object
- Vellum::VariablePromptBlock
- Defined in:
- lib/vellum_ai/types/variable_prompt_block.rb
Overview
A block that represents a variable in a prompt template.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #block_type ⇒ String readonly
- #cache_config ⇒ Vellum::EphemeralPromptCacheConfig readonly
- #input_variable ⇒ String readonly
- #state ⇒ Vellum::PromptBlockState readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(block_type:, state: OMIT, cache_config: OMIT, input_variable:, additional_properties: nil) ⇒ Vellum::VariablePromptBlock constructor
- #to_json ⇒ String
Constructor Details
#initialize(block_type:, state: OMIT, cache_config: OMIT, input_variable:, additional_properties: nil) ⇒ Vellum::VariablePromptBlock
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 32 def initialize(block_type:, state: OMIT, cache_config: OMIT, input_variable:, additional_properties: nil) @block_type = block_type @state = state if state != OMIT @cache_config = cache_config if cache_config != OMIT @input_variable = input_variable @additional_properties = additional_properties @_field_set = { "block_type": block_type, "state": state, "cache_config": cache_config, "input_variable": input_variable }.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/vellum_ai/types/variable_prompt_block.rb', line 19 def additional_properties @additional_properties end |
#block_type ⇒ String (readonly)
11 12 13 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 11 def block_type @block_type end |
#cache_config ⇒ Vellum::EphemeralPromptCacheConfig (readonly)
15 16 17 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 15 def cache_config @cache_config end |
#input_variable ⇒ String (readonly)
17 18 19 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 17 def input_variable @input_variable end |
#state ⇒ Vellum::PromptBlockState (readonly)
13 14 15 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 13 def state @state end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::VariablePromptBlock
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 46 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) block_type = parsed_json["block_type"] 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 input_variable = parsed_json["input_variable"] new( block_type: block_type, state: state, cache_config: cache_config, input_variable: input_variable, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
78 79 80 81 82 83 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 78 def self.validate_raw(obj:) obj.block_type.is_a?(String) != false || raise("Passed value for field obj.block_type is not the expected type, validation failed.") 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.input_variable.is_a?(String) != false || raise("Passed value for field obj.input_variable is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
69 70 71 |
# File 'lib/vellum_ai/types/variable_prompt_block.rb', line 69 def to_json @_field_set&.to_json end |