Class: Vellum::RichTextPromptBlock
- Inherits:
-
Object
- Object
- Vellum::RichTextPromptBlock
- Defined in:
- lib/vellum_ai/types/rich_text_prompt_block.rb
Overview
A block that includes a combination of plain text and variable blocks.
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
- #blocks ⇒ Array<Vellum::RichTextChildBlock> readonly
- #cache_config ⇒ Vellum::EphemeralPromptCacheConfig readonly
- #state ⇒ Vellum::PromptBlockState readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(block_type:, state: OMIT, cache_config: OMIT, blocks:, additional_properties: nil) ⇒ Vellum::RichTextPromptBlock constructor
- #to_json ⇒ String
Constructor Details
#initialize(block_type:, state: OMIT, cache_config: OMIT, blocks:, additional_properties: nil) ⇒ Vellum::RichTextPromptBlock
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 33 def initialize(block_type:, state: OMIT, cache_config: OMIT, blocks:, additional_properties: nil) @block_type = block_type @state = state if state != OMIT @cache_config = cache_config if cache_config != OMIT @blocks = blocks @additional_properties = additional_properties @_field_set = { "block_type": block_type, "state": state, "cache_config": cache_config, "blocks": blocks }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 20 def additional_properties @additional_properties end |
#block_type ⇒ String (readonly)
12 13 14 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 12 def block_type @block_type end |
#blocks ⇒ Array<Vellum::RichTextChildBlock> (readonly)
18 19 20 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 18 def blocks @blocks end |
#cache_config ⇒ Vellum::EphemeralPromptCacheConfig (readonly)
16 17 18 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 16 def cache_config @cache_config end |
#state ⇒ Vellum::PromptBlockState (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 14 def state @state end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::RichTextPromptBlock
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 47 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 blocks = parsed_json["blocks"]&.map do | item | item = item.to_json Vellum::RichTextChildBlock.from_json(json_object: item) end new( block_type: block_type, state: state, cache_config: cache_config, blocks: blocks, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
82 83 84 85 86 87 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 82 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.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 ⇒ String
73 74 75 |
# File 'lib/vellum_ai/types/rich_text_prompt_block.rb', line 73 def to_json @_field_set&.to_json end |