Class: Twilio::REST::Intelligence::V3::OperatorInstance
- Inherits:
-
Twilio::REST::InstanceResource
- Object
- Twilio::REST::InstanceResource
- Twilio::REST::Intelligence::V3::OperatorInstance
- Defined in:
- lib/twilio-ruby/rest/intelligence/v3/operator.rb
Instance Method Summary collapse
- #author ⇒ OperatorAuthor
-
#code ⇒ String
Twilio-specific error code.
- #context ⇒ OperatorContext
-
#delete ⇒ Boolean
Delete the OperatorInstance.
-
#description ⇒ String
Description of the Language Operator further explaining its purpose.
-
#display_name ⇒ String
Display name of the Language Operator describing its purpose.
-
#fetch ⇒ OperatorInstance
Fetch the OperatorInstance.
-
#http_status_code ⇒ String
HTTP response status code.
-
#id ⇒ String
The unique identifier for the Language Operator.
-
#initialize(version, payload, id: nil) ⇒ OperatorInstance
constructor
Initialize the OperatorInstance.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#message ⇒ String
A human readable error message.
- #output_format ⇒ OperatorOutputFormat
-
#output_schema ⇒ Hash
Required for ‘JSON` output only.
-
#parameters ⇒ 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.
-
#params ⇒ 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.
-
#prompt ⇒ String
The natural language instructions used by the operator to analyze the conversation.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#training_examples ⇒ Array<OperatorTrainingExample>
An array of example input/output pairs used to illustrate the intended behavior of the Language Operator.
-
#update(if_match: :unset, language_operator: nil) ⇒ OperatorInstance
Update the OperatorInstance.
-
#user_error ⇒ Boolean
Whether the error is a user error (true) or a system error (false).
-
#version ⇒ String
Numeric Operator version.
Constructor Details
#initialize(version, payload, id: nil) ⇒ OperatorInstance
Initialize the OperatorInstance
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
#author ⇒ OperatorAuthor
664 665 666 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 664 def @properties['author'] end |
#code ⇒ String
Returns Twilio-specific error code.
706 707 708 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 706 def code @properties['code'] end |
#context ⇒ OperatorContext
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 |
#delete ⇒ Boolean
Delete the OperatorInstance
737 738 739 740 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 737 def delete context.delete end |
#description ⇒ String
Returns 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_name ⇒ String
Returns 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 |
#fetch ⇒ OperatorInstance
Fetch the OperatorInstance
745 746 747 748 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 745 def fetch context.fetch end |
#http_status_code ⇒ String
Returns 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 |
#id ⇒ String
Returns 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 |
#inspect ⇒ Object
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 |
#message ⇒ String
Returns A human readable error message.
712 713 714 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 712 def @properties['message'] end |
#output_format ⇒ OperatorOutputFormat
676 677 678 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 676 def output_format @properties['output_format'] end |
#output_schema ⇒ Hash
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.
682 683 684 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 682 def output_schema @properties['output_schema'] end |
#parameters ⇒ Hash<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.
700 701 702 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 700 def parameters @properties['parameters'] end |
#params ⇒ Hash<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.
730 731 732 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 730 def params @properties['params'] end |
#prompt ⇒ String
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.
670 671 672 |
# File 'lib/twilio-ruby/rest/intelligence/v3/operator.rb', line 670 def prompt @properties['prompt'] end |
#to_s ⇒ Object
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_examples ⇒ Array<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.
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
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_error ⇒ Boolean
Returns 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 |
#version ⇒ String
Returns 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 |