Class: Vellum::ModelVersionExecConfig

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters:, input_variables:, prompt_template: nil, prompt_block_data: nil, prompt_syntax_version: nil, additional_properties: nil) ⇒ ModelVersionExecConfig

Parameters:

  • parameters (ModelVersionExecConfigParameters)

    The generation parameters that are passed to the LLM provider at runtime.

  • input_variables (Array<VellumVariable>)

    Input variables specified in the prompt template.

  • prompt_template (String) (defaults to: nil)

    The template used to generate prompts for this model version.

  • prompt_block_data (PromptTemplateBlockData) (defaults to: nil)
  • prompt_syntax_version (Integer) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vellum_ai/types/model_version_exec_config.rb', line 20

def initialize(parameters:, input_variables:, prompt_template: nil, prompt_block_data: nil,
               prompt_syntax_version: nil, additional_properties: nil)
  # @type [ModelVersionExecConfigParameters] The generation parameters that are passed to the LLM provider at runtime.
  @parameters = parameters
  # @type [Array<VellumVariable>] Input variables specified in the prompt template.
  @input_variables = input_variables
  # @type [String] The template used to generate prompts for this model version.
  @prompt_template = prompt_template
  # @type [PromptTemplateBlockData]
  @prompt_block_data = prompt_block_data
  # @type [Integer]
  @prompt_syntax_version = prompt_syntax_version
  # @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/model_version_exec_config.rb', line 10

def additional_properties
  @additional_properties
end

#input_variablesObject (readonly)

Returns the value of attribute input_variables.



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

def input_variables
  @input_variables
end

#parametersObject (readonly)

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#prompt_block_dataObject (readonly)

Returns the value of attribute prompt_block_data.



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

def prompt_block_data
  @prompt_block_data
end

#prompt_syntax_versionObject (readonly)

Returns the value of attribute prompt_syntax_version.



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

def prompt_syntax_version
  @prompt_syntax_version
end

#prompt_templateObject (readonly)

Returns the value of attribute prompt_template.



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

def prompt_template
  @prompt_template
end

Class Method Details

.from_json(json_object:) ⇒ ModelVersionExecConfig

Deserialize a JSON object to an instance of ModelVersionExecConfig

Parameters:

  • json_object (JSON)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vellum_ai/types/model_version_exec_config.rb', line 40

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["parameters"].nil?
    parameters = nil
  else
    parameters = parsed_json["parameters"].to_json
    parameters = ModelVersionExecConfigParameters.from_json(json_object: parameters)
  end
  input_variables = parsed_json["input_variables"].map do |v|
    v = v.to_json
    VellumVariable.from_json(json_object: v)
  end
  prompt_template = struct.prompt_template
  if parsed_json["prompt_block_data"].nil?
    prompt_block_data = nil
  else
    prompt_block_data = parsed_json["prompt_block_data"].to_json
    prompt_block_data = PromptTemplateBlockData.from_json(json_object: prompt_block_data)
  end
  prompt_syntax_version = struct.prompt_syntax_version
  new(parameters: parameters, input_variables: input_variables, prompt_template: prompt_template,
      prompt_block_data: prompt_block_data, prompt_syntax_version: prompt_syntax_version, 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)


82
83
84
85
86
87
88
# File 'lib/vellum_ai/types/model_version_exec_config.rb', line 82

def self.validate_raw(obj:)
  ModelVersionExecConfigParameters.validate_raw(obj: obj.parameters)
  obj.input_variables.is_a?(Array) != false || raise("Passed value for field obj.input_variables is not the expected type, validation failed.")
  obj.prompt_template&.is_a?(String) != false || raise("Passed value for field obj.prompt_template is not the expected type, validation failed.")
  obj.prompt_block_data.nil? || PromptTemplateBlockData.validate_raw(obj: obj.prompt_block_data)
  obj.prompt_syntax_version&.is_a?(Integer) != false || raise("Passed value for field obj.prompt_syntax_version is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of ModelVersionExecConfig to a JSON object

Returns:

  • (JSON)


68
69
70
71
72
73
74
75
76
# File 'lib/vellum_ai/types/model_version_exec_config.rb', line 68

def to_json(*_args)
  {
    "parameters": @parameters,
    "input_variables": @input_variables,
    "prompt_template": @prompt_template,
    "prompt_block_data": @prompt_block_data,
    "prompt_syntax_version": @prompt_syntax_version
  }.to_json
end