Class: Vapi::SuccessEvaluationPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rubric: OMIT, messages: OMIT, enabled: OMIT, timeout_seconds: OMIT, additional_properties: nil) ⇒ Vapi::SuccessEvaluationPlan

Parameters:

  • rubric (Vapi::SuccessEvaluationPlanRubric) (defaults to: OMIT) —

    This enforces the rubric of the evaluation. The output is stored in call.analysis.successEvaluation. Options include:

    • 'NumericScale': A scale of 1 to 10.
    • 'DescriptiveScale': A scale of Excellent, Good, Fair, Poor.
    • 'Checklist': A checklist of criteria and their status.
    • 'Matrix': A grid that evaluates multiple criteria across different performance levels.
    • 'PercentageScale': A scale of 0% to 100%.
    • 'LikertScale': A scale of Strongly Agree, Agree, Neutral, Disagree, Strongly Disagree.
    • 'AutomaticRubric': Automatically break down evaluation into several criteria, each with its own score.
    • 'PassFail': A simple 'true' if call passed, 'false' if not. Default is 'PassFail'.
  • messages (Array<Hash{String => Object}>) (defaults to: OMIT) —

    These are the messages used to generate the success evaluation. @default: [ { "role": "system", "content": "You are an expert call evaluator. You will be given a transcript of a call and the system prompt of the AI participant. Determine if the call was successful based on the objectives inferred from the system prompt. DO NOT return anything except the result.\n\nRubric:\\n{{rubric}}\n\nOnly respond with the result." }, { "role": "user", "content": "Here is the transcript:\n\n{{transcript}}\n\n" }, { "role": "user", "content": "Here was the system prompt of the call:\n\n{{systemPrompt}}\n\n" } ] You can customize by providing any messages you want. Here are the template variables available:

    • {transcript}: the transcript of the call from call.artifact.transcript- {systemPrompt}: the system prompt of the call from assistant.model.messages[type=system].content- {rubric}: the rubric of the success evaluation from successEvaluationPlan.rubric
  • enabled (Boolean) (defaults to: OMIT) —

    This determines whether a success evaluation is generated and stored in call.analysis.successEvaluation. Defaults to true. Usage:

    • If you want to disable the success evaluation, set this to false. @default true
  • timeout_seconds (Float) (defaults to: OMIT) —

    This is how long the request is tried before giving up. When request times out, call.analysis.successEvaluation will be empty. Usage:

    • To guarantee the success evaluation is generated, set this value high. Note, this will delay the end of call report in cases where model is slow to respond. @default 5 seconds
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 127

def initialize(rubric: OMIT, messages: OMIT, enabled: OMIT, timeout_seconds: OMIT, additional_properties: nil)
  @rubric = rubric if rubric != OMIT
  @messages = messages if messages != OMIT
  @enabled = enabled if enabled != OMIT
  @timeout_seconds = timeout_seconds if timeout_seconds != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "rubric": rubric,
    "messages": messages,
    "enabled": enabled,
    "timeoutSeconds": timeout_seconds
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



66
67
68
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 66

def additional_properties
  @additional_properties
end

#enabled ⇒ Boolean (readonly)

Returns This determines whether a success evaluation is generated and stored in call.analysis.successEvaluation. Defaults to true. Usage:

  • If you want to disable the success evaluation, set this to false. @default true.

Returns:

  • (Boolean) —

    This determines whether a success evaluation is generated and stored in call.analysis.successEvaluation. Defaults to true. Usage:

    • If you want to disable the success evaluation, set this to false. @default true


57
58
59
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 57

def enabled
  @enabled
end

#messages ⇒ Array<Hash{String => Object}> (readonly)

These are the messages used to generate the success evaluation. @default: [ { "role": "system", "content": "You are an expert call evaluator. You will be given a transcript of a call and the system prompt of the AI participant. Determine if the call was successful based on the objectives inferred from the system prompt. DO NOT return anything except the result.\n\nRubric:\\n{{rubric}}\n\nOnly respond with the result." }, { "role": "user", "content": "Here is the transcript:\n\n{{transcript}}\n\n" }, { "role": "user", "content": "Here was the system prompt of the call:\n\n{{systemPrompt}}\n\n" } ] You can customize by providing any messages you want. Here are the template variables available:

  • {transcript}: the transcript of the call from call.artifact.transcript- {systemPrompt}: the system prompt of the call from assistant.model.messages[type=system].content- {rubric}: the rubric of the success evaluation from successEvaluationPlan.rubric

