vellum_ai 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/core/file_utilities.rb +26 -0
- data/lib/environment.rb +11 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/requests.rb +88 -0
- data/lib/types_export.rb +255 -0
- data/lib/vellum_ai/deployments/client.rb +157 -0
- data/lib/vellum_ai/deployments/types/deployments_list_request_status.rb +8 -0
- data/lib/vellum_ai/document_indexes/client.rb +135 -0
- data/lib/vellum_ai/documents/client.rb +245 -0
- data/lib/vellum_ai/model_versions/client.rb +61 -0
- data/lib/vellum_ai/registered_prompts/client.rb +154 -0
- data/lib/vellum_ai/sandboxes/client.rb +132 -0
- data/lib/vellum_ai/test_suites/client.rb +130 -0
- data/lib/vellum_ai/types/api_node_result.rb +52 -0
- data/lib/vellum_ai/types/api_node_result_data.rb +80 -0
- data/lib/vellum_ai/types/array_chat_message_content.rb +50 -0
- data/lib/vellum_ai/types/array_chat_message_content_item.rb +103 -0
- data/lib/vellum_ai/types/array_chat_message_content_item_request.rb +103 -0
- data/lib/vellum_ai/types/array_chat_message_content_request.rb +50 -0
- data/lib/vellum_ai/types/block_type_enum.rb +11 -0
- data/lib/vellum_ai/types/chat_history_enum.rb +5 -0
- data/lib/vellum_ai/types/chat_history_input_request.rb +55 -0
- data/lib/vellum_ai/types/chat_message.rb +62 -0
- data/lib/vellum_ai/types/chat_message_content.rb +116 -0
- data/lib/vellum_ai/types/chat_message_content_request.rb +116 -0
- data/lib/vellum_ai/types/chat_message_request.rb +62 -0
- data/lib/vellum_ai/types/chat_message_role.rb +6 -0
- data/lib/vellum_ai/types/code_execution_node_chat_history_result.rb +54 -0
- data/lib/vellum_ai/types/code_execution_node_error_result.rb +56 -0
- data/lib/vellum_ai/types/code_execution_node_json_result.rb +50 -0
- data/lib/vellum_ai/types/code_execution_node_number_result.rb +50 -0
- data/lib/vellum_ai/types/code_execution_node_result.rb +52 -0
- data/lib/vellum_ai/types/code_execution_node_result_data.rb +51 -0
- data/lib/vellum_ai/types/code_execution_node_result_output.rb +142 -0
- data/lib/vellum_ai/types/code_execution_node_search_results_result.rb +54 -0
- data/lib/vellum_ai/types/code_execution_node_string_result.rb +50 -0
- data/lib/vellum_ai/types/conditional_node_result.rb +52 -0
- data/lib/vellum_ai/types/conditional_node_result_data.rb +45 -0
- data/lib/vellum_ai/types/deployment_provider_payload_response.rb +45 -0
- data/lib/vellum_ai/types/deployment_read.rb +115 -0
- data/lib/vellum_ai/types/document_document_to_document_index.rb +70 -0
- data/lib/vellum_ai/types/document_index_read.rb +98 -0
- data/lib/vellum_ai/types/document_read.rb +121 -0
- data/lib/vellum_ai/types/document_status.rb +5 -0
- data/lib/vellum_ai/types/enriched_normalized_completion.rb +118 -0
- data/lib/vellum_ai/types/entity_status.rb +6 -0
- data/lib/vellum_ai/types/environment_enum.rb +6 -0
- data/lib/vellum_ai/types/error_enum.rb +5 -0
- data/lib/vellum_ai/types/error_variable_value.rb +51 -0
- data/lib/vellum_ai/types/execute_prompt_api_error_response.rb +45 -0
- data/lib/vellum_ai/types/execute_prompt_event.rb +116 -0
- data/lib/vellum_ai/types/execute_prompt_response.rb +90 -0
- data/lib/vellum_ai/types/execute_workflow_error_response.rb +45 -0
- data/lib/vellum_ai/types/execute_workflow_response.rb +67 -0
- data/lib/vellum_ai/types/execute_workflow_stream_error_response.rb +45 -0
- data/lib/vellum_ai/types/execute_workflow_workflow_result_event.rb +90 -0
- data/lib/vellum_ai/types/finish_reason_enum.rb +6 -0
- data/lib/vellum_ai/types/fulfilled_enum.rb +5 -0
- data/lib/vellum_ai/types/fulfilled_execute_prompt_event.rb +66 -0
- data/lib/vellum_ai/types/fulfilled_execute_prompt_response.rb +71 -0
- data/lib/vellum_ai/types/fulfilled_execute_workflow_workflow_result_event.rb +61 -0
- data/lib/vellum_ai/types/fulfilled_function_call.rb +56 -0
- data/lib/vellum_ai/types/fulfilled_prompt_execution_meta.rb +52 -0
- data/lib/vellum_ai/types/fulfilled_workflow_node_result_event.rb +90 -0
- data/lib/vellum_ai/types/function_call.rb +90 -0
- data/lib/vellum_ai/types/function_call_chat_message_content.rb +52 -0
- data/lib/vellum_ai/types/function_call_chat_message_content_request.rb +52 -0
- data/lib/vellum_ai/types/function_call_chat_message_content_value.rb +56 -0
- data/lib/vellum_ai/types/function_call_chat_message_content_value_request.rb +56 -0
- data/lib/vellum_ai/types/function_call_enum.rb +5 -0
- data/lib/vellum_ai/types/function_call_variable_value.rb +51 -0
- data/lib/vellum_ai/types/generate_error_response.rb +45 -0
- data/lib/vellum_ai/types/generate_options_request.rb +50 -0
- data/lib/vellum_ai/types/generate_request.rb +60 -0
- data/lib/vellum_ai/types/generate_response.rb +49 -0
- data/lib/vellum_ai/types/generate_result.rb +62 -0
- data/lib/vellum_ai/types/generate_result_data.rb +49 -0
- data/lib/vellum_ai/types/generate_result_error.rb +45 -0
- data/lib/vellum_ai/types/generate_stream_response.rb +51 -0
- data/lib/vellum_ai/types/generate_stream_result.rb +67 -0
- data/lib/vellum_ai/types/generate_stream_result_data.rb +56 -0
- data/lib/vellum_ai/types/image_chat_message_content.rb +52 -0
- data/lib/vellum_ai/types/image_chat_message_content_request.rb +52 -0
- data/lib/vellum_ai/types/image_enum.rb +5 -0
- data/lib/vellum_ai/types/indexing_state_enum.rb +12 -0
- data/lib/vellum_ai/types/initiated_enum.rb +5 -0
- data/lib/vellum_ai/types/initiated_execute_prompt_event.rb +57 -0
- data/lib/vellum_ai/types/initiated_prompt_execution_meta.rb +68 -0
- data/lib/vellum_ai/types/initiated_workflow_node_result_event.rb +90 -0
- data/lib/vellum_ai/types/json_enum.rb +5 -0
- data/lib/vellum_ai/types/json_input_request.rb +51 -0
- data/lib/vellum_ai/types/json_variable_value.rb +45 -0
- data/lib/vellum_ai/types/logical_operator.rb +25 -0
- data/lib/vellum_ai/types/logprobs_enum.rb +6 -0
- data/lib/vellum_ai/types/metadata_filter_config_request.rb +85 -0
- data/lib/vellum_ai/types/metadata_filter_rule_combinator.rb +6 -0
- data/lib/vellum_ai/types/metadata_filter_rule_request.rb +84 -0
- data/lib/vellum_ai/types/model_version_build_config.rb +66 -0
- data/lib/vellum_ai/types/model_version_exec_config.rb +90 -0
- data/lib/vellum_ai/types/model_version_exec_config_parameters.rb +98 -0
- data/lib/vellum_ai/types/model_version_read.rb +133 -0
- data/lib/vellum_ai/types/model_version_read_status_enum.rb +11 -0
- data/lib/vellum_ai/types/model_version_sandbox_snapshot.rb +61 -0
- data/lib/vellum_ai/types/named_test_case_chat_history_variable_value_request.rb +54 -0
- data/lib/vellum_ai/types/named_test_case_error_variable_value_request.rb +56 -0
- data/lib/vellum_ai/types/named_test_case_json_variable_value_request.rb +50 -0
- data/lib/vellum_ai/types/named_test_case_number_variable_value_request.rb +50 -0
- data/lib/vellum_ai/types/named_test_case_search_results_variable_value_request.rb +54 -0
- data/lib/vellum_ai/types/named_test_case_string_variable_value_request.rb +50 -0
- data/lib/vellum_ai/types/named_test_case_variable_value_request.rb +142 -0
- data/lib/vellum_ai/types/node_input_compiled_chat_history_value.rb +59 -0
- data/lib/vellum_ai/types/node_input_compiled_error_value.rb +61 -0
- data/lib/vellum_ai/types/node_input_compiled_json_value.rb +55 -0
- data/lib/vellum_ai/types/node_input_compiled_number_value.rb +55 -0
- data/lib/vellum_ai/types/node_input_compiled_search_results_value.rb +59 -0
- data/lib/vellum_ai/types/node_input_compiled_string_value.rb +55 -0
- data/lib/vellum_ai/types/node_input_variable_compiled_value.rb +142 -0
- data/lib/vellum_ai/types/node_output_compiled_chat_history_value.rb +54 -0
- data/lib/vellum_ai/types/node_output_compiled_error_value.rb +56 -0
- data/lib/vellum_ai/types/node_output_compiled_json_value.rb +50 -0
- data/lib/vellum_ai/types/node_output_compiled_number_value.rb +50 -0
- data/lib/vellum_ai/types/node_output_compiled_search_results_value.rb +54 -0
- data/lib/vellum_ai/types/node_output_compiled_string_value.rb +50 -0
- data/lib/vellum_ai/types/node_output_compiled_value.rb +142 -0
- data/lib/vellum_ai/types/normalized_log_probs.rb +54 -0
- data/lib/vellum_ai/types/normalized_token_log_probs.rb +61 -0
- data/lib/vellum_ai/types/number_enum.rb +5 -0
- data/lib/vellum_ai/types/paginated_slim_deployment_read_list.rb +64 -0
- data/lib/vellum_ai/types/paginated_slim_document_list.rb +64 -0
- data/lib/vellum_ai/types/paginated_slim_workflow_deployment_list.rb +64 -0
- data/lib/vellum_ai/types/processing_failure_reason_enum.rb +9 -0
- data/lib/vellum_ai/types/processing_state_enum.rb +11 -0
- data/lib/vellum_ai/types/prompt_deployment_expand_meta_request_request.rb +74 -0
- data/lib/vellum_ai/types/prompt_deployment_input_request.rb +103 -0
- data/lib/vellum_ai/types/prompt_execution_meta.rb +76 -0
- data/lib/vellum_ai/types/prompt_node_result.rb +52 -0
- data/lib/vellum_ai/types/prompt_node_result_data.rb +55 -0
- data/lib/vellum_ai/types/prompt_output.rb +116 -0
- data/lib/vellum_ai/types/prompt_template_block.rb +62 -0
- data/lib/vellum_ai/types/prompt_template_block_data.rb +54 -0
- data/lib/vellum_ai/types/prompt_template_block_data_request.rb +54 -0
- data/lib/vellum_ai/types/prompt_template_block_properties.rb +104 -0
- data/lib/vellum_ai/types/prompt_template_block_properties_request.rb +104 -0
- data/lib/vellum_ai/types/prompt_template_block_request.rb +62 -0
- data/lib/vellum_ai/types/provider_enum.rb +20 -0
- data/lib/vellum_ai/types/raw_prompt_execution_overrides_request.rb +55 -0
- data/lib/vellum_ai/types/register_prompt_error_response.rb +45 -0
- data/lib/vellum_ai/types/register_prompt_model_parameters_request.rb +98 -0
- data/lib/vellum_ai/types/register_prompt_prompt.rb +50 -0
- data/lib/vellum_ai/types/register_prompt_prompt_info_request.rb +60 -0
- data/lib/vellum_ai/types/register_prompt_response.rb +110 -0
- data/lib/vellum_ai/types/registered_prompt_deployment.rb +55 -0
- data/lib/vellum_ai/types/registered_prompt_input_variable_request.rb +56 -0
- data/lib/vellum_ai/types/registered_prompt_model_version.rb +50 -0
- data/lib/vellum_ai/types/registered_prompt_sandbox.rb +50 -0
- data/lib/vellum_ai/types/registered_prompt_sandbox_snapshot.rb +45 -0
- data/lib/vellum_ai/types/rejected_enum.rb +5 -0
- data/lib/vellum_ai/types/rejected_execute_prompt_event.rb +68 -0
- data/lib/vellum_ai/types/rejected_execute_prompt_response.rb +73 -0
- data/lib/vellum_ai/types/rejected_execute_workflow_workflow_result_event.rb +63 -0
- data/lib/vellum_ai/types/rejected_function_call.rb +62 -0
- data/lib/vellum_ai/types/rejected_prompt_execution_meta.rb +52 -0
- data/lib/vellum_ai/types/rejected_workflow_node_result_event.rb +92 -0
- data/lib/vellum_ai/types/sandbox_scenario.rb +59 -0
- data/lib/vellum_ai/types/scenario_input.rb +70 -0
- data/lib/vellum_ai/types/scenario_input_request.rb +70 -0
- data/lib/vellum_ai/types/scenario_input_type_enum.rb +6 -0
- data/lib/vellum_ai/types/search_error_response.rb +45 -0
- data/lib/vellum_ai/types/search_filters_request.rb +56 -0
- data/lib/vellum_ai/types/search_node_result.rb +52 -0
- data/lib/vellum_ai/types/search_node_result_data.rb +70 -0
- data/lib/vellum_ai/types/search_request_options_request.rb +79 -0
- data/lib/vellum_ai/types/search_response.rb +49 -0
- data/lib/vellum_ai/types/search_result.rb +66 -0
- data/lib/vellum_ai/types/search_result_document.rb +60 -0
- data/lib/vellum_ai/types/search_result_document_request.rb +55 -0
- data/lib/vellum_ai/types/search_result_merging_request.rb +45 -0
- data/lib/vellum_ai/types/search_result_request.rb +66 -0
- data/lib/vellum_ai/types/search_results_enum.rb +5 -0
- data/lib/vellum_ai/types/search_weights_request.rb +50 -0
- data/lib/vellum_ai/types/slim_deployment_read.rb +109 -0
- data/lib/vellum_ai/types/slim_document.rb +126 -0
- data/lib/vellum_ai/types/slim_workflow_deployment.rb +118 -0
- data/lib/vellum_ai/types/streaming_enum.rb +5 -0
- data/lib/vellum_ai/types/streaming_execute_prompt_event.rb +85 -0
- data/lib/vellum_ai/types/streaming_prompt_execution_meta.rb +46 -0
- data/lib/vellum_ai/types/streaming_workflow_node_result_event.rb +99 -0
- data/lib/vellum_ai/types/string_chat_message_content.rb +46 -0
- data/lib/vellum_ai/types/string_chat_message_content_request.rb +46 -0
- data/lib/vellum_ai/types/string_enum.rb +5 -0
- data/lib/vellum_ai/types/string_input_request.rb +51 -0
- data/lib/vellum_ai/types/string_variable_value.rb +45 -0
- data/lib/vellum_ai/types/submit_completion_actual_request.rb +67 -0
- data/lib/vellum_ai/types/submit_completion_actuals_error_response.rb +45 -0
- data/lib/vellum_ai/types/submit_workflow_execution_actual_request.rb +103 -0
- data/lib/vellum_ai/types/templating_node_chat_history_result.rb +54 -0
- data/lib/vellum_ai/types/templating_node_error_result.rb +56 -0
- data/lib/vellum_ai/types/templating_node_json_result.rb +50 -0
- data/lib/vellum_ai/types/templating_node_number_result.rb +50 -0
- data/lib/vellum_ai/types/templating_node_result.rb +52 -0
- data/lib/vellum_ai/types/templating_node_result_data.rb +51 -0
- data/lib/vellum_ai/types/templating_node_result_output.rb +142 -0
- data/lib/vellum_ai/types/templating_node_search_results_result.rb +54 -0
- data/lib/vellum_ai/types/templating_node_string_result.rb +50 -0
- data/lib/vellum_ai/types/terminal_node_chat_history_result.rb +59 -0
- data/lib/vellum_ai/types/terminal_node_error_result.rb +61 -0
- data/lib/vellum_ai/types/terminal_node_json_result.rb +55 -0
- data/lib/vellum_ai/types/terminal_node_number_result.rb +55 -0
- data/lib/vellum_ai/types/terminal_node_result.rb +52 -0
- data/lib/vellum_ai/types/terminal_node_result_data.rb +51 -0
- data/lib/vellum_ai/types/terminal_node_result_output.rb +142 -0
- data/lib/vellum_ai/types/terminal_node_search_results_result.rb +59 -0
- data/lib/vellum_ai/types/terminal_node_string_result.rb +55 -0
- data/lib/vellum_ai/types/test_case_chat_history_variable_value.rb +54 -0
- data/lib/vellum_ai/types/test_case_error_variable_value.rb +56 -0
- data/lib/vellum_ai/types/test_case_json_variable_value.rb +50 -0
- data/lib/vellum_ai/types/test_case_number_variable_value.rb +50 -0
- data/lib/vellum_ai/types/test_case_search_results_variable_value.rb +54 -0
- data/lib/vellum_ai/types/test_case_string_variable_value.rb +50 -0
- data/lib/vellum_ai/types/test_case_variable_value.rb +142 -0
- data/lib/vellum_ai/types/test_suite_test_case.rb +68 -0
- data/lib/vellum_ai/types/upload_document_error_response.rb +45 -0
- data/lib/vellum_ai/types/upload_document_response.rb +45 -0
- data/lib/vellum_ai/types/vellum_error.rb +51 -0
- data/lib/vellum_ai/types/vellum_error_code_enum.rb +10 -0
- data/lib/vellum_ai/types/vellum_error_request.rb +51 -0
- data/lib/vellum_ai/types/vellum_image.rb +50 -0
- data/lib/vellum_ai/types/vellum_image_request.rb +50 -0
- data/lib/vellum_ai/types/vellum_variable.rb +56 -0
- data/lib/vellum_ai/types/vellum_variable_type.rb +16 -0
- data/lib/vellum_ai/types/workflow_event_error.rb +51 -0
- data/lib/vellum_ai/types/workflow_execution_actual_chat_history_request.rb +77 -0
- data/lib/vellum_ai/types/workflow_execution_actual_json_request.rb +73 -0
- data/lib/vellum_ai/types/workflow_execution_actual_string_request.rb +73 -0
- data/lib/vellum_ai/types/workflow_execution_event_error_code.rb +13 -0
- data/lib/vellum_ai/types/workflow_execution_event_type.rb +6 -0
- data/lib/vellum_ai/types/workflow_execution_node_result_event.rb +68 -0
- data/lib/vellum_ai/types/workflow_execution_workflow_result_event.rb +68 -0
- data/lib/vellum_ai/types/workflow_node_result_data.rb +155 -0
- data/lib/vellum_ai/types/workflow_node_result_event.rb +116 -0
- data/lib/vellum_ai/types/workflow_node_result_event_state.rb +11 -0
- data/lib/vellum_ai/types/workflow_output.rb +168 -0
- data/lib/vellum_ai/types/workflow_output_chat_history.rb +60 -0
- data/lib/vellum_ai/types/workflow_output_error.rb +62 -0
- data/lib/vellum_ai/types/workflow_output_function_call.rb +62 -0
- data/lib/vellum_ai/types/workflow_output_image.rb +62 -0
- data/lib/vellum_ai/types/workflow_output_json.rb +56 -0
- data/lib/vellum_ai/types/workflow_output_number.rb +56 -0
- data/lib/vellum_ai/types/workflow_output_search_results.rb +60 -0
- data/lib/vellum_ai/types/workflow_output_string.rb +56 -0
- data/lib/vellum_ai/types/workflow_request_chat_history_input_request.rb +54 -0
- data/lib/vellum_ai/types/workflow_request_input_request.rb +116 -0
- data/lib/vellum_ai/types/workflow_request_json_input_request.rb +50 -0
- data/lib/vellum_ai/types/workflow_request_number_input_request.rb +50 -0
- data/lib/vellum_ai/types/workflow_request_string_input_request.rb +50 -0
- data/lib/vellum_ai/types/workflow_result_event.rb +95 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data.rb +142 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_chat_history.rb +83 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_error.rb +85 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_json.rb +79 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_number.rb +79 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb +83 -0
- data/lib/vellum_ai/types/workflow_result_event_output_data_string.rb +79 -0
- data/lib/vellum_ai/types/workflow_stream_event.rb +90 -0
- data/lib/vellum_ai/workflow_deployments/client.rb +82 -0
- data/lib/vellum_ai/workflow_deployments/types/workflow_deployments_list_request_status.rb +8 -0
- data/lib/vellum_ai.rb +476 -0
- metadata +381 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/scenario_input_request"
|
5
|
+
require_relative "../types/sandbox_scenario"
|
6
|
+
require "async"
|
7
|
+
|
8
|
+
module Vellum
|
9
|
+
class SandboxesClient
|
10
|
+
attr_reader :request_client
|
11
|
+
|
12
|
+
# @param request_client [RequestClient]
|
13
|
+
# @return [SandboxesClient]
|
14
|
+
def initialize(request_client:)
|
15
|
+
# @type [RequestClient]
|
16
|
+
@request_client = request_client
|
17
|
+
end
|
18
|
+
|
19
|
+
# Upserts a new scenario for a sandbox, keying off of the optionally provided scenario id.
|
20
|
+
#
|
21
|
+
# If an id is provided and has a match, the scenario will be updated. If no id is provided or no match
|
22
|
+
# is found, a new scenario will be appended to the end.
|
23
|
+
#
|
24
|
+
# Note that a full replacement of the scenario is performed, so any fields not provided will be removed
|
25
|
+
# or overwritten with default values.
|
26
|
+
#
|
27
|
+
# @param id [String] A UUID string identifying this sandbox.
|
28
|
+
# @param label [String]
|
29
|
+
# @param inputs [Array<Hash>] The inputs for the scenarioRequest of type Array<ScenarioInputRequest>, as a Hash
|
30
|
+
# * :key (String)
|
31
|
+
# * :type (SCENARIO_INPUT_TYPE_ENUM)
|
32
|
+
# * :value (String)
|
33
|
+
# * :chat_history (Array<ChatMessageRequest>)
|
34
|
+
# @param scenario_id [String] The id of the scenario to update. If none is provided, an id will be generated and a new scenario will be appended.
|
35
|
+
# @param request_options [RequestOptions]
|
36
|
+
# @return [SandboxScenario]
|
37
|
+
def upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil)
|
38
|
+
response = @request_client.conn.post do |req|
|
39
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
40
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
41
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
42
|
+
req.body = {
|
43
|
+
**(request_options&.additional_body_parameters || {}),
|
44
|
+
label: label,
|
45
|
+
inputs: inputs,
|
46
|
+
scenario_id: scenario_id
|
47
|
+
}.compact
|
48
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios"
|
49
|
+
end
|
50
|
+
SandboxScenario.from_json(json_object: response.body)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Deletes an existing scenario from a sandbox, keying off of the provided scenario id.
|
54
|
+
#
|
55
|
+
# @param id [String] A UUID string identifying this sandbox.
|
56
|
+
# @param scenario_id [String] An id identifying the scenario that you'd like to delete
|
57
|
+
# @param request_options [RequestOptions]
|
58
|
+
# @return [Void]
|
59
|
+
def delete_sandbox_scenario(id:, scenario_id:, request_options: nil)
|
60
|
+
@request_client.conn.delete do |req|
|
61
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
62
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
63
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
64
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios/#{scenario_id}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class AsyncSandboxesClient
|
70
|
+
attr_reader :request_client
|
71
|
+
|
72
|
+
# @param request_client [AsyncRequestClient]
|
73
|
+
# @return [AsyncSandboxesClient]
|
74
|
+
def initialize(request_client:)
|
75
|
+
# @type [AsyncRequestClient]
|
76
|
+
@request_client = request_client
|
77
|
+
end
|
78
|
+
|
79
|
+
# Upserts a new scenario for a sandbox, keying off of the optionally provided scenario id.
|
80
|
+
#
|
81
|
+
# If an id is provided and has a match, the scenario will be updated. If no id is provided or no match
|
82
|
+
# is found, a new scenario will be appended to the end.
|
83
|
+
#
|
84
|
+
# Note that a full replacement of the scenario is performed, so any fields not provided will be removed
|
85
|
+
# or overwritten with default values.
|
86
|
+
#
|
87
|
+
# @param id [String] A UUID string identifying this sandbox.
|
88
|
+
# @param label [String]
|
89
|
+
# @param inputs [Array<Hash>] The inputs for the scenarioRequest of type Array<ScenarioInputRequest>, as a Hash
|
90
|
+
# * :key (String)
|
91
|
+
# * :type (SCENARIO_INPUT_TYPE_ENUM)
|
92
|
+
# * :value (String)
|
93
|
+
# * :chat_history (Array<ChatMessageRequest>)
|
94
|
+
# @param scenario_id [String] The id of the scenario to update. If none is provided, an id will be generated and a new scenario will be appended.
|
95
|
+
# @param request_options [RequestOptions]
|
96
|
+
# @return [SandboxScenario]
|
97
|
+
def upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil)
|
98
|
+
Async do
|
99
|
+
response = @request_client.conn.post do |req|
|
100
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
101
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
102
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
103
|
+
req.body = {
|
104
|
+
**(request_options&.additional_body_parameters || {}),
|
105
|
+
label: label,
|
106
|
+
inputs: inputs,
|
107
|
+
scenario_id: scenario_id
|
108
|
+
}.compact
|
109
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios"
|
110
|
+
end
|
111
|
+
SandboxScenario.from_json(json_object: response.body)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Deletes an existing scenario from a sandbox, keying off of the provided scenario id.
|
116
|
+
#
|
117
|
+
# @param id [String] A UUID string identifying this sandbox.
|
118
|
+
# @param scenario_id [String] An id identifying the scenario that you'd like to delete
|
119
|
+
# @param request_options [RequestOptions]
|
120
|
+
# @return [Void]
|
121
|
+
def delete_sandbox_scenario(id:, scenario_id:, request_options: nil)
|
122
|
+
Async do
|
123
|
+
@request_client.conn.delete do |req|
|
124
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
125
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
126
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
127
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios/#{scenario_id}"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/named_test_case_variable_value_request"
|
5
|
+
require_relative "../types/test_suite_test_case"
|
6
|
+
require "async"
|
7
|
+
|
8
|
+
module Vellum
|
9
|
+
class TestSuitesClient
|
10
|
+
attr_reader :request_client
|
11
|
+
|
12
|
+
# @param request_client [RequestClient]
|
13
|
+
# @return [TestSuitesClient]
|
14
|
+
def initialize(request_client:)
|
15
|
+
# @type [RequestClient]
|
16
|
+
@request_client = request_client
|
17
|
+
end
|
18
|
+
|
19
|
+
# Upserts a new test case for a test suite, keying off of the optionally provided test case id.
|
20
|
+
#
|
21
|
+
# If an id is provided and has a match, the test case will be updated. If no id is provided or no match
|
22
|
+
# is found, a new test case will be appended to the end.
|
23
|
+
#
|
24
|
+
# Note that a full replacement of the test case is performed, so any fields not provided will be removed
|
25
|
+
# or overwritten with default values.
|
26
|
+
#
|
27
|
+
# @param id [String] A UUID string identifying this test suite.
|
28
|
+
# @param upsert_test_suite_test_case_request_id [String]
|
29
|
+
# @param label [String]
|
30
|
+
# @param input_values [Array<Hash>] Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash
|
31
|
+
# @param evaluation_values [Array<Hash>] Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash
|
32
|
+
# @param request_options [RequestOptions]
|
33
|
+
# @return [TestSuiteTestCase]
|
34
|
+
def upsert_test_suite_test_case(id:, input_values:, evaluation_values:,
|
35
|
+
upsert_test_suite_test_case_request_id: nil, label: nil, request_options: nil)
|
36
|
+
response = @request_client.conn.post do |req|
|
37
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
38
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
39
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
40
|
+
req.body = {
|
41
|
+
**(request_options&.additional_body_parameters || {}),
|
42
|
+
id: upsert_test_suite_test_case_request_id,
|
43
|
+
label: label,
|
44
|
+
input_values: input_values,
|
45
|
+
evaluation_values: evaluation_values
|
46
|
+
}.compact
|
47
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases"
|
48
|
+
end
|
49
|
+
TestSuiteTestCase.from_json(json_object: response.body)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Deletes an existing test case for a test suite, keying off of the test case id.
|
53
|
+
#
|
54
|
+
# @param id [String] A UUID string identifying this test suite.
|
55
|
+
# @param test_case_id [String] An id identifying the test case that you'd like to delete
|
56
|
+
# @param request_options [RequestOptions]
|
57
|
+
# @return [Void]
|
58
|
+
def delete_test_suite_test_case(id:, test_case_id:, request_options: nil)
|
59
|
+
@request_client.conn.delete do |req|
|
60
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
61
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
62
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
63
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases/#{test_case_id}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class AsyncTestSuitesClient
|
69
|
+
attr_reader :request_client
|
70
|
+
|
71
|
+
# @param request_client [AsyncRequestClient]
|
72
|
+
# @return [AsyncTestSuitesClient]
|
73
|
+
def initialize(request_client:)
|
74
|
+
# @type [AsyncRequestClient]
|
75
|
+
@request_client = request_client
|
76
|
+
end
|
77
|
+
|
78
|
+
# Upserts a new test case for a test suite, keying off of the optionally provided test case id.
|
79
|
+
#
|
80
|
+
# If an id is provided and has a match, the test case will be updated. If no id is provided or no match
|
81
|
+
# is found, a new test case will be appended to the end.
|
82
|
+
#
|
83
|
+
# Note that a full replacement of the test case is performed, so any fields not provided will be removed
|
84
|
+
# or overwritten with default values.
|
85
|
+
#
|
86
|
+
# @param id [String] A UUID string identifying this test suite.
|
87
|
+
# @param upsert_test_suite_test_case_request_id [String]
|
88
|
+
# @param label [String]
|
89
|
+
# @param input_values [Array<Hash>] Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash
|
90
|
+
# @param evaluation_values [Array<Hash>] Request of type Array<NamedTestCaseVariableValueRequest>, as a Hash
|
91
|
+
# @param request_options [RequestOptions]
|
92
|
+
# @return [TestSuiteTestCase]
|
93
|
+
def upsert_test_suite_test_case(id:, input_values:, evaluation_values:,
|
94
|
+
upsert_test_suite_test_case_request_id: nil, label: nil, request_options: nil)
|
95
|
+
Async do
|
96
|
+
response = @request_client.conn.post do |req|
|
97
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
98
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
99
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
100
|
+
req.body = {
|
101
|
+
**(request_options&.additional_body_parameters || {}),
|
102
|
+
id: upsert_test_suite_test_case_request_id,
|
103
|
+
label: label,
|
104
|
+
input_values: input_values,
|
105
|
+
evaluation_values: evaluation_values
|
106
|
+
}.compact
|
107
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases"
|
108
|
+
end
|
109
|
+
TestSuiteTestCase.from_json(json_object: response.body)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Deletes an existing test case for a test suite, keying off of the test case id.
|
114
|
+
#
|
115
|
+
# @param id [String] A UUID string identifying this test suite.
|
116
|
+
# @param test_case_id [String] An id identifying the test case that you'd like to delete
|
117
|
+
# @param request_options [RequestOptions]
|
118
|
+
# @return [Void]
|
119
|
+
def delete_test_suite_test_case(id:, test_case_id:, request_options: nil)
|
120
|
+
Async do
|
121
|
+
@request_client.conn.delete do |req|
|
122
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
123
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
124
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
125
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/test-suites/#{id}/test-cases/#{test_case_id}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "api_node_result_data"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
# A Node Result Event emitted from an API Node.
|
8
|
+
class ApiNodeResult
|
9
|
+
attr_reader :data, :additional_properties
|
10
|
+
|
11
|
+
# @param data [ApiNodeResultData]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ApiNodeResult]
|
14
|
+
def initialize(data:, additional_properties: nil)
|
15
|
+
# @type [ApiNodeResultData]
|
16
|
+
@data = data
|
17
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
@additional_properties = additional_properties
|
19
|
+
end
|
20
|
+
|
21
|
+
# Deserialize a JSON object to an instance of ApiNodeResult
|
22
|
+
#
|
23
|
+
# @param json_object [JSON]
|
24
|
+
# @return [ApiNodeResult]
|
25
|
+
def self.from_json(json_object:)
|
26
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
27
|
+
parsed_json = JSON.parse(json_object)
|
28
|
+
if parsed_json["data"].nil?
|
29
|
+
data = nil
|
30
|
+
else
|
31
|
+
data = parsed_json["data"].to_json
|
32
|
+
data = ApiNodeResultData.from_json(json_object: data)
|
33
|
+
end
|
34
|
+
new(data: data, additional_properties: struct)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Serialize an instance of ApiNodeResult to a JSON object
|
38
|
+
#
|
39
|
+
# @return [JSON]
|
40
|
+
def to_json(*_args)
|
41
|
+
{ "data": @data }.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
|
45
|
+
#
|
46
|
+
# @param obj [Object]
|
47
|
+
# @return [Void]
|
48
|
+
def self.validate_raw(obj:)
|
49
|
+
ApiNodeResultData.validate_raw(obj: obj.data)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class ApiNodeResultData
|
7
|
+
attr_reader :text_output_id, :text, :json_output_id, :json, :status_code_output_id, :status_code,
|
8
|
+
:additional_properties
|
9
|
+
|
10
|
+
# @param text_output_id [String]
|
11
|
+
# @param text [String]
|
12
|
+
# @param json_output_id [String]
|
13
|
+
# @param json [Hash{String => String}]
|
14
|
+
# @param status_code_output_id [String]
|
15
|
+
# @param status_code [Integer]
|
16
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
17
|
+
# @return [ApiNodeResultData]
|
18
|
+
def initialize(text_output_id:, json_output_id:, status_code_output_id:, status_code:, text: nil, json: nil,
|
19
|
+
additional_properties: nil)
|
20
|
+
# @type [String]
|
21
|
+
@text_output_id = text_output_id
|
22
|
+
# @type [String]
|
23
|
+
@text = text
|
24
|
+
# @type [String]
|
25
|
+
@json_output_id = json_output_id
|
26
|
+
# @type [Hash{String => String}]
|
27
|
+
@json = json
|
28
|
+
# @type [String]
|
29
|
+
@status_code_output_id = status_code_output_id
|
30
|
+
# @type [Integer]
|
31
|
+
@status_code = status_code
|
32
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
33
|
+
@additional_properties = additional_properties
|
34
|
+
end
|
35
|
+
|
36
|
+
# Deserialize a JSON object to an instance of ApiNodeResultData
|
37
|
+
#
|
38
|
+
# @param json_object [JSON]
|
39
|
+
# @return [ApiNodeResultData]
|
40
|
+
def self.from_json(json_object:)
|
41
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
42
|
+
JSON.parse(json_object)
|
43
|
+
text_output_id = struct.text_output_id
|
44
|
+
text = struct.text
|
45
|
+
json_output_id = struct.json_output_id
|
46
|
+
json = struct.json
|
47
|
+
status_code_output_id = struct.status_code_output_id
|
48
|
+
status_code = struct.status_code
|
49
|
+
new(text_output_id: text_output_id, text: text, json_output_id: json_output_id, json: json,
|
50
|
+
status_code_output_id: status_code_output_id, status_code: status_code, additional_properties: struct)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Serialize an instance of ApiNodeResultData to a JSON object
|
54
|
+
#
|
55
|
+
# @return [JSON]
|
56
|
+
def to_json(*_args)
|
57
|
+
{
|
58
|
+
"text_output_id": @text_output_id,
|
59
|
+
"text": @text,
|
60
|
+
"json_output_id": @json_output_id,
|
61
|
+
"json": @json,
|
62
|
+
"status_code_output_id": @status_code_output_id,
|
63
|
+
"status_code": @status_code
|
64
|
+
}.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
|
68
|
+
#
|
69
|
+
# @param obj [Object]
|
70
|
+
# @return [Void]
|
71
|
+
def self.validate_raw(obj:)
|
72
|
+
obj.text_output_id.is_a?(String) != false || raise("Passed value for field obj.text_output_id is not the expected type, validation failed.")
|
73
|
+
obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
74
|
+
obj.json_output_id.is_a?(String) != false || raise("Passed value for field obj.json_output_id is not the expected type, validation failed.")
|
75
|
+
obj.json&.is_a?(Hash) != false || raise("Passed value for field obj.json is not the expected type, validation failed.")
|
76
|
+
obj.status_code_output_id.is_a?(String) != false || raise("Passed value for field obj.status_code_output_id is not the expected type, validation failed.")
|
77
|
+
obj.status_code.is_a?(Integer) != false || raise("Passed value for field obj.status_code is not the expected type, validation failed.")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "array_chat_message_content_item"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
# A list of chat message content items.
|
8
|
+
class ArrayChatMessageContent
|
9
|
+
attr_reader :value, :additional_properties
|
10
|
+
|
11
|
+
# @param value [Array<ArrayChatMessageContentItem>]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ArrayChatMessageContent]
|
14
|
+
def initialize(value:, additional_properties: nil)
|
15
|
+
# @type [Array<ArrayChatMessageContentItem>]
|
16
|
+
@value = value
|
17
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
@additional_properties = additional_properties
|
19
|
+
end
|
20
|
+
|
21
|
+
# Deserialize a JSON object to an instance of ArrayChatMessageContent
|
22
|
+
#
|
23
|
+
# @param json_object [JSON]
|
24
|
+
# @return [ArrayChatMessageContent]
|
25
|
+
def self.from_json(json_object:)
|
26
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
27
|
+
parsed_json = JSON.parse(json_object)
|
28
|
+
value = parsed_json["value"].map do |v|
|
29
|
+
v = v.to_json
|
30
|
+
ArrayChatMessageContentItem.from_json(json_object: v)
|
31
|
+
end
|
32
|
+
new(value: value, additional_properties: struct)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Serialize an instance of ArrayChatMessageContent to a JSON object
|
36
|
+
#
|
37
|
+
# @return [JSON]
|
38
|
+
def to_json(*_args)
|
39
|
+
{ "value": @value }.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
|
43
|
+
#
|
44
|
+
# @param obj [Object]
|
45
|
+
# @return [Void]
|
46
|
+
def self.validate_raw(obj:)
|
47
|
+
obj.value.is_a?(Array) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require_relative "string_chat_message_content"
|
5
|
+
require_relative "function_call_chat_message_content"
|
6
|
+
require_relative "image_chat_message_content"
|
7
|
+
|
8
|
+
module Vellum
|
9
|
+
class ArrayChatMessageContentItem
|
10
|
+
attr_reader :member, :discriminant
|
11
|
+
|
12
|
+
private_class_method :new
|
13
|
+
alias kind_of? is_a?
|
14
|
+
# @param member [Object]
|
15
|
+
# @param discriminant [String]
|
16
|
+
# @return [ArrayChatMessageContentItem]
|
17
|
+
def initialize(member:, discriminant:)
|
18
|
+
# @type [Object]
|
19
|
+
@member = member
|
20
|
+
# @type [String]
|
21
|
+
@discriminant = discriminant
|
22
|
+
end
|
23
|
+
|
24
|
+
# Deserialize a JSON object to an instance of ArrayChatMessageContentItem
|
25
|
+
#
|
26
|
+
# @param json_object [JSON]
|
27
|
+
# @return [ArrayChatMessageContentItem]
|
28
|
+
def self.from_json(json_object:)
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
30
|
+
member = case struct.type
|
31
|
+
when "STRING"
|
32
|
+
StringChatMessageContent.from_json(json_object: json_object)
|
33
|
+
when "FUNCTION_CALL"
|
34
|
+
FunctionCallChatMessageContent.from_json(json_object: json_object)
|
35
|
+
when "IMAGE"
|
36
|
+
ImageChatMessageContent.from_json(json_object: json_object)
|
37
|
+
else
|
38
|
+
StringChatMessageContent.from_json(json_object: json_object)
|
39
|
+
end
|
40
|
+
new(member: member, discriminant: struct.type)
|
41
|
+
end
|
42
|
+
|
43
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
44
|
+
#
|
45
|
+
# @return [JSON]
|
46
|
+
def to_json(*_args)
|
47
|
+
case @discriminant
|
48
|
+
when "STRING"
|
49
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
50
|
+
when "FUNCTION_CALL"
|
51
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
52
|
+
when "IMAGE"
|
53
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
54
|
+
else
|
55
|
+
{ "type": @discriminant, value: @member }.to_json
|
56
|
+
end
|
57
|
+
@member.to_json
|
58
|
+
end
|
59
|
+
|
60
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
|
61
|
+
#
|
62
|
+
# @param obj [Object]
|
63
|
+
# @return [Void]
|
64
|
+
def self.validate_raw(obj:)
|
65
|
+
case obj.type
|
66
|
+
when "STRING"
|
67
|
+
StringChatMessageContent.validate_raw(obj: obj)
|
68
|
+
when "FUNCTION_CALL"
|
69
|
+
FunctionCallChatMessageContent.validate_raw(obj: obj)
|
70
|
+
when "IMAGE"
|
71
|
+
ImageChatMessageContent.validate_raw(obj: obj)
|
72
|
+
else
|
73
|
+
raise("Passed value matched no type within the union, validation failed.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
78
|
+
#
|
79
|
+
# @param obj [Object]
|
80
|
+
# @return [Boolean]
|
81
|
+
def is_a?(obj)
|
82
|
+
@member.is_a?(obj)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param member [StringChatMessageContent]
|
86
|
+
# @return [ArrayChatMessageContentItem]
|
87
|
+
def self.string(member:)
|
88
|
+
new(member: member, discriminant: "STRING")
|
89
|
+
end
|
90
|
+
|
91
|
+
# @param member [FunctionCallChatMessageContent]
|
92
|
+
# @return [ArrayChatMessageContentItem]
|
93
|
+
def self.function_call(member:)
|
94
|
+
new(member: member, discriminant: "FUNCTION_CALL")
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param member [ImageChatMessageContent]
|
98
|
+
# @return [ArrayChatMessageContentItem]
|
99
|
+
def self.image(member:)
|
100
|
+
new(member: member, discriminant: "IMAGE")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require_relative "string_chat_message_content_request"
|
5
|
+
require_relative "function_call_chat_message_content_request"
|
6
|
+
require_relative "image_chat_message_content_request"
|
7
|
+
|
8
|
+
module Vellum
|
9
|
+
class ArrayChatMessageContentItemRequest
|
10
|
+
attr_reader :member, :discriminant
|
11
|
+
|
12
|
+
private_class_method :new
|
13
|
+
alias kind_of? is_a?
|
14
|
+
# @param member [Object]
|
15
|
+
# @param discriminant [String]
|
16
|
+
# @return [ArrayChatMessageContentItemRequest]
|
17
|
+
def initialize(member:, discriminant:)
|
18
|
+
# @type [Object]
|
19
|
+
@member = member
|
20
|
+
# @type [String]
|
21
|
+
@discriminant = discriminant
|
22
|
+
end
|
23
|
+
|
24
|
+
# Deserialize a JSON object to an instance of ArrayChatMessageContentItemRequest
|
25
|
+
#
|
26
|
+
# @param json_object [JSON]
|
27
|
+
# @return [ArrayChatMessageContentItemRequest]
|
28
|
+
def self.from_json(json_object:)
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
30
|
+
member = case struct.type
|
31
|
+
when "STRING"
|
32
|
+
StringChatMessageContentRequest.from_json(json_object: json_object)
|
33
|
+
when "FUNCTION_CALL"
|
34
|
+
FunctionCallChatMessageContentRequest.from_json(json_object: json_object)
|
35
|
+
when "IMAGE"
|
36
|
+
ImageChatMessageContentRequest.from_json(json_object: json_object)
|
37
|
+
else
|
38
|
+
StringChatMessageContentRequest.from_json(json_object: json_object)
|
39
|
+
end
|
40
|
+
new(member: member, discriminant: struct.type)
|
41
|
+
end
|
42
|
+
|
43
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
44
|
+
#
|
45
|
+
# @return [JSON]
|
46
|
+
def to_json(*_args)
|
47
|
+
case @discriminant
|
48
|
+
when "STRING"
|
49
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
50
|
+
when "FUNCTION_CALL"
|
51
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
52
|
+
when "IMAGE"
|
53
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
54
|
+
else
|
55
|
+
{ "type": @discriminant, value: @member }.to_json
|
56
|
+
end
|
57
|
+
@member.to_json
|
58
|
+
end
|
59
|
+
|
60
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
|
61
|
+
#
|
62
|
+
# @param obj [Object]
|
63
|
+
# @return [Void]
|
64
|
+
def self.validate_raw(obj:)
|
65
|
+
case obj.type
|
66
|
+
when "STRING"
|
67
|
+
StringChatMessageContentRequest.validate_raw(obj: obj)
|
68
|
+
when "FUNCTION_CALL"
|
69
|
+
FunctionCallChatMessageContentRequest.validate_raw(obj: obj)
|
70
|
+
when "IMAGE"
|
71
|
+
ImageChatMessageContentRequest.validate_raw(obj: obj)
|
72
|
+
else
|
73
|
+
raise("Passed value matched no type within the union, validation failed.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
78
|
+
#
|
79
|
+
# @param obj [Object]
|
80
|
+
# @return [Boolean]
|
81
|
+
def is_a?(obj)
|
82
|
+
@member.is_a?(obj)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param member [StringChatMessageContentRequest]
|
86
|
+
# @return [ArrayChatMessageContentItemRequest]
|
87
|
+
def self.string(member:)
|
88
|
+
new(member: member, discriminant: "STRING")
|
89
|
+
end
|
90
|
+
|
91
|
+
# @param member [FunctionCallChatMessageContentRequest]
|
92
|
+
# @return [ArrayChatMessageContentItemRequest]
|
93
|
+
def self.function_call(member:)
|
94
|
+
new(member: member, discriminant: "FUNCTION_CALL")
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param member [ImageChatMessageContentRequest]
|
98
|
+
# @return [ArrayChatMessageContentItemRequest]
|
99
|
+
def self.image(member:)
|
100
|
+
new(member: member, discriminant: "IMAGE")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|