Class: Vellum::TestSuitesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/test_suites/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ TestSuitesClient

Parameters:



14
15
16
17
# File 'lib/vellum_ai/test_suites/client.rb', line 14

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



10
11
12
# File 'lib/vellum_ai/test_suites/client.rb', line 10

def request_client
  @request_client
end

Instance Method Details

#delete_test_suite_test_case(id:, test_case_id:, request_options: nil) ⇒ Void

Deletes an existing test case for a test suite, keying off of the test case id.

Parameters:

  • id (String)

    A UUID string identifying this test suite.

  • test_case_id (String)

    An id identifying the test case that you’d like to delete

  • request_options (RequestOptions) (defaults to: nil)

Returns:

  • (Void)


58
59
60
61
62
63
64
65
# File 'lib/vellum_ai/test_suites/client.rb', line 58

def delete_test_suite_test_case(id:, test_case_id:, request_options: nil)
  @request_client.conn.delete do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases/#{test_case_id}"
  end
end

#upsert_test_suite_test_case(id:, input_values:, evaluation_values:, upsert_test_suite_test_case_request_id: nil, label: nil, request_options: nil) ⇒ TestSuiteTestCase

Upserts a new test case for a test suite, keying off of the optionally provided test case id.

If an id is provided and has a match, the test case will be updated. If no id is provided or no match is found, a new test case will be appended to the end.

Note that a full replacement of the test case is performed, so any fields not provided will be removed or overwritten with default values.

Parameters:

  • id (String)

    A UUID string identifying this test suite.

  • upsert_test_suite_test_case_request_id (String) (defaults to: nil)
  • label (String) (defaults to: nil)
  • input_values (Array<Hash>)

    Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash

  • evaluation_values (Array<Hash>)

    Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash

  • request_options (RequestOptions) (defaults to: nil)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vellum_ai/test_suites/client.rb', line 34

def upsert_test_suite_test_case(id:, input_values:, evaluation_values:,
                                upsert_test_suite_test_case_request_id: nil, label: nil, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      id: upsert_test_suite_test_case_request_id,
      label: label,
      input_values: input_values,
      evaluation_values: evaluation_values
    }.compact
    req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases"
  end
  TestSuiteTestCase.from_json(json_object: response.body)
end