Class: Vellum::PlainTextPromptBlock

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

Overview

A block that holds a plain text string value.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block_type:, state: OMIT, cache_config: OMIT, text:, additional_properties: nil) ⇒ Vellum::PlainTextPromptBlock

Parameters:



32
33
34
35
36
37
38
39
40
41
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 32

def initialize(block_type:, state: OMIT, cache_config: OMIT, text:, additional_properties: nil)
  @block_type = block_type
  @state = state if state != OMIT
  @cache_config = cache_config if cache_config != OMIT
  @text = text
  @additional_properties = additional_properties
  @_field_set = { "block_type": block_type, "state": state, "cache_config": cache_config, "text": text }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



19
20
21
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 19

def additional_properties
  @additional_properties
end

#block_typeString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 11

def block_type
  @block_type
end

#cache_configVellum::EphemeralPromptCacheConfig (readonly)



15
16
17
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 15

def cache_config
  @cache_config
end

#stateVellum::PromptBlockState (readonly)



13
14
15
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 13

def state
  @state
end

#textString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 17

def text
  @text
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::PlainTextPromptBlock

Parameters:

  • json_object (String)

Returns:



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/plain_text_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
  text = parsed_json["text"]
  new(
    block_type: block_type,
    state: state,
    cache_config: cache_config,
    text: text,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
83
# File 'lib/vellum_ai/types/plain_text_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.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


69
70
71
# File 'lib/vellum_ai/types/plain_text_prompt_block.rb', line 69

def to_json
  @_field_set&.to_json
end