Returns:

  • (Array<Hash{String => Object}>) —

    These are the messages used to generate the success evaluation. @default: [ { "role": "system", "content": "You are an expert call evaluator. You will be given a transcript of a call and the system prompt of the AI participant. Determine if the call was successful based on the objectives inferred from the system prompt. DO NOT return anything except the result.\n\nRubric:\\n{{rubric}}\n\nOnly respond with the result." }, { "role": "user", "content": "Here is the transcript:\n\n{{transcript}}\n\n" }, { "role": "user", "content": "Here was the system prompt of the call:\n\n{{systemPrompt}}\n\n" } ] You can customize by providing any messages you want. Here are the template variables available:

    • {transcript}: the transcript of the call from call.artifact.transcript- {systemPrompt}: the system prompt of the call from assistant.model.messages[type=system].content- {rubric}: the rubric of the success evaluation from successEvaluationPlan.rubric


51
52
53
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 51

def messages
  @messages
end

#rubric ⇒ Vapi::SuccessEvaluationPlanRubric (readonly)

Returns This enforces the rubric of the evaluation. The output is stored in call.analysis.successEvaluation. Options include:

  • 'NumericScale': A scale of 1 to 10.
  • 'DescriptiveScale': A scale of Excellent, Good, Fair, Poor.
  • 'Checklist': A checklist of criteria and their status.
  • 'Matrix': A grid that evaluates multiple criteria across different performance levels.
  • 'PercentageScale': A scale of 0% to 100%.
  • 'LikertScale': A scale of Strongly Agree, Agree, Neutral, Disagree, Strongly Disagree.
  • 'AutomaticRubric': Automatically break down evaluation into several criteria, each with its own score.
  • 'PassFail': A simple 'true' if call passed, 'false' if not. Default is 'PassFail'.

Returns:

  • (Vapi::SuccessEvaluationPlanRubric) —

    This enforces the rubric of the evaluation. The output is stored in call.analysis.successEvaluation. Options include:

    • 'NumericScale': A scale of 1 to 10.
    • 'DescriptiveScale': A scale of Excellent, Good, Fair, Poor.
    • 'Checklist': A checklist of criteria and their status.
    • 'Matrix': A grid that evaluates multiple criteria across different performance levels.
    • 'PercentageScale': A scale of 0% to 100%.
    • 'LikertScale': A scale of Strongly Agree, Agree, Neutral, Disagree, Strongly Disagree.
    • 'AutomaticRubric': Automatically break down evaluation into several criteria, each with its own score.
    • 'PassFail': A simple 'true' if call passed, 'false' if not. Default is 'PassFail'.


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

def rubric
  @rubric
end

#timeout_seconds ⇒ Float (readonly)

Returns This is how long the request is tried before giving up. When request times out, call.analysis.successEvaluation will be empty. Usage:

  • To guarantee the success evaluation is generated, set this value high. Note, this will delay the end of call report in cases where model is slow to respond. @default 5 seconds.

Returns:

  • (Float) —

    This is how long the request is tried before giving up. When request times out, call.analysis.successEvaluation will be empty. Usage:

    • To guarantee the success evaluation is generated, set this value high. Note, this will delay the end of call report in cases where model is slow to respond. @default 5 seconds


64
65
66
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 64

def timeout_seconds
  @timeout_seconds
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::SuccessEvaluationPlan

Deserialize a JSON object to an instance of SuccessEvaluationPlan

Parameters:

  • json_object (String)

Returns:



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 147

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  rubric = parsed_json["rubric"]
  messages = parsed_json["messages"]
  enabled = parsed_json["enabled"]
  timeout_seconds = parsed_json["timeoutSeconds"]
  new(
    rubric: rubric,
    messages: messages,
    enabled: enabled,
    timeout_seconds: timeout_seconds,
    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)


176
177
178
179
180
181
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 176

def self.validate_raw(obj:)
  obj.rubric&.is_a?(Vapi::SuccessEvaluationPlanRubric) != false || raise("Passed value for field obj.rubric is not the expected type, validation failed.")
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
  obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of SuccessEvaluationPlan to a JSON object

Returns:

  • (String)


166
167
168
# File 'lib/vapi_server_sdk/types/success_evaluation_plan.rb', line 166

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