Class: Twilio::REST::Intelligence::V3::OperatorInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/intelligence/v3/operator.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, id: nil) ⇒ OperatorInstance

Initialize the OperatorInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Operator resource.

  • sid (String)

    The SID of the Call resource to fetch.



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 597

def initialize(version, payload , id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'display_name' => payload['display_name'],
        'description' => payload['description'],
        'version' => payload['version'] == nil ? payload['version'] : payload['version'].to_i,
        'author' => payload['author'],
        'prompt' => payload['prompt'],
        'output_format' => payload['output_format'],
        'output_schema' => payload['output_schema'],
        'training_examples' => payload['training_examples'],
        'context' => payload['context'],
        'parameters' => payload['parameters'],
        'code' => payload['code'],
        'message' => payload['message'],
        'http_status_code' => payload['http_status_code'],
        'user_error' => payload['user_error'],
        'params' => payload['params'],
    }

    # Context
    @instance_context = nil
    @params = { 'id' => id  || @properties['id']  , }
end

Instance Method Details

#authorOperatorAuthor

Returns:

  • (OperatorAuthor)


664
665
666
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 664

def author
    @properties['author']
end

#codeString

Returns Twilio-specific error code.

Returns:

  • (String)

    Twilio-specific error code



706
707
708
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 706

def code
    @properties['code']
end

#contextOperatorContext

Returns:



631
632
633
634
635
636
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 631

def context
    unless @instance_context
        @instance_context = OperatorContext.new(@version , @params['id'])
    end
    @instance_context
end

#deleteBoolean

Delete the OperatorInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



737
738
739
740
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 737

def delete

    context.delete
end

#descriptionString

Returns Description of the Language Operator further explaining its purpose.

Returns:

  • (String)

    Description of the Language Operator further explaining its purpose.



652
653
654
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 652

def description
    @properties['description']
end

#display_nameString

Returns Display name of the Language Operator describing its purpose.

Returns:

  • (String)

    Display name of the Language Operator describing its purpose.



646
647
648
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 646

def display_name
    @properties['display_name']
end

#fetchOperatorInstance

Fetch the OperatorInstance

Returns:



745
746
747
748
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 745

def fetch

    context.fetch
end

#http_status_codeString

Returns HTTP response status code.

Returns:

  • (String)

    HTTP response status code



718
719
720
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 718

def http_status_code
    @properties['http_status_code']
end

#idString

Returns The unique identifier for the Language Operator. Assigned by Twilio (TTID).

Returns:

  • (String)

    The unique identifier for the Language Operator. Assigned by Twilio (TTID).



640
641
642
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 640

def id
    @properties['id']
end

#inspectObject

Provide a detailed, user friendly representation



775
776
777
778
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 775

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Intelligence.V3.OperatorInstance #{values}>"
end

#messageString

Returns A human readable error message.

Returns:

  • (String)

    A human readable error message



712
713
714
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 712

def message
    @properties['message']
end

#output_formatOperatorOutputFormat

Returns:

  • (OperatorOutputFormat)


676
677
678
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 676

def output_format
    @properties['output_format']
end

#output_schemaHash

Returns Required for ‘JSON` output only. this will be set to a JSON Schema object describing the properties & data types of the response. Please see platform.openai.com/docs/guides/structured-outputs#supported-schemas Will include the following keywords: - `type` : Must be set to `object` - `properties`: An object containing the property names and their data types you would like the LLM to return Additional details on JSON output formatting: - The root level `type` of a JSON schema must be set to `object` - The following property data types are supported : `string`, `number`, `boolean`, `integer`, `object`, `array`, `anyOf` - Definitions with `$defs` / `$ref` are supported - Max 100 object properties and 10 levels of nesting are supported - Max 1000 enum values across all enum properties are supported - Notable JSON Schema keywords not supported include: - For `strings`: `minLength`, `maxLength` - For `objects`: `patternProperties`, `unevaluatedProperties`, `propertyNames`, `minProperties`, `maxProperties` - For `arrays`: `unevaluatedItems`, `contains`, `minContains`, `maxContains`, `uniqueItems` - Structured Operator Results will be returned in the same order as the ordering of keys in the schema - In the event an Operator execution request is refused for safety reasons the Operator Result API response will include a new field called `refusal` to indicate that the LLM refused to fulfill the request - Twilio will automatically set `additionalProperties` to false and specify all provided fields as required (constraints of Structured Outputs). You don’t need to pass these fields as part of your JSON schema. Twilio will automatically overwrite any user-provided values for these fields.

Returns:

  • (Hash)

    Required for ‘JSON` output only. this will be set to a JSON Schema object describing the properties & data types of the response. Please see platform.openai.com/docs/guides/structured-outputs#supported-schemas Will include the following keywords: - `type` : Must be set to `object` - `properties`: An object containing the property names and their data types you would like the LLM to return Additional details on JSON output formatting: - The root level `type` of a JSON schema must be set to `object` - The following property data types are supported : `string`, `number`, `boolean`, `integer`, `object`, `array`, `anyOf` - Definitions with `$defs` / `$ref` are supported - Max 100 object properties and 10 levels of nesting are supported - Max 1000 enum values across all enum properties are supported - Notable JSON Schema keywords not supported include: - For `strings`: `minLength`, `maxLength` - For `objects`: `patternProperties`, `unevaluatedProperties`, `propertyNames`, `minProperties`, `maxProperties` - For `arrays`: `unevaluatedItems`, `contains`, `minContains`, `maxContains`, `uniqueItems` - Structured Operator Results will be returned in the same order as the ordering of keys in the schema - In the event an Operator execution request is refused for safety reasons the Operator Result API response will include a new field called `refusal` to indicate that the LLM refused to fulfill the request - Twilio will automatically set `additionalProperties` to false and specify all provided fields as required (constraints of Structured Outputs). You don’t need to pass these fields as part of your JSON schema. Twilio will automatically overwrite any user-provided values for these fields.



