Class: Vellum::GenerateOptionsRequest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logprobs: nil, additional_properties: nil) ⇒ GenerateOptionsRequest

Parameters:

  • logprobs (LOGPROBS_ENUM) (defaults to: nil)

    Which logprobs to include, if any. Defaults to NONE.

    • ‘ALL` - ALL

    • ‘NONE` - NONE

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



15
16
17
18
19
20
21
22
# File 'lib/vellum_ai/types/generate_options_request.rb', line 15

def initialize(logprobs: nil, additional_properties: nil)
  # @type [LOGPROBS_ENUM] Which logprobs to include, if any. Defaults to NONE.
  #   - `ALL` - ALL
  #   - `NONE` - NONE
  @logprobs = logprobs
  # @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.



8
9
10
# File 'lib/vellum_ai/types/generate_options_request.rb', line 8

def additional_properties
  @additional_properties
end

#logprobsObject (readonly)

Returns the value of attribute logprobs.



8
9
10
# File 'lib/vellum_ai/types/generate_options_request.rb', line 8

def logprobs
  @logprobs
end

Class Method Details

.from_json(json_object:) ⇒ GenerateOptionsRequest

Deserialize a JSON object to an instance of GenerateOptionsRequest

Parameters:

  • json_object (JSON)

Returns:



28
29
30
31
32
33
# File 'lib/vellum_ai/types/generate_options_request.rb', line 28

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  logprobs = LOGPROBS_ENUM.key(parsed_json["logprobs"]) || parsed_json["logprobs"]
  new(logprobs: logprobs, 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)


46
47
48
# File 'lib/vellum_ai/types/generate_options_request.rb', line 46

def self.validate_raw(obj:)
  obj.logprobs&.is_a?(LOGPROBS_ENUM) != false || raise("Passed value for field obj.logprobs is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of GenerateOptionsRequest to a JSON object

Returns:

  • (JSON)


38
39
40
# File 'lib/vellum_ai/types/generate_options_request.rb', line 38

def to_json(*_args)
  { "logprobs": LOGPROBS_ENUM[@logprobs] || @logprobs }.to_json
end