Class: Vapi::WorkflowCustomModel

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/workflow_custom_model.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, model:, metadata_send_mode: OMIT, timeout_seconds: OMIT, temperature: OMIT, max_tokens: OMIT, additional_properties: nil) ⇒ Vapi::WorkflowCustomModel

Parameters:

  • metadata_send_mode (Vapi::WorkflowCustomModelMetadataSendMode) (defaults to: OMIT)

    This determines whether metadata is sent in requests to the custom provider.

    • ‘off` will not send any metadata. payload will look like `{ messages }`

    • ‘variable` will send `assistant.metadata` as a variable on the payload.

    payload will look like ‘{ messages, metadata }`

    • ‘destructured` will send `assistant.metadata` fields directly on the payload.

    payload will look like ‘{ messages, …metadata }` Further, `variable` and `destructured` will send `call`, `phoneNumber`, and `customer` objects in the payload. Default is `variable`.

  • url (String)

    These is the URL we’ll use for the OpenAI client’s ‘baseURL`. Ex. openrouter.ai/api/v1

  • timeout_seconds (Float) (defaults to: OMIT)

    This sets the timeout for the connection to the custom provider without needing to stream any tokens back. Default is 20 seconds.

  • model (String)

    This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b

  • temperature (Float) (defaults to: OMIT)

    This is the temperature of the model.

  • max_tokens (Float) (defaults to: OMIT)

    This is the max tokens of the model.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 57

def initialize(url:, model:, metadata_send_mode: OMIT, timeout_seconds: OMIT, temperature: OMIT, max_tokens: OMIT,
               additional_properties: nil)
  @metadata_send_mode =  if  != OMIT
  @url = url
  @timeout_seconds = timeout_seconds if timeout_seconds != OMIT
  @model = model
  @temperature = temperature if temperature != OMIT
  @max_tokens = max_tokens if max_tokens != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "metadataSendMode": ,
    "url": url,
    "timeoutSeconds": timeout_seconds,
    "model": model,
    "temperature": temperature,
    "maxTokens": max_tokens
  }.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



32
33
34
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 32

def additional_properties
  @additional_properties
end

#max_tokensFloat (readonly)

Returns This is the max tokens of the model.

Returns:

  • (Float)

    This is the max tokens of the model.



30
31
32
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 30

def max_tokens
  @max_tokens
end

#metadata_send_modeVapi::WorkflowCustomModelMetadataSendMode (readonly)

Returns This determines whether metadata is sent in requests to the custom provider.

  • ‘off` will not send any metadata. payload will look like `{ messages }`

  • ‘variable` will send `assistant.metadata` as a variable on the payload.

payload will look like ‘{ messages, metadata }`

  • ‘destructured` will send `assistant.metadata` fields directly on the payload.

payload will look like ‘{ messages, …metadata }` Further, `variable` and `destructured` will send `call`, `phoneNumber`, and `customer` objects in the payload. Default is `variable`.

Returns:

  • (Vapi::WorkflowCustomModelMetadataSendMode)

    This determines whether metadata is sent in requests to the custom provider.

    • ‘off` will not send any metadata. payload will look like `{ messages }`

    • ‘variable` will send `assistant.metadata` as a variable on the payload.

    payload will look like ‘{ messages, metadata }`

    • ‘destructured` will send `assistant.metadata` fields directly on the payload.

    payload will look like ‘{ messages, …metadata }` Further, `variable` and `destructured` will send `call`, `phoneNumber`, and `customer` objects in the payload. Default is `variable`.



18
19
20
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 18

def 
  @metadata_send_mode
end

#modelString (readonly)

Returns This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b.

Returns:

  • (String)

    This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b



26
27
28
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 26

def model
  @model
end

#temperatureFloat (readonly)

Returns This is the temperature of the model.

Returns:

  • (Float)

    This is the temperature of the model.



28
29
30
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 28

def temperature
  @temperature
end

#timeout_secondsFloat (readonly)

Returns This sets the timeout for the connection to the custom provider without needing to stream any tokens back. Default is 20 seconds.

Returns:

  • (Float)

    This sets the timeout for the connection to the custom provider without needing to stream any tokens back. Default is 20 seconds.



24
25
26
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 24

def timeout_seconds
  @timeout_seconds
end

#urlString (readonly)

Returns These is the URL we’ll use for the OpenAI client’s ‘baseURL`. Ex. openrouter.ai/api/v1.

Returns:

  • (String)

    These is the URL we’ll use for the OpenAI client’s ‘baseURL`. Ex. openrouter.ai/api/v1



21
22
23
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 21

def url
  @url
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::WorkflowCustomModel

Deserialize a JSON object to an instance of WorkflowCustomModel

Parameters:

  • json_object (String)

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 82

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
   = parsed_json["metadataSendMode"]
  url = parsed_json["url"]
  timeout_seconds = parsed_json["timeoutSeconds"]
  model = parsed_json["model"]
  temperature = parsed_json["temperature"]
  max_tokens = parsed_json["maxTokens"]
  new(
    metadata_send_mode: ,
    url: url,
    timeout_seconds: timeout_seconds,
    model: model,
    temperature: temperature,
    max_tokens: max_tokens,
    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)


115
116
117
118
119
120
121
122
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 115

def self.validate_raw(obj:)
  obj.&.is_a?(Vapi::WorkflowCustomModelMetadataSendMode) != false || raise("Passed value for field obj.metadata_send_mode is not the expected type, validation failed.")
  obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
  obj.timeout_seconds&.is_a?(Float) != false || raise("Passed value for field obj.timeout_seconds is not the expected type, validation failed.")
  obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.")
  obj.max_tokens&.is_a?(Float) != false || raise("Passed value for field obj.max_tokens is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WorkflowCustomModel to a JSON object

Returns:

  • (String)


105
106
107
# File 'lib/vapi_server_sdk/types/workflow_custom_model.rb', line 105

def to_json(*_args)
  @_field_set&.to_json
end