Class: Telnyx::Resources::AI::Tools

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/tools.rb,
sig/telnyx/resources/ai/tools.rbs

Overview

Configure AI assistant specifications

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tools

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tools.

Parameters:



179
180
181
# File 'lib/telnyx/resources/ai/tools.rb', line 179

def initialize(client:)
  @client = client
end

Instance Method Details

#create(display_name:, type:, client_side_tool: nil, function: nil, handoff: nil, invite: nil, pay: nil, retrieval: nil, timeout_ms: nil, update_dynamic_variables: nil, webhook: nil, idempotency_key: nil, request_options: {}) ⇒ Telnyx::Models::AI::SharedToolResponse

Some parameter documentations has been truncated, see Models::AI::ToolCreateParams for more details.

Create a new custom AI tool that can be attached to AI assistants.

Parameters:

  • display_name (String)

    Body param

  • type (String)

    Body param

  • client_side_tool (Hash{Symbol=>Object})

    Body param

  • function (Hash{Symbol=>Object})

    Body param

  • handoff (Hash{Symbol=>Object})

    Body param

  • invite (Hash{Symbol=>Object})

    Body param

  • pay (Telnyx::Models::AI::PayToolParams)

    Body param

  • retrieval (Hash{Symbol=>Object})

    Body param

  • timeout_ms (Integer)

    Body param

  • update_dynamic_variables (Telnyx::Models::AI::UpdateDynamicVariablesToolParams)

    Body param: Configuration for an update_dynamic_variables tool.

  • webhook (Hash{Symbol=>Object})

    Body param

  • idempotency_key (String)

    Header param: Optional opaque, unquoted key for safely retrying the same logical

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/telnyx/resources/ai/tools.rb', line 44

def create(params)
  parsed, options = Telnyx::AI::ToolCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "ai/tools",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Telnyx::AI::SharedToolResponse,
    options: options
  )
end

#delete(tool_id, request_options: {}) ⇒ Object

Permanently deletes the specified custom AI tool from your account.

Parameters:

  • tool_id (String)

    Unique identifier of the tool.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (Object)

See Also:



167
168
169
170
171
172
173
174
# File 'lib/telnyx/resources/ai/tools.rb', line 167

def delete(tool_id, params = {})
  @client.request(
    method: :delete,
    path: ["ai/tools/%1$s", tool_id],
    model: Telnyx::Internal::Type::Unknown,
    options: params[:request_options]
  )
end

#list(filter_name: nil, filter_type: nil, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::AI::SharedToolResponse>

Retrieve a list of the custom AI tools configured on your account.

Parameters:

  • filter_name (String)

    Filter results by filter name.

  • filter_type (String)

    Filter results by filter type.

  • page_number (Integer)

    Page number to retrieve (1-based).

  • page_size (Integer)

    Number of items to return per page.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/telnyx/resources/ai/tools.rb', line 138

def list(params = {})
  parsed, options = Telnyx::AI::ToolListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ai/tools",
    query: query.transform_keys(
      filter_name: "filter[name]",
      filter_type: "filter[type]",
      page_number: "page[number]",
      page_size: "page[size]"
    ),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::AI::SharedToolResponse,
    options: options
  )
end

#retrieve(tool_id, request_options: {}) ⇒ Telnyx::Models::AI::SharedToolResponse

Retrieve the details of a specific AI tool.

Parameters:

  • tool_id (String)

    Unique identifier of the tool.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



68
69
70
71
72
73
74
75
# File 'lib/telnyx/resources/ai/tools.rb', line 68

def retrieve(tool_id, params = {})
  @client.request(
    method: :get,
    path: ["ai/tools/%1$s", tool_id],
    model: Telnyx::AI::SharedToolResponse,
    options: params[:request_options]
  )
end

#update(tool_id, client_side_tool: nil, display_name: nil, function: nil, handoff: nil, invite: nil, pay: nil, retrieval: nil, timeout_ms: nil, type: nil, update_dynamic_variables: nil, webhook: nil, request_options: {}) ⇒ Telnyx::Models::AI::SharedToolResponse

Update the configuration of an existing AI tool.

Parameters:

  • tool_id (String)

    Unique identifier of the tool.

  • client_side_tool (Hash{Symbol=>Object})
  • display_name (String)
  • function (Hash{Symbol=>Object})
  • handoff (Hash{Symbol=>Object})
  • invite (Hash{Symbol=>Object})
  • pay (Telnyx::Models::AI::PayToolParams)
  • retrieval (Hash{Symbol=>Object})
  • timeout_ms (Integer)
  • type (String)
  • update_dynamic_variables (Telnyx::Models::AI::UpdateDynamicVariablesToolParams)

    Configuration for an update_dynamic_variables tool.

  • webhook (Hash{Symbol=>Object})
  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
# File 'lib/telnyx/resources/ai/tools.rb', line 110

def update(tool_id, params = {})
  parsed, options = Telnyx::AI::ToolUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["ai/tools/%1$s", tool_id],
    body: parsed,
    model: Telnyx::AI::SharedToolResponse,
    options: options
  )
end