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,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "search_result"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
class SearchResponse
|
8
|
+
attr_reader :results, :additional_properties
|
9
|
+
|
10
|
+
# @param results [Array<SearchResult>] The results of the search. Each result represents a chunk that matches the search query.
|
11
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
12
|
+
# @return [SearchResponse]
|
13
|
+
def initialize(results:, additional_properties: nil)
|
14
|
+
# @type [Array<SearchResult>] The results of the search. Each result represents a chunk that matches the search query.
|
15
|
+
@results = results
|
16
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
17
|
+
@additional_properties = additional_properties
|
18
|
+
end
|
19
|
+
|
20
|
+
# Deserialize a JSON object to an instance of SearchResponse
|
21
|
+
#
|
22
|
+
# @param json_object [JSON]
|
23
|
+
# @return [SearchResponse]
|
24
|
+
def self.from_json(json_object:)
|
25
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
26
|
+
parsed_json = JSON.parse(json_object)
|
27
|
+
results = parsed_json["results"].map do |v|
|
28
|
+
v = v.to_json
|
29
|
+
SearchResult.from_json(json_object: v)
|
30
|
+
end
|
31
|
+
new(results: results, additional_properties: struct)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Serialize an instance of SearchResponse to a JSON object
|
35
|
+
#
|
36
|
+
# @return [JSON]
|
37
|
+
def to_json(*_args)
|
38
|
+
{ "results": @results }.to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
# 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.
|
42
|
+
#
|
43
|
+
# @param obj [Object]
|
44
|
+
# @return [Void]
|
45
|
+
def self.validate_raw(obj:)
|
46
|
+
obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "search_result_document"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
class SearchResult
|
8
|
+
attr_reader :text, :score, :keywords, :document, :additional_properties
|
9
|
+
|
10
|
+
# @param text [String] The text of the chunk that matched the search query.
|
11
|
+
# @param score [Float] A score representing how well the chunk matches the search query.
|
12
|
+
# @param keywords [Array<String>]
|
13
|
+
# @param document [SearchResultDocument] The document that contains the chunk that matched the search query.
|
14
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
# @return [SearchResult]
|
16
|
+
def initialize(text:, score:, keywords:, document:, additional_properties: nil)
|
17
|
+
# @type [String] The text of the chunk that matched the search query.
|
18
|
+
@text = text
|
19
|
+
# @type [Float] A score representing how well the chunk matches the search query.
|
20
|
+
@score = score
|
21
|
+
# @type [Array<String>]
|
22
|
+
@keywords = keywords
|
23
|
+
# @type [SearchResultDocument] The document that contains the chunk that matched the search query.
|
24
|
+
@document = document
|
25
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
26
|
+
@additional_properties = additional_properties
|
27
|
+
end
|
28
|
+
|
29
|
+
# Deserialize a JSON object to an instance of SearchResult
|
30
|
+
#
|
31
|
+
# @param json_object [JSON]
|
32
|
+
# @return [SearchResult]
|
33
|
+
def self.from_json(json_object:)
|
34
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
35
|
+
parsed_json = JSON.parse(json_object)
|
36
|
+
text = struct.text
|
37
|
+
score = struct.score
|
38
|
+
keywords = struct.keywords
|
39
|
+
if parsed_json["document"].nil?
|
40
|
+
document = nil
|
41
|
+
else
|
42
|
+
document = parsed_json["document"].to_json
|
43
|
+
document = SearchResultDocument.from_json(json_object: document)
|
44
|
+
end
|
45
|
+
new(text: text, score: score, keywords: keywords, document: document, additional_properties: struct)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Serialize an instance of SearchResult to a JSON object
|
49
|
+
#
|
50
|
+
# @return [JSON]
|
51
|
+
def to_json(*_args)
|
52
|
+
{ "text": @text, "score": @score, "keywords": @keywords, "document": @document }.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
# 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.
|
56
|
+
#
|
57
|
+
# @param obj [Object]
|
58
|
+
# @return [Void]
|
59
|
+
def self.validate_raw(obj:)
|
60
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
61
|
+
obj.score.is_a?(Float) != false || raise("Passed value for field obj.score is not the expected type, validation failed.")
|
62
|
+
obj.keywords.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
|
63
|
+
SearchResultDocument.validate_raw(obj: obj.document)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class SearchResultDocument
|
7
|
+
attr_reader :id, :label, :external_id, :metadata, :additional_properties
|
8
|
+
|
9
|
+
# @param id [String] The ID of the document.
|
10
|
+
# @param label [String] The human-readable name for the document.
|
11
|
+
# @param external_id [String] The unique ID of the document as represented in an external system and specified when it was originally uploaded.
|
12
|
+
# @param metadata [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [SearchResultDocument]
|
15
|
+
def initialize(id:, label:, external_id: nil, metadata: nil, additional_properties: nil)
|
16
|
+
# @type [String] The ID of the document.
|
17
|
+
@id = id
|
18
|
+
# @type [String] The human-readable name for the document.
|
19
|
+
@label = label
|
20
|
+
# @type [String] The unique ID of the document as represented in an external system and specified when it was originally uploaded.
|
21
|
+
@external_id = external_id
|
22
|
+
# @type [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
23
|
+
@metadata = metadata
|
24
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
@additional_properties = additional_properties
|
26
|
+
end
|
27
|
+
|
28
|
+
# Deserialize a JSON object to an instance of SearchResultDocument
|
29
|
+
#
|
30
|
+
# @param json_object [JSON]
|
31
|
+
# @return [SearchResultDocument]
|
32
|
+
def self.from_json(json_object:)
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
34
|
+
JSON.parse(json_object)
|
35
|
+
id = struct.id
|
36
|
+
label = struct.label
|
37
|
+
external_id = struct.external_id
|
38
|
+
metadata = struct.metadata
|
39
|
+
new(id: id, label: label, external_id: external_id, metadata: metadata, additional_properties: struct)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Serialize an instance of SearchResultDocument to a JSON object
|
43
|
+
#
|
44
|
+
# @return [JSON]
|
45
|
+
def to_json(*_args)
|
46
|
+
{ "id": @id, "label": @label, "external_id": @external_id, "metadata": @metadata }.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
# 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.
|
50
|
+
#
|
51
|
+
# @param obj [Object]
|
52
|
+
# @return [Void]
|
53
|
+
def self.validate_raw(obj:)
|
54
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
55
|
+
obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
|
56
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
57
|
+
obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class SearchResultDocumentRequest
|
7
|
+
attr_reader :label, :external_id, :metadata, :additional_properties
|
8
|
+
|
9
|
+
# @param label [String] The human-readable name for the document.
|
10
|
+
# @param external_id [String] The unique ID of the document as represented in an external system and specified when it was originally uploaded.
|
11
|
+
# @param metadata [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [SearchResultDocumentRequest]
|
14
|
+
def initialize(label:, external_id: nil, metadata: nil, additional_properties: nil)
|
15
|
+
# @type [String] The human-readable name for the document.
|
16
|
+
@label = label
|
17
|
+
# @type [String] The unique ID of the document as represented in an external system and specified when it was originally uploaded.
|
18
|
+
@external_id = external_id
|
19
|
+
# @type [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
20
|
+
@metadata = metadata
|
21
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
22
|
+
@additional_properties = additional_properties
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deserialize a JSON object to an instance of SearchResultDocumentRequest
|
26
|
+
#
|
27
|
+
# @param json_object [JSON]
|
28
|
+
# @return [SearchResultDocumentRequest]
|
29
|
+
def self.from_json(json_object:)
|
30
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
31
|
+
JSON.parse(json_object)
|
32
|
+
label = struct.label
|
33
|
+
external_id = struct.external_id
|
34
|
+
metadata = struct.metadata
|
35
|
+
new(label: label, external_id: external_id, metadata: metadata, additional_properties: struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Serialize an instance of SearchResultDocumentRequest to a JSON object
|
39
|
+
#
|
40
|
+
# @return [JSON]
|
41
|
+
def to_json(*_args)
|
42
|
+
{ "label": @label, "external_id": @external_id, "metadata": @metadata }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
# 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.
|
46
|
+
#
|
47
|
+
# @param obj [Object]
|
48
|
+
# @return [Void]
|
49
|
+
def self.validate_raw(obj:)
|
50
|
+
obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
|
51
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
52
|
+
obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class SearchResultMergingRequest
|
7
|
+
attr_reader :enabled, :additional_properties
|
8
|
+
|
9
|
+
# @param enabled [Boolean] Whether to enable merging results
|
10
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
11
|
+
# @return [SearchResultMergingRequest]
|
12
|
+
def initialize(enabled: nil, additional_properties: nil)
|
13
|
+
# @type [Boolean] Whether to enable merging results
|
14
|
+
@enabled = enabled
|
15
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
16
|
+
@additional_properties = additional_properties
|
17
|
+
end
|
18
|
+
|
19
|
+
# Deserialize a JSON object to an instance of SearchResultMergingRequest
|
20
|
+
#
|
21
|
+
# @param json_object [JSON]
|
22
|
+
# @return [SearchResultMergingRequest]
|
23
|
+
def self.from_json(json_object:)
|
24
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
25
|
+
JSON.parse(json_object)
|
26
|
+
enabled = struct.enabled
|
27
|
+
new(enabled: enabled, additional_properties: struct)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Serialize an instance of SearchResultMergingRequest to a JSON object
|
31
|
+
#
|
32
|
+
# @return [JSON]
|
33
|
+
def to_json(*_args)
|
34
|
+
{ "enabled": @enabled }.to_json
|
35
|
+
end
|
36
|
+
|
37
|
+
# 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.
|
38
|
+
#
|
39
|
+
# @param obj [Object]
|
40
|
+
# @return [Void]
|
41
|
+
def self.validate_raw(obj:)
|
42
|
+
obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "search_result_document_request"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
class SearchResultRequest
|
8
|
+
attr_reader :text, :score, :keywords, :document, :additional_properties
|
9
|
+
|
10
|
+
# @param text [String] The text of the chunk that matched the search query.
|
11
|
+
# @param score [Float] A score representing how well the chunk matches the search query.
|
12
|
+
# @param keywords [Array<String>]
|
13
|
+
# @param document [SearchResultDocumentRequest] The document that contains the chunk that matched the search query.
|
14
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
# @return [SearchResultRequest]
|
16
|
+
def initialize(text:, score:, keywords:, document:, additional_properties: nil)
|
17
|
+
# @type [String] The text of the chunk that matched the search query.
|
18
|
+
@text = text
|
19
|
+
# @type [Float] A score representing how well the chunk matches the search query.
|
20
|
+
@score = score
|
21
|
+
# @type [Array<String>]
|
22
|
+
@keywords = keywords
|
23
|
+
# @type [SearchResultDocumentRequest] The document that contains the chunk that matched the search query.
|
24
|
+
@document = document
|
25
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
26
|
+
@additional_properties = additional_properties
|
27
|
+
end
|
28
|
+
|
29
|
+
# Deserialize a JSON object to an instance of SearchResultRequest
|
30
|
+
#
|
31
|
+
# @param json_object [JSON]
|
32
|
+
# @return [SearchResultRequest]
|
33
|
+
def self.from_json(json_object:)
|
34
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
35
|
+
parsed_json = JSON.parse(json_object)
|
36
|
+
text = struct.text
|
37
|
+
score = struct.score
|
38
|
+
keywords = struct.keywords
|
39
|
+
if parsed_json["document"].nil?
|
40
|
+
document = nil
|
41
|
+
else
|
42
|
+
document = parsed_json["document"].to_json
|
43
|
+
document = SearchResultDocumentRequest.from_json(json_object: document)
|
44
|
+
end
|
45
|
+
new(text: text, score: score, keywords: keywords, document: document, additional_properties: struct)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Serialize an instance of SearchResultRequest to a JSON object
|
49
|
+
#
|
50
|
+
# @return [JSON]
|
51
|
+
def to_json(*_args)
|
52
|
+
{ "text": @text, "score": @score, "keywords": @keywords, "document": @document }.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
# 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.
|
56
|
+
#
|
57
|
+
# @param obj [Object]
|
58
|
+
# @return [Void]
|
59
|
+
def self.validate_raw(obj:)
|
60
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
61
|
+
obj.score.is_a?(Float) != false || raise("Passed value for field obj.score is not the expected type, validation failed.")
|
62
|
+
obj.keywords.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
|
63
|
+
SearchResultDocumentRequest.validate_raw(obj: obj.document)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class SearchWeightsRequest
|
7
|
+
attr_reader :semantic_similarity, :keywords, :additional_properties
|
8
|
+
|
9
|
+
# @param semantic_similarity [Float] The relative weight to give to semantic similarity
|
10
|
+
# @param keywords [Float] The relative weight to give to keywords
|
11
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
12
|
+
# @return [SearchWeightsRequest]
|
13
|
+
def initialize(semantic_similarity: nil, keywords: nil, additional_properties: nil)
|
14
|
+
# @type [Float] The relative weight to give to semantic similarity
|
15
|
+
@semantic_similarity = semantic_similarity
|
16
|
+
# @type [Float] The relative weight to give to keywords
|
17
|
+
@keywords = keywords
|
18
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
19
|
+
@additional_properties = additional_properties
|
20
|
+
end
|
21
|
+
|
22
|
+
# Deserialize a JSON object to an instance of SearchWeightsRequest
|
23
|
+
#
|
24
|
+
# @param json_object [JSON]
|
25
|
+
# @return [SearchWeightsRequest]
|
26
|
+
def self.from_json(json_object:)
|
27
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
28
|
+
JSON.parse(json_object)
|
29
|
+
semantic_similarity = struct.semantic_similarity
|
30
|
+
keywords = struct.keywords
|
31
|
+
new(semantic_similarity: semantic_similarity, keywords: keywords, additional_properties: struct)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Serialize an instance of SearchWeightsRequest to a JSON object
|
35
|
+
#
|
36
|
+
# @return [JSON]
|
37
|
+
def to_json(*_args)
|
38
|
+
{ "semantic_similarity": @semantic_similarity, "keywords": @keywords }.to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
# 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.
|
42
|
+
#
|
43
|
+
# @param obj [Object]
|
44
|
+
# @return [Void]
|
45
|
+
def self.validate_raw(obj:)
|
46
|
+
obj.semantic_similarity&.is_a?(Float) != false || raise("Passed value for field obj.semantic_similarity is not the expected type, validation failed.")
|
47
|
+
obj.keywords&.is_a?(Float) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require_relative "entity_status"
|
5
|
+
require_relative "environment_enum"
|
6
|
+
require_relative "vellum_variable"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module Vellum
|
10
|
+
class SlimDeploymentRead
|
11
|
+
attr_reader :id, :created, :label, :name, :status, :environment, :last_deployed_on, :input_variables,
|
12
|
+
:additional_properties
|
13
|
+
|
14
|
+
# @param id [String]
|
15
|
+
# @param created [DateTime]
|
16
|
+
# @param label [String] A human-readable label for the deployment
|
17
|
+
# @param name [String] A name that uniquely identifies this deployment within its workspace
|
18
|
+
# @param status [ENTITY_STATUS] The current status of the deployment
|
19
|
+
# - `ACTIVE` - Active
|
20
|
+
# - `ARCHIVED` - Archived
|
21
|
+
# @param environment [ENVIRONMENT_ENUM] The environment this deployment is used in
|
22
|
+
# - `DEVELOPMENT` - Development
|
23
|
+
# - `STAGING` - Staging
|
24
|
+
# - `PRODUCTION` - Production
|
25
|
+
# @param last_deployed_on [DateTime]
|
26
|
+
# @param input_variables [Array<VellumVariable>]
|
27
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
28
|
+
# @return [SlimDeploymentRead]
|
29
|
+
def initialize(id:, created:, label:, name:, last_deployed_on:, input_variables:, status: nil, environment: nil,
|
30
|
+
additional_properties: nil)
|
31
|
+
# @type [String]
|
32
|
+
@id = id
|
33
|
+
# @type [DateTime]
|
34
|
+
@created = created
|
35
|
+
# @type [String] A human-readable label for the deployment
|
36
|
+
@label = label
|
37
|
+
# @type [String] A name that uniquely identifies this deployment within its workspace
|
38
|
+
@name = name
|
39
|
+
# @type [ENTITY_STATUS] The current status of the deployment
|
40
|
+
# - `ACTIVE` - Active
|
41
|
+
# - `ARCHIVED` - Archived
|
42
|
+
@status = status
|
43
|
+
# @type [ENVIRONMENT_ENUM] The environment this deployment is used in
|
44
|
+
# - `DEVELOPMENT` - Development
|
45
|
+
# - `STAGING` - Staging
|
46
|
+
# - `PRODUCTION` - Production
|
47
|
+
@environment = environment
|
48
|
+
# @type [DateTime]
|
49
|
+
@last_deployed_on = last_deployed_on
|
50
|
+
# @type [Array<VellumVariable>]
|
51
|
+
@input_variables = input_variables
|
52
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
53
|
+
@additional_properties = additional_properties
|
54
|
+
end
|
55
|
+
|
56
|
+
# Deserialize a JSON object to an instance of SlimDeploymentRead
|
57
|
+
#
|
58
|
+
# @param json_object [JSON]
|
59
|
+
# @return [SlimDeploymentRead]
|
60
|
+
def self.from_json(json_object:)
|
61
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
62
|
+
parsed_json = JSON.parse(json_object)
|
63
|
+
id = struct.id
|
64
|
+
created = DateTime.parse(parsed_json["created"])
|
65
|
+
label = struct.label
|
66
|
+
name = struct.name
|
67
|
+
status = ENTITY_STATUS.key(parsed_json["status"]) || parsed_json["status"]
|
68
|
+
environment = ENVIRONMENT_ENUM.key(parsed_json["environment"]) || parsed_json["environment"]
|
69
|
+
last_deployed_on = DateTime.parse(parsed_json["last_deployed_on"])
|
70
|
+
input_variables = parsed_json["input_variables"].map do |v|
|
71
|
+
v = v.to_json
|
72
|
+
VellumVariable.from_json(json_object: v)
|
73
|
+
end
|
74
|
+
new(id: id, created: created, label: label, name: name, status: status, environment: environment,
|
75
|
+
last_deployed_on: last_deployed_on, input_variables: input_variables, additional_properties: struct)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Serialize an instance of SlimDeploymentRead to a JSON object
|
79
|
+
#
|
80
|
+
# @return [JSON]
|
81
|
+
def to_json(*_args)
|
82
|
+
{
|
83
|
+
"id": @id,
|
84
|
+
"created": @created,
|
85
|
+
"label": @label,
|
86
|
+
"name": @name,
|
87
|
+
"status": ENTITY_STATUS[@status] || @status,
|
88
|
+
"environment": ENVIRONMENT_ENUM[@environment] || @environment,
|
89
|
+
"last_deployed_on": @last_deployed_on,
|
90
|
+
"input_variables": @input_variables
|
91
|
+
}.to_json
|
92
|
+
end
|
93
|
+
|
94
|
+
# 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.
|
95
|
+
#
|
96
|
+
# @param obj [Object]
|
97
|
+
# @return [Void]
|
98
|
+
def self.validate_raw(obj:)
|
99
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
100
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
101
|
+
obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
|
102
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
103
|
+
obj.status&.is_a?(ENTITY_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
104
|
+
obj.environment&.is_a?(ENVIRONMENT_ENUM) != false || raise("Passed value for field obj.environment is not the expected type, validation failed.")
|
105
|
+
obj.last_deployed_on.is_a?(DateTime) != false || raise("Passed value for field obj.last_deployed_on is not the expected type, validation failed.")
|
106
|
+
obj.input_variables.is_a?(Array) != false || raise("Passed value for field obj.input_variables is not the expected type, validation failed.")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require_relative "processing_state_enum"
|
5
|
+
require_relative "processing_failure_reason_enum"
|
6
|
+
require_relative "document_status"
|
7
|
+
require_relative "document_document_to_document_index"
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
module Vellum
|
11
|
+
class SlimDocument
|
12
|
+
attr_reader :id, :external_id, :last_uploaded_at, :label, :processing_state, :processing_failure_reason, :status,
|
13
|
+
:keywords, :metadata, :document_to_document_indexes, :additional_properties
|
14
|
+
|
15
|
+
# @param id [String] Vellum-generated ID that uniquely identifies this document.
|
16
|
+
# @param external_id [String] The external ID that was originally provided when uploading the document.
|
17
|
+
# @param last_uploaded_at [DateTime] A timestamp representing when this document was most recently uploaded.
|
18
|
+
# @param label [String] Human-friendly name for this document.
|
19
|
+
# @param processing_state [PROCESSING_STATE_ENUM] An enum value representing where this document is along its processing lifecycle. Note that this is different than its indexing lifecycle.
|
20
|
+
# - `QUEUED` - Queued
|
21
|
+
# - `PROCESSING` - Processing
|
22
|
+
# - `PROCESSED` - Processed
|
23
|
+
# - `FAILED` - Failed
|
24
|
+
# @param processing_failure_reason [PROCESSING_FAILURE_REASON_ENUM] An enum value representing why the document could not be processed. Is null unless processing_state is FAILED.
|
25
|
+
# - `EXCEEDED_CHARACTER_LIMIT` - Exceeded Character Limit
|
26
|
+
# - `INVALID_FILE` - Invalid File
|
27
|
+
# @param status [DOCUMENT_STATUS] The document's current status.
|
28
|
+
# - `ACTIVE` - Active
|
29
|
+
# @param keywords [Array<String>] A list of keywords associated with this document. Originally provided when uploading the document.
|
30
|
+
# @param metadata [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
31
|
+
# @param document_to_document_indexes [Array<DocumentDocumentToDocumentIndex>]
|
32
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
33
|
+
# @return [SlimDocument]
|
34
|
+
def initialize(id:, last_uploaded_at:, label:, document_to_document_indexes:, external_id: nil, processing_state: nil,
|
35
|
+
processing_failure_reason: nil, status: nil, keywords: nil, metadata: nil, additional_properties: nil)
|
36
|
+
# @type [String] Vellum-generated ID that uniquely identifies this document.
|
37
|
+
@id = id
|
38
|
+
# @type [String] The external ID that was originally provided when uploading the document.
|
39
|
+
@external_id = external_id
|
40
|
+
# @type [DateTime] A timestamp representing when this document was most recently uploaded.
|
41
|
+
@last_uploaded_at = last_uploaded_at
|
42
|
+
# @type [String] Human-friendly name for this document.
|
43
|
+
@label = label
|
44
|
+
# @type [PROCESSING_STATE_ENUM] An enum value representing where this document is along its processing lifecycle. Note that this is different than its indexing lifecycle.
|
45
|
+
# - `QUEUED` - Queued
|
46
|
+
# - `PROCESSING` - Processing
|
47
|
+
# - `PROCESSED` - Processed
|
48
|
+
# - `FAILED` - Failed
|
49
|
+
@processing_state = processing_state
|
50
|
+
# @type [PROCESSING_FAILURE_REASON_ENUM] An enum value representing why the document could not be processed. Is null unless processing_state is FAILED.
|
51
|
+
# - `EXCEEDED_CHARACTER_LIMIT` - Exceeded Character Limit
|
52
|
+
# - `INVALID_FILE` - Invalid File
|
53
|
+
@processing_failure_reason = processing_failure_reason
|
54
|
+
# @type [DOCUMENT_STATUS] The document's current status.
|
55
|
+
# - `ACTIVE` - Active
|
56
|
+
@status = status
|
57
|
+
# @type [Array<String>] A list of keywords associated with this document. Originally provided when uploading the document.
|
58
|
+
@keywords = keywords
|
59
|
+
# @type [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
|
60
|
+
@metadata = metadata
|
61
|
+
# @type [Array<DocumentDocumentToDocumentIndex>]
|
62
|
+
@document_to_document_indexes = document_to_document_indexes
|
63
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
64
|
+
@additional_properties = additional_properties
|
65
|
+
end
|
66
|
+
|
67
|
+
# Deserialize a JSON object to an instance of SlimDocument
|
68
|
+
#
|
69
|
+
# @param json_object [JSON]
|
70
|
+
# @return [SlimDocument]
|
71
|
+
def self.from_json(json_object:)
|
72
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
73
|
+
parsed_json = JSON.parse(json_object)
|
74
|
+
id = struct.id
|
75
|
+
external_id = struct.external_id
|
76
|
+
last_uploaded_at = DateTime.parse(parsed_json["last_uploaded_at"])
|
77
|
+
label = struct.label
|
78
|
+
processing_state = PROCESSING_STATE_ENUM.key(parsed_json["processing_state"]) || parsed_json["processing_state"]
|
79
|
+
processing_failure_reason = PROCESSING_FAILURE_REASON_ENUM.key(parsed_json["processing_failure_reason"]) || parsed_json["processing_failure_reason"]
|
80
|
+
status = struct.status
|
81
|
+
keywords = struct.keywords
|
82
|
+
metadata = struct.metadata
|
83
|
+
document_to_document_indexes = parsed_json["document_to_document_indexes"].map do |v|
|
84
|
+
v = v.to_json
|
85
|
+
DocumentDocumentToDocumentIndex.from_json(json_object: v)
|
86
|
+
end
|
87
|
+
new(id: id, external_id: external_id, last_uploaded_at: last_uploaded_at, label: label,
|
88
|
+
processing_state: processing_state, processing_failure_reason: processing_failure_reason, status: status, keywords: keywords, metadata: metadata, document_to_document_indexes: document_to_document_indexes, additional_properties: struct)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Serialize an instance of SlimDocument to a JSON object
|
92
|
+
#
|
93
|
+
# @return [JSON]
|
94
|
+
def to_json(*_args)
|
95
|
+
{
|
96
|
+
"id": @id,
|
97
|
+
"external_id": @external_id,
|
98
|
+
"last_uploaded_at": @last_uploaded_at,
|
99
|
+
"label": @label,
|
100
|
+
"processing_state": PROCESSING_STATE_ENUM[@processing_state] || @processing_state,
|
101
|
+
"processing_failure_reason": PROCESSING_FAILURE_REASON_ENUM[@processing_failure_reason] || @processing_failure_reason,
|
102
|
+
"status": @status,
|
103
|
+
"keywords": @keywords,
|
104
|
+
"metadata": @metadata,
|
105
|
+
"document_to_document_indexes": @document_to_document_indexes
|
106
|
+
}.to_json
|
107
|
+
end
|
108
|
+
|
109
|
+
# 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.
|
110
|
+
#
|
111
|
+
# @param obj [Object]
|
112
|
+
# @return [Void]
|
113
|
+
def self.validate_raw(obj:)
|
114
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
115
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
116
|
+
obj.last_uploaded_at.is_a?(DateTime) != false || raise("Passed value for field obj.last_uploaded_at is not the expected type, validation failed.")
|
117
|
+
obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
|
118
|
+
obj.processing_state&.is_a?(PROCESSING_STATE_ENUM) != false || raise("Passed value for field obj.processing_state is not the expected type, validation failed.")
|
119
|
+
obj.processing_failure_reason&.is_a?(PROCESSING_FAILURE_REASON_ENUM) != false || raise("Passed value for field obj.processing_failure_reason is not the expected type, validation failed.")
|
120
|
+
obj.status&.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
121
|
+
obj.keywords&.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
|
122
|
+
obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
|
123
|
+
obj.document_to_document_indexes.is_a?(Array) != false || raise("Passed value for field obj.document_to_document_indexes is not the expected type, validation failed.")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|