Class: Vellum::EnrichedNormalizedCompletion
- Inherits:
-
Object
- Object
- Vellum::EnrichedNormalizedCompletion
- Defined in:
- lib/vellum_ai/types/enriched_normalized_completion.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #deployment_release_tag ⇒ String readonly
-
#external_id ⇒ Object
readonly
which uniquely identifies this generation in an external system.
-
#finish_reason ⇒ Object
readonly
-
‘UNKNOWN` - UNKNOWN.
-
-
#id ⇒ String
readonly
The Vellum-generated ID of the completion.
-
#logprobs ⇒ Object
readonly
request options.
- #model_name ⇒ String readonly
-
#model_version_id ⇒ String
readonly
The ID of the model version used to generate this completion.
- #prompt_version_id ⇒ String readonly
-
#text ⇒ String
readonly
The text generated by the LLM.
- #type ⇒ Vellum::VellumVariableType readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(id:, external_id: OMIT, text:, finish_reason: OMIT, logprobs: OMIT, model_version_id: OMIT, prompt_version_id:, type: OMIT, deployment_release_tag:, model_name:, additional_properties: nil) ⇒ Vellum::EnrichedNormalizedCompletion constructor
- #to_json ⇒ String
Constructor Details
#initialize(id:, external_id: OMIT, text:, finish_reason: OMIT, logprobs: OMIT, model_version_id: OMIT, prompt_version_id:, type: OMIT, deployment_release_tag:, model_name:, additional_properties: nil) ⇒ Vellum::EnrichedNormalizedCompletion
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 60 def initialize(id:, external_id: OMIT, text:, finish_reason: OMIT, logprobs: OMIT, model_version_id: OMIT, prompt_version_id:, type: OMIT, deployment_release_tag:, model_name:, additional_properties: nil) @id = id @external_id = external_id if external_id != OMIT @text = text @finish_reason = finish_reason if finish_reason != OMIT @logprobs = logprobs if logprobs != OMIT @model_version_id = model_version_id if model_version_id != OMIT @prompt_version_id = prompt_version_id @type = type if type != OMIT @deployment_release_tag = deployment_release_tag @model_name = model_name @additional_properties = additional_properties @_field_set = { "id": id, "external_id": external_id, "text": text, "finish_reason": finish_reason, "logprobs": logprobs, "model_version_id": model_version_id, "prompt_version_id": prompt_version_id, "type": type, "deployment_release_tag": deployment_release_tag, "model_name": model_name }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
36 37 38 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 36 def additional_properties @additional_properties end |
#deployment_release_tag ⇒ String (readonly)
32 33 34 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 32 def deployment_release_tag @deployment_release_tag end |
#external_id ⇒ Object (readonly)
which uniquely identifies this generation in an external system.
14 15 16 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 14 def external_id @external_id end |
#finish_reason ⇒ Object (readonly)
-
‘UNKNOWN` - UNKNOWN
21 22 23 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 21 def finish_reason @finish_reason end |
#id ⇒ String (readonly)
Returns The Vellum-generated ID of the completion.
11 12 13 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 11 def id @id end |
#logprobs ⇒ Object (readonly)
request options.
24 25 26 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 24 def logprobs @logprobs end |
#model_name ⇒ String (readonly)
34 35 36 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 34 def model_name @model_name end |
#model_version_id ⇒ String (readonly)
Returns The ID of the model version used to generate this completion.
26 27 28 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 26 def model_version_id @model_version_id end |
#prompt_version_id ⇒ String (readonly)
28 29 30 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 28 def prompt_version_id @prompt_version_id end |
#text ⇒ String (readonly)
Returns The text generated by the LLM.
16 17 18 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 16 def text @text end |
#type ⇒ Vellum::VellumVariableType (readonly)
30 31 32 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 30 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::EnrichedNormalizedCompletion
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 80 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] external_id = parsed_json["external_id"] text = parsed_json["text"] finish_reason = parsed_json["finish_reason"] unless parsed_json["logprobs"].nil? logprobs = parsed_json["logprobs"].to_json logprobs = Vellum::NormalizedLogProbs.from_json(json_object: logprobs) else logprobs = nil end model_version_id = parsed_json["model_version_id"] prompt_version_id = parsed_json["prompt_version_id"] type = parsed_json["type"] deployment_release_tag = parsed_json["deployment_release_tag"] model_name = parsed_json["model_name"] new( id: id, external_id: external_id, text: text, finish_reason: finish_reason, logprobs: logprobs, model_version_id: model_version_id, prompt_version_id: prompt_version_id, type: type, deployment_release_tag: deployment_release_tag, model_name: model_name, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 124 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.") obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.finish_reason&.is_a?(Vellum::FinishReasonEnum) != false || raise("Passed value for field obj.finish_reason is not the expected type, validation failed.") obj.logprobs.nil? || Vellum::NormalizedLogProbs.validate_raw(obj: obj.logprobs) obj.model_version_id&.is_a?(String) != false || raise("Passed value for field obj.model_version_id is not the expected type, validation failed.") obj.prompt_version_id.is_a?(String) != false || raise("Passed value for field obj.prompt_version_id is not the expected type, validation failed.") obj.type&.is_a?(Vellum::VellumVariableType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.deployment_release_tag.is_a?(String) != false || raise("Passed value for field obj.deployment_release_tag is not the expected type, validation failed.") obj.model_name.is_a?(String) != false || raise("Passed value for field obj.model_name is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
115 116 117 |
# File 'lib/vellum_ai/types/enriched_normalized_completion.rb', line 115 def to_json @_field_set&.to_json end |