Class: Vellum::RejectedExecutePromptResponse

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

Overview

The unsuccessful response from the model containing an error of what went wrong.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_id:, error:, meta: nil, raw: nil, additional_properties: nil) ⇒ RejectedExecutePromptResponse

Parameters:

  • meta (PromptExecutionMeta) (defaults to: nil)
  • raw (Hash{String => String}) (defaults to: nil)

    The subset of the raw response from the model that the request opted into with ‘expand_raw`.

  • execution_id (String)

    The ID of the execution.

  • error (VellumError)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 18

def initialize(execution_id:, error:, meta: nil, raw: nil, additional_properties: nil)
  # @type [PromptExecutionMeta]
  @meta = meta
  # @type [Hash{String => String}] The subset of the raw response from the model that the request opted into with `expand_raw`.
  @raw = raw
  # @type [String] The ID of the execution.
  @execution_id = execution_id
  # @type [VellumError]
  @error = error
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



10
11
12
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 10

def additional_properties
  @additional_properties
end

#errorObject (readonly)

Returns the value of attribute error.



10
11
12
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 10

def error
  @error
end

#execution_idObject (readonly)

Returns the value of attribute execution_id.



10
11
12
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 10

def execution_id
  @execution_id
end

#metaObject (readonly)

Returns the value of attribute meta.



10
11
12
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 10

def meta
  @meta
end

#rawObject (readonly)

Returns the value of attribute raw.



10
11
12
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 10

def raw
  @raw
end

Class Method Details

.from_json(json_object:) ⇒ RejectedExecutePromptResponse

Deserialize a JSON object to an instance of RejectedExecutePromptResponse

Parameters:

  • json_object (JSON)

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 35

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["meta"].nil?
    meta = nil
  else
    meta = parsed_json["meta"].to_json
    meta = PromptExecutionMeta.from_json(json_object: meta)
  end
  raw = struct.raw
  execution_id = struct.execution_id
  if parsed_json["error"].nil?
    error = nil
  else
    error = parsed_json["error"].to_json
    error = VellumError.from_json(json_object: error)
  end
  new(meta: meta, raw: raw, execution_id: execution_id, error: error, additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


66
67
68
69
70
71
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 66

def self.validate_raw(obj:)
  obj.meta.nil? || PromptExecutionMeta.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.")
  obj.execution_id.is_a?(String) != false || raise("Passed value for field obj.execution_id is not the expected type, validation failed.")
  VellumError.validate_raw(obj: obj.error)
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of RejectedExecutePromptResponse to a JSON object

Returns:

  • (JSON)


58
59
60
# File 'lib/vellum_ai/types/rejected_execute_prompt_response.rb', line 58

def to_json(*_args)
  { "meta": @meta, "raw": @raw, "execution_id": @execution_id, "error": @error }.to_json
end