Class: ElevenlabsClient::Endpoints::AgentsPlatform::Tests

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/agents_platform/tests.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Tests

Returns a new instance of Tests.



7
8
9
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#create(name:, chat_history:, success_condition:, success_examples:, failure_examples:, **options) ⇒ Hash

POST /v1/convai/agent-testing/create Creates a new agent response test Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/create

Parameters:

  • name (String)

    Name of the test

  • chat_history (Array<Hash>)

    List of chat messages for the test

  • success_condition (String)

    Prompt that evaluates whether the agent's response is successful

  • success_examples (Array<Hash>)

    Non-empty list of example responses that should be considered successful

  • failure_examples (Array<Hash>)

    Non-empty list of example responses that should be considered failures

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :tool_call_parameters (Hash)

    How to evaluate the agent's tool call (if any)

  • :dynamic_variables (Hash)

    Dynamic variables to replace in the agent config during testing

  • :type (String)

    Test type ("llm" or "tool")

Returns:

  • (Hash)

    Created test with ID



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 57

def create(name:, chat_history:, success_condition:, success_examples:, failure_examples:, **options)
  endpoint = "/v1/convai/agent-testing/create"
  request_body = {
    name: name,
    chat_history: chat_history,
    success_condition: success_condition,
    success_examples: success_examples,
    failure_examples: failure_examples
  }.merge(options)
  
  @client.post(endpoint, request_body)
end

#delete(test_id) ⇒ Hash

DELETE /v1/convai/agent-testing/test_id Deletes an agent response test by ID Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/delete

Parameters:

  • test_id (String)

    The id of a chat response test

Returns:

  • (Hash)

    Empty response on success



104
105
106
107
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 104

def delete(test_id)
  endpoint = "/v1/convai/agent-testing/#{test_id}"
  @client.delete(endpoint)
end

#get(test_id) ⇒ Hash

GET /v1/convai/agent-testing/test_id Gets an agent response test by ID Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/get

Parameters:

  • test_id (String)

    The id of a chat response test

Returns:

  • (Hash)

    Complete test details including chat history and evaluation criteria



38
39
40
41
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 38

def get(test_id)
  endpoint = "/v1/convai/agent-testing/#{test_id}"
  @client.get(endpoint)
end

#get_summaries(test_ids) ⇒ Hash

POST /v1/convai/agent-testing/summaries Gets multiple agent response tests by their IDs Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/summaries

Parameters:

  • test_ids (Array<String>)

    List of test IDs to fetch (no duplicates allowed)

Returns:

  • (Hash)

    Dictionary mapping test IDs to their summary information



115
116
117
118
119
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 115

def get_summaries(test_ids)
  endpoint = "/v1/convai/agent-testing/summaries"
  request_body = { test_ids: test_ids }
  @client.post(endpoint, request_body)
end

#list(**options) ⇒ Hash

GET /v1/convai/agent-testing Lists all agent response tests with pagination support and optional search filtering Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/list

Parameters:

  • options (Hash)

    Query parameters

Options Hash (**options):

  • :cursor (String)

    Used for fetching next page

  • :page_size (Integer)

    How many tests to return at maximum (1-100, default: 30)

  • :search (String)

    Search query to filter tests by name

Returns:

  • (Hash)

    List of tests with pagination info



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 20

def list(**options)
  endpoint = "/v1/convai/agent-testing"
  query_params = options.compact
  
  if query_params.any?
    query_string = URI.encode_www_form(query_params)
    endpoint = "#{endpoint}?#{query_string}"
  end
  
  @client.get(endpoint)
end

#run_on_agent(agent_id, tests:, **options) ⇒ Hash

POST /v1/convai/agents/agent_id/run-tests Run selected tests on the agent with provided configuration Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/run-tests

Parameters:

  • agent_id (String)

    The id of an agent

  • tests (Array<Hash>)

    List of tests to run on the agent

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :agent_config_override (Hash)

    Configuration overrides to use for testing

Returns:

  • (Hash)

    Test run results with status and responses



130
131
132
133
134
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 130

def run_on_agent(agent_id, tests:, **options)
  endpoint = "/v1/convai/agents/#{agent_id}/run-tests"
  request_body = { tests: tests }.merge(options)
  @client.post(endpoint, request_body)
end

#update(test_id, name:, chat_history:, success_condition:, success_examples:, failure_examples:, **options) ⇒ Hash

PUT /v1/convai/agent-testing/test_id Updates an agent response test by ID Documentation: https://elevenlabs.io/docs/api-reference/convai/agent-testing/update

Parameters:

  • test_id (String)

    The id of a chat response test

  • name (String)

    Name of the test

  • chat_history (Array<Hash>)

    List of chat messages for the test

  • success_condition (String)

    Prompt that evaluates whether the agent's response is successful

  • success_examples (Array<Hash>)

    Non-empty list of example responses that should be considered successful

  • failure_examples (Array<Hash>)

    Non-empty list of example responses that should be considered failures

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :tool_call_parameters (Hash)

    How to evaluate the agent's tool call (if any)

  • :dynamic_variables (Hash)

    Dynamic variables to replace in the agent config during testing

  • :type (String)

    Test type ("llm" or "tool")

Returns:

  • (Hash)

    Updated test details



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/elevenlabs_client/endpoints/agents_platform/tests.rb', line 85

def update(test_id, name:, chat_history:, success_condition:, success_examples:, failure_examples:, **options)
  endpoint = "/v1/convai/agent-testing/#{test_id}"
  request_body = {
    name: name,
    chat_history: chat_history,
    success_condition: success_condition,
    success_examples: success_examples,
    failure_examples: failure_examples
  }.merge(options)
  
  @client.patch(endpoint, request_body)
end