Class: Vellum::StreamingAdHocExecutePromptEvent

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

Overview

The data returned for each delta during the prompt execution stream.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state:, output:, output_index:, execution_id:, meta: OMIT, raw: OMIT, additional_properties: nil) ⇒ Vellum::StreamingAdHocExecutePromptEvent

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 40

def initialize(state:, output:, output_index:, execution_id:, meta: OMIT, raw: OMIT, additional_properties: nil)
  @state = state
  @output = output
  @output_index = output_index
  @execution_id = execution_id
  @meta = meta if meta != OMIT
  @raw = raw if raw != OMIT
  @additional_properties = additional_properties
  @_field_set = { "state": state, "output": output, "output_index": output_index, "execution_id": execution_id, "meta": meta, "raw": raw }.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



24
25
26
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 24

def additional_properties
  @additional_properties
end

#execution_idString (readonly)

Returns:

  • (String)


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

def execution_id
  @execution_id
end

#metaVellum::AdHocStreamingPromptExecutionMeta (readonly)



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

def meta
  @meta
end

#outputVellum::PromptOutput (readonly)



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

def output
  @output
end

#output_indexInteger (readonly)

Returns:

  • (Integer)


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

def output_index
  @output_index
end

#rawObject (readonly)

‘expand_raw`.



22
23
24
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 22

def raw
  @raw
end

#stateString (readonly)

Returns:

  • (String)


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

def state
  @state
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::StreamingAdHocExecutePromptEvent

Parameters:

  • json_object (String)

Returns:



56
57
58
59
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
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 56

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  state = parsed_json["state"]
  unless parsed_json["output"].nil?
    output = parsed_json["output"].to_json
    output = Vellum::PromptOutput.from_json(json_object: output)
  else
    output = nil
  end
  output_index = parsed_json["output_index"]
  execution_id = parsed_json["execution_id"]
  unless parsed_json["meta"].nil?
    meta = parsed_json["meta"].to_json
    meta = Vellum::AdHocStreamingPromptExecutionMeta.from_json(json_object: meta)
  else
    meta = nil
  end
  raw = parsed_json["raw"]
  new(
    state: state,
    output: output,
    output_index: output_index,
    execution_id: execution_id,
    meta: meta,
    raw: raw,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


97
98
99
100
101
102
103
104
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 97

def self.validate_raw(obj:)
  obj.state.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.")
  Vellum::PromptOutput.validate_raw(obj: obj.output)
  obj.output_index.is_a?(Integer) != false || raise("Passed value for field obj.output_index is not the expected type, validation failed.")
  obj.execution_id.is_a?(String) != false || raise("Passed value for field obj.execution_id is not the expected type, validation failed.")
  obj.meta.nil? || Vellum::AdHocStreamingPromptExecutionMeta.validate_raw(obj: obj.meta)
  obj.raw&.is_a?(Hash) != false || raise("Passed value for field obj.raw is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


88
89
90
# File 'lib/vellum_ai/types/streaming_ad_hoc_execute_prompt_event.rb', line 88

def to_json
  @_field_set&.to_json
end