Class: Vellum::ChatMessagePromptBlock
- Inherits:
-
Object
- Object
- Vellum::ChatMessagePromptBlock
- Defined in:
- lib/vellum_ai/types/chat_message_prompt_block.rb
Overview
A block that represents a chat message 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
- #blocks ⇒ Array<Vellum::PromptBlock> readonly
- #cache_config ⇒ Vellum::EphemeralPromptCacheConfig readonly
- #chat_message_unterminated ⇒ Boolean readonly
- #chat_role ⇒ Vellum::ChatMessageRole readonly
- #chat_source ⇒ String readonly
- #state ⇒ Vellum::PromptBlockState readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(block_type:, state: OMIT, cache_config: OMIT, chat_role:, chat_source: OMIT, chat_message_unterminated: OMIT, blocks:, additional_properties: nil) ⇒ Vellum::ChatMessagePromptBlock constructor
- #to_json ⇒ String
Constructor Details
#initialize(block_type:, state: OMIT, cache_config: OMIT, chat_role:, chat_source: OMIT, chat_message_unterminated: OMIT, blocks:, additional_properties: nil) ⇒ Vellum::ChatMessagePromptBlock
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 43 def initialize(block_type:, state: OMIT, cache_config: OMIT, chat_role:, chat_source: OMIT, chat_message_unterminated: OMIT, blocks:, additional_properties: nil) @block_type = block_type @state = state if state != OMIT @cache_config = cache_config if cache_config != OMIT @chat_role = chat_role @chat_source = chat_source if chat_source != OMIT @chat_message_unterminated = if != OMIT @blocks = blocks @additional_properties = additional_properties @_field_set = { "block_type": block_type, "state": state, "cache_config": cache_config, "chat_role": chat_role, "chat_source": chat_source, "chat_message_unterminated": , "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.
27 28 29 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 27 def additional_properties @additional_properties end |
#block_type ⇒ String (readonly)
13 14 15 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 13 def block_type @block_type end |
#blocks ⇒ Array<Vellum::PromptBlock> (readonly)
25 26 27 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 25 def blocks @blocks end |
#cache_config ⇒ Vellum::EphemeralPromptCacheConfig (readonly)
17 18 19 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 17 def cache_config @cache_config end |
#chat_message_unterminated ⇒ Boolean (readonly)
23 24 25 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 23 def @chat_message_unterminated end |
#chat_role ⇒ Vellum::ChatMessageRole (readonly)
19 20 21 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 19 def chat_role @chat_role end |
#chat_source ⇒ String (readonly)
21 22 23 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 21 def chat_source @chat_source end |
#state ⇒ Vellum::PromptBlockState (readonly)
15 16 17 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 15 def state @state end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::ChatMessagePromptBlock
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 60 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 chat_role = parsed_json["chat_role"] chat_source = parsed_json["chat_source"] = parsed_json["chat_message_unterminated"] blocks = parsed_json["blocks"]&.map do | item | item = item.to_json Vellum::PromptBlock.from_json(json_object: item) end new( block_type: block_type, state: state, cache_config: cache_config, chat_role: chat_role, chat_source: chat_source, chat_message_unterminated: , blocks: blocks, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
101 102 103 104 105 106 107 108 109 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 101 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.chat_role.is_a?(Vellum::ChatMessageRole) != false || raise("Passed value for field obj.chat_role 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.&.is_a?(Boolean) != false || raise("Passed value for field obj.chat_message_unterminated 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 ⇒ String
92 93 94 |
# File 'lib/vellum_ai/types/chat_message_prompt_block.rb', line 92 def to_json @_field_set&.to_json end |