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

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/assistants/tools.rb,
sig/telnyx/resources/ai/assistants/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.



101
102
103
# File 'lib/telnyx/resources/ai/assistants/tools.rb', line 101

def initialize(client:)
  @client = client
end

Instance Method Details

#add(tool_id, assistant_id:, request_options: {}) ⇒ Object

Attach an existing tool to an AI assistant.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/telnyx/resources/ai/assistants/tools.rb', line 22

def add(tool_id, params)
  parsed, options = Telnyx::AI::Assistants::ToolAddParams.dump_request(params)
  assistant_id =
    parsed.delete(:assistant_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["ai/assistants/%1$s/tools/%2$s", assistant_id, tool_id],
    model: Telnyx::Internal::Type::Unknown,
    options: options
  )
end

#remove(tool_id, assistant_id:, request_options: {}) ⇒ Object

Detaches the specified tool from the AI assistant so the assistant can no longer invoke it.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/telnyx/resources/ai/assistants/tools.rb', line 50

def remove(tool_id, params)
  parsed, options = Telnyx::AI::Assistants::ToolRemoveParams.dump_request(params)
  assistant_id =
    parsed.delete(:assistant_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["ai/assistants/%1$s/tools/%2$s", assistant_id, tool_id],
    model: Telnyx::Internal::Type::Unknown,
    options: options
  )
end

#test_(tool_id, assistant_id:, arguments: nil, dynamic_variables: nil, request_options: {}) ⇒ Telnyx::Models::AI::Assistants::ToolTestResponse

Executes a test invocation of the specified webhook tool for the assistant and returns the outcome, so you can verify the webhook's behavior before relying on it in conversations.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/telnyx/resources/ai/assistants/tools.rb', line 83

def test_(tool_id, params)
  parsed, options = Telnyx::AI::Assistants::ToolTestParams.dump_request(params)
  assistant_id =
    parsed.delete(:assistant_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["ai/assistants/%1$s/tools/%2$s/test", assistant_id, tool_id],
    body: parsed,
    model: Telnyx::Models::AI::Assistants::ToolTestResponse,
    options: options
  )
end