682
683
684
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 682

def output_schema
    @properties['output_schema']
end

#parametersHash<String, OperatorParameter>

Returns Defines the schema of the parameters that are provided when running the operator, including required and optional values that determine the operator’s behavior. The values of the parameters themselves are passed in by the attached Intelligence Configuration.

Returns:

  • (Hash<String, OperatorParameter>)

    Defines the schema of the parameters that are provided when running the operator, including required and optional values that determine the operator’s behavior. The values of the parameters themselves are passed in by the attached Intelligence Configuration.



700
701
702
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 700

def parameters
    @properties['parameters']
end

#paramsHash<String, String>

Returns A map of parameters related to the error, for example, a ‘params.twilioErrorCodeUrl` might hold a URL or link to additional information.

Returns:

  • (Hash<String, String>)

    A map of parameters related to the error, for example, a ‘params.twilioErrorCodeUrl` might hold a URL or link to additional information



730
731
732
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 730

def params
    @properties['params']
end

#promptString

Returns The natural language instructions used by the operator to analyze the conversation. Within the prompt, users can reference parameters using the ‘href="param_name">parameters.}` syntax. Parameter values are provided to the Operator by the Intelligence Configuration Rule at runtime. Note: Prompts will only be exposed for Custom Operators (`author` = `SELF`). Twilio-authored Operators (`author` = `TWILIO`) will have their prompts omitted from the API.

Returns:

  • (String)

    The natural language instructions used by the operator to analyze the conversation. Within the prompt, users can reference parameters using the ‘href="param_name">parameters.}` syntax. Parameter values are provided to the Operator by the Intelligence Configuration Rule at runtime. Note: Prompts will only be exposed for Custom Operators (`author` = `SELF`). Twilio-authored Operators (`author` = `TWILIO`) will have their prompts omitted from the API.



670
671
672
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 670

def prompt
    @properties['prompt']
end

#to_sObject

Provide a user friendly representation



768
769
770
771
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 768

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Intelligence.V3.OperatorInstance #{values}>"
end

#training_examplesArray<OperatorTrainingExample>

Returns An array of example input/output pairs used to illustrate the intended behavior of the Language Operator. These examples help guide the model’s understanding of expected input–output relationships and improve consistency during evaluation and testing. Note: Training examples will only be exposed for Custom Operators (‘author` = `SELF`). Twilio-authored Operators (`author` = `TWILIO`) will have their training examples omitted from the API.

Returns:

  • (Array<OperatorTrainingExample>)

    An array of example input/output pairs used to illustrate the intended behavior of the Language Operator. These examples help guide the model’s understanding of expected input–output relationships and improve consistency during evaluation and testing. Note: Training examples will only be exposed for Custom Operators (‘author` = `SELF`). Twilio-authored Operators (`author` = `TWILIO`) will have their training examples omitted from the API.



688
689
690
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 688

def training_examples
    @properties['training_examples']
end

#update(if_match: :unset, language_operator: nil) ⇒ OperatorInstance

Update the OperatorInstance

Parameters:

  • if_match (String) (defaults to: :unset)

    Current ETag/version required for conditional update

  • language_operator (LanguageOperator) (defaults to: nil)

    Full replacement of a Language Operator configuration

Returns:



755
756
757
758
759
760
761
762
763
764
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 755

def update(
  if_match: :unset,
  language_operator: nil
)

    context.update(
        if_match: if_match, 
        language_operator: language_operator, 
    )
end

#user_errorBoolean

Returns Whether the error is a user error (true) or a system error (false).

Returns:

  • (Boolean)

    Whether the error is a user error (true) or a system error (false)



724
725
726
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 724

def user_error
    @properties['user_error']
end

#versionString

Returns Numeric Operator version. Automatically incremented with each update on the resource, used to ensure integrity when updating the Operator.

Returns:

  • (String)

    Numeric Operator version. Automatically incremented with each update on the resource, used to ensure integrity when updating the Operator.



658
659
660
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 658

def version
    @properties['version']
end