Class: Vellum::AsyncTestSuitesClient

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:) ⇒ AsyncTestSuitesClient

Parameters:



73
74
75
76
# File 'lib/vellum_ai/test_suites/client.rb', line 73

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



69
70
71
# File 'lib/vellum_ai/test_suites/client.rb', line 69

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)


119
120
121
122
123
124
125
126
127
128
# File 'lib/vellum_ai/test_suites/client.rb', line 119

def delete_test_suite_test_case(id:, test_case_id:, request_options: nil)
  Async do
    @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
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:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vellum_ai/test_suites/client.rb', line 93

def upsert_test_suite_test_case(id:, input_values:, evaluation_values:,
                                upsert_test_suite_test_case_request_id: nil, label: nil, request_options: nil)
  Async do
    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
end