Class: Vellum::TestSuitesClient
- Inherits:
-
Object
- Object
- Vellum::TestSuitesClient
- Defined in:
- lib/vellum_ai/test_suites/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#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.
- #initialize(request_client:) ⇒ TestSuitesClient constructor
-
#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.
Constructor Details
#initialize(request_client:) ⇒ TestSuitesClient
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_client ⇒ Object (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.
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.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.
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.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 |