vellum_ai 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/entity_status"
|
5
|
+
require_relative "../types/environment_enum"
|
6
|
+
require_relative "../types/document_index_read"
|
7
|
+
require "async"
|
8
|
+
|
9
|
+
module Vellum
|
10
|
+
class DocumentIndexesClient
|
11
|
+
attr_reader :request_client
|
12
|
+
|
13
|
+
# @param request_client [RequestClient]
|
14
|
+
# @return [DocumentIndexesClient]
|
15
|
+
def initialize(request_client:)
|
16
|
+
# @type [RequestClient]
|
17
|
+
@request_client = request_client
|
18
|
+
end
|
19
|
+
|
20
|
+
# Creates a new document index.
|
21
|
+
#
|
22
|
+
# @param label [String] A human-readable label for the document index
|
23
|
+
# @param name [String] A name that uniquely identifies this index within its workspace
|
24
|
+
# @param status [ENTITY_STATUS] The current status of the document index
|
25
|
+
# * `ACTIVE` - Active
|
26
|
+
# * `ARCHIVED` - Archived
|
27
|
+
# @param environment [ENVIRONMENT_ENUM] The environment this document index is used in
|
28
|
+
# * `DEVELOPMENT` - Development
|
29
|
+
# * `STAGING` - Staging
|
30
|
+
# * `PRODUCTION` - Production
|
31
|
+
# @param indexing_config [Hash{String => String}] Configuration representing how documents should be indexed
|
32
|
+
# @param copy_documents_from_index_id [String] Optionally specify the id of a document index from which you'd like to copy and re-index its documents into this newly created index
|
33
|
+
# @param request_options [RequestOptions]
|
34
|
+
# @return [DocumentIndexRead]
|
35
|
+
def create(label:, name:, indexing_config:, status: nil, environment: nil, copy_documents_from_index_id: nil,
|
36
|
+
request_options: nil)
|
37
|
+
response = @request_client.conn.post do |req|
|
38
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
39
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
40
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
41
|
+
req.body = {
|
42
|
+
**(request_options&.additional_body_parameters || {}),
|
43
|
+
label: label,
|
44
|
+
name: name,
|
45
|
+
status: status,
|
46
|
+
environment: environment,
|
47
|
+
indexing_config: indexing_config,
|
48
|
+
copy_documents_from_index_id: copy_documents_from_index_id
|
49
|
+
}.compact
|
50
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes"
|
51
|
+
end
|
52
|
+
DocumentIndexRead.from_json(json_object: response.body)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Used to retrieve a Document Index given its ID or name.
|
56
|
+
#
|
57
|
+
# @param id [String] Either the Document Index's ID or its unique name
|
58
|
+
# @param request_options [RequestOptions]
|
59
|
+
# @return [DocumentIndexRead]
|
60
|
+
def retrieve(id:, request_options: nil)
|
61
|
+
response = @request_client.conn.get do |req|
|
62
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
63
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
64
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
65
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}"
|
66
|
+
end
|
67
|
+
DocumentIndexRead.from_json(json_object: response.body)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class AsyncDocumentIndexesClient
|
72
|
+
attr_reader :request_client
|
73
|
+
|
74
|
+
# @param request_client [AsyncRequestClient]
|
75
|
+
# @return [AsyncDocumentIndexesClient]
|
76
|
+
def initialize(request_client:)
|
77
|
+
# @type [AsyncRequestClient]
|
78
|
+
@request_client = request_client
|
79
|
+
end
|
80
|
+
|
81
|
+
# Creates a new document index.
|
82
|
+
#
|
83
|
+
# @param label [String] A human-readable label for the document index
|
84
|
+
# @param name [String] A name that uniquely identifies this index within its workspace
|
85
|
+
# @param status [ENTITY_STATUS] The current status of the document index
|
86
|
+
# * `ACTIVE` - Active
|
87
|
+
# * `ARCHIVED` - Archived
|
88
|
+
# @param environment [ENVIRONMENT_ENUM] The environment this document index is used in
|
89
|
+
# * `DEVELOPMENT` - Development
|
90
|
+
# * `STAGING` - Staging
|
91
|
+
# * `PRODUCTION` - Production
|
92
|
+
# @param indexing_config [Hash{String => String}] Configuration representing how documents should be indexed
|
93
|
+
# @param copy_documents_from_index_id [String] Optionally specify the id of a document index from which you'd like to copy and re-index its documents into this newly created index
|
94
|
+
# @param request_options [RequestOptions]
|
95
|
+
# @return [DocumentIndexRead]
|
96
|
+
def create(label:, name:, indexing_config:, status: nil, environment: nil, copy_documents_from_index_id: nil,
|
97
|
+
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
|
+
name: name,
|
107
|
+
status: status,
|
108
|
+
environment: environment,
|
109
|
+
indexing_config: indexing_config,
|
110
|
+
copy_documents_from_index_id: copy_documents_from_index_id
|
111
|
+
}.compact
|
112
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes"
|
113
|
+
end
|
114
|
+
DocumentIndexRead.from_json(json_object: response.body)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Used to retrieve a Document Index given its ID or name.
|
119
|
+
#
|
120
|
+
# @param id [String] Either the Document Index's ID or its unique name
|
121
|
+
# @param request_options [RequestOptions]
|
122
|
+
# @return [DocumentIndexRead]
|
123
|
+
def retrieve(id:, request_options: nil)
|
124
|
+
Async do
|
125
|
+
response = @request_client.conn.get do |req|
|
126
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
127
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
128
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
129
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}"
|
130
|
+
end
|
131
|
+
DocumentIndexRead.from_json(json_object: response.body)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/paginated_slim_document_list"
|
5
|
+
require_relative "../types/document_status"
|
6
|
+
require_relative "../types/document_read"
|
7
|
+
require_relative "../types/upload_document_response"
|
8
|
+
require_relative "../../core/file_utilities"
|
9
|
+
require "async"
|
10
|
+
|
11
|
+
module Vellum
|
12
|
+
class DocumentsClient
|
13
|
+
attr_reader :request_client
|
14
|
+
|
15
|
+
# @param request_client [RequestClient]
|
16
|
+
# @return [DocumentsClient]
|
17
|
+
def initialize(request_client:)
|
18
|
+
# @type [RequestClient]
|
19
|
+
@request_client = request_client
|
20
|
+
end
|
21
|
+
|
22
|
+
# Used to list documents. Optionally filter on supported fields.
|
23
|
+
#
|
24
|
+
# @param document_index_id [String] Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
25
|
+
# @param limit [Integer] Number of results to return per page.
|
26
|
+
# @param offset [Integer] The initial index from which to return the results.
|
27
|
+
# @param ordering [String] Which field to use when ordering the results.
|
28
|
+
# @param request_options [RequestOptions]
|
29
|
+
# @return [PaginatedSlimDocumentList]
|
30
|
+
def list(document_index_id: nil, limit: nil, offset: nil, ordering: nil, request_options: nil)
|
31
|
+
response = @request_client.conn.get do |req|
|
32
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
33
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
34
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
35
|
+
req.params = {
|
36
|
+
**(request_options&.additional_query_parameters || {}),
|
37
|
+
"document_index_id": document_index_id,
|
38
|
+
"limit": limit,
|
39
|
+
"offset": offset,
|
40
|
+
"ordering": ordering
|
41
|
+
}.compact
|
42
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents"
|
43
|
+
end
|
44
|
+
PaginatedSlimDocumentList.from_json(json_object: response.body)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param id [String] A UUID string identifying this document.
|
48
|
+
# @param request_options [RequestOptions]
|
49
|
+
# @return [Void]
|
50
|
+
def destroy(id:, request_options: nil)
|
51
|
+
@request_client.conn.delete do |req|
|
52
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
53
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
54
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
55
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Update a Document, keying off of its Vellum-generated ID. Particularly useful for updating its metadata.
|
60
|
+
#
|
61
|
+
# @param id [String] A UUID string identifying this document.
|
62
|
+
# @param label [String] A human-readable label for the document. Defaults to the originally uploaded file's file name.
|
63
|
+
# @param status [DOCUMENT_STATUS] The current status of the document
|
64
|
+
# * `ACTIVE` - Active
|
65
|
+
# @param metadata [Hash{String => String}] A JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
66
|
+
# @param request_options [RequestOptions]
|
67
|
+
# @return [DocumentRead]
|
68
|
+
def partial_update(id:, label: nil, status: nil, metadata: nil, request_options: nil)
|
69
|
+
response = @request_client.conn.patch do |req|
|
70
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
71
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
72
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
73
|
+
req.body = {
|
74
|
+
**(request_options&.additional_body_parameters || {}),
|
75
|
+
label: label,
|
76
|
+
status: status,
|
77
|
+
metadata: metadata
|
78
|
+
}.compact
|
79
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
|
80
|
+
end
|
81
|
+
DocumentRead.from_json(json_object: response.body)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Upload a document to be indexed and used for search.
|
85
|
+
#
|
86
|
+
# **Note:** Uses a base url of `https://documents.vellum.ai`.
|
87
|
+
#
|
88
|
+
# This is a multipart/form-data request. The `contents` field should be a file upload. It also expects a JSON body with the following fields:
|
89
|
+
#
|
90
|
+
# - `add_to_index_names: list[str]` - Optionally include the names of all indexes that you'd like this document to be included in
|
91
|
+
# - `external_id: str | None` - Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
92
|
+
# - `label: str` - A human-friendly name for this document. Typically the filename.
|
93
|
+
# - `keywords: list[str] | None` - Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
94
|
+
# - `metadata: dict[str, Any]` - A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
95
|
+
#
|
96
|
+
# @param add_to_index_names [Array<String>] Optionally include the names of all indexes that you'd like this document to be included in
|
97
|
+
# @param external_id [String] Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
98
|
+
# @param label [String] A human-friendly name for this document. Typically the filename.
|
99
|
+
# @param contents [String, IO]
|
100
|
+
# @param keywords [Array<String>] Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
101
|
+
# @param metadata [String] A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
102
|
+
# @param request_options [RequestOptions]
|
103
|
+
# @return [UploadDocumentResponse]
|
104
|
+
def upload(label:, contents:, add_to_index_names: nil, external_id: nil, keywords: nil, metadata: nil,
|
105
|
+
request_options: nil)
|
106
|
+
response = @request_client.conn.post do |req|
|
107
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
108
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
109
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
110
|
+
req.body = {
|
111
|
+
**(request_options&.additional_body_parameters || {}),
|
112
|
+
add_to_index_names: add_to_index_names,
|
113
|
+
external_id: external_id,
|
114
|
+
label: label,
|
115
|
+
contents: FileUtilities.as_faraday_multipart(file_like: contents),
|
116
|
+
keywords: keywords,
|
117
|
+
metadata: metadata
|
118
|
+
}.compact
|
119
|
+
req.url "#{@request_client.default_environment[:Documents]}/v1/upload-document"
|
120
|
+
end
|
121
|
+
UploadDocumentResponse.from_json(json_object: response.body)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class AsyncDocumentsClient
|
126
|
+
attr_reader :request_client
|
127
|
+
|
128
|
+
# @param request_client [AsyncRequestClient]
|
129
|
+
# @return [AsyncDocumentsClient]
|
130
|
+
def initialize(request_client:)
|
131
|
+
# @type [AsyncRequestClient]
|
132
|
+
@request_client = request_client
|
133
|
+
end
|
134
|
+
|
135
|
+
# Used to list documents. Optionally filter on supported fields.
|
136
|
+
#
|
137
|
+
# @param document_index_id [String] Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
138
|
+
# @param limit [Integer] Number of results to return per page.
|
139
|
+
# @param offset [Integer] The initial index from which to return the results.
|
140
|
+
# @param ordering [String] Which field to use when ordering the results.
|
141
|
+
# @param request_options [RequestOptions]
|
142
|
+
# @return [PaginatedSlimDocumentList]
|
143
|
+
def list(document_index_id: nil, limit: nil, offset: nil, ordering: nil, request_options: nil)
|
144
|
+
Async do
|
145
|
+
response = @request_client.conn.get do |req|
|
146
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
147
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
148
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
149
|
+
req.params = {
|
150
|
+
**(request_options&.additional_query_parameters || {}),
|
151
|
+
"document_index_id": document_index_id,
|
152
|
+
"limit": limit,
|
153
|
+
"offset": offset,
|
154
|
+
"ordering": ordering
|
155
|
+
}.compact
|
156
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents"
|
157
|
+
end
|
158
|
+
PaginatedSlimDocumentList.from_json(json_object: response.body)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# @param id [String] A UUID string identifying this document.
|
163
|
+
# @param request_options [RequestOptions]
|
164
|
+
# @return [Void]
|
165
|
+
def destroy(id:, request_options: nil)
|
166
|
+
Async do
|
167
|
+
@request_client.conn.delete do |req|
|
168
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
169
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
170
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
171
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Update a Document, keying off of its Vellum-generated ID. Particularly useful for updating its metadata.
|
177
|
+
#
|
178
|
+
# @param id [String] A UUID string identifying this document.
|
179
|
+
# @param label [String] A human-readable label for the document. Defaults to the originally uploaded file's file name.
|
180
|
+
# @param status [DOCUMENT_STATUS] The current status of the document
|
181
|
+
# * `ACTIVE` - Active
|
182
|
+
# @param metadata [Hash{String => String}] A JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
183
|
+
# @param request_options [RequestOptions]
|
184
|
+
# @return [DocumentRead]
|
185
|
+
def partial_update(id:, label: nil, status: nil, metadata: nil, request_options: nil)
|
186
|
+
Async do
|
187
|
+
response = @request_client.conn.patch do |req|
|
188
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
189
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
190
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
191
|
+
req.body = {
|
192
|
+
**(request_options&.additional_body_parameters || {}),
|
193
|
+
label: label,
|
194
|
+
status: status,
|
195
|
+
metadata: metadata
|
196
|
+
}.compact
|
197
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
|
198
|
+
end
|
199
|
+
DocumentRead.from_json(json_object: response.body)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Upload a document to be indexed and used for search.
|
204
|
+
#
|
205
|
+
# **Note:** Uses a base url of `https://documents.vellum.ai`.
|
206
|
+
#
|
207
|
+
# This is a multipart/form-data request. The `contents` field should be a file upload. It also expects a JSON body with the following fields:
|
208
|
+
#
|
209
|
+
# - `add_to_index_names: list[str]` - Optionally include the names of all indexes that you'd like this document to be included in
|
210
|
+
# - `external_id: str | None` - Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
211
|
+
# - `label: str` - A human-friendly name for this document. Typically the filename.
|
212
|
+
# - `keywords: list[str] | None` - Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
213
|
+
# - `metadata: dict[str, Any]` - A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
214
|
+
#
|
215
|
+
# @param add_to_index_names [Array<String>] Optionally include the names of all indexes that you'd like this document to be included in
|
216
|
+
# @param external_id [String] Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
|
217
|
+
# @param label [String] A human-friendly name for this document. Typically the filename.
|
218
|
+
# @param contents [String, IO]
|
219
|
+
# @param keywords [Array<String>] Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
|
220
|
+
# @param metadata [String] A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
|
221
|
+
# @param request_options [RequestOptions]
|
222
|
+
# @return [UploadDocumentResponse]
|
223
|
+
def upload(label:, contents:, add_to_index_names: nil, external_id: nil, keywords: nil, metadata: nil,
|
224
|
+
request_options: nil)
|
225
|
+
Async do
|
226
|
+
response = @request_client.conn.post do |req|
|
227
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
228
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
229
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
230
|
+
req.body = {
|
231
|
+
**(request_options&.additional_body_parameters || {}),
|
232
|
+
add_to_index_names: add_to_index_names,
|
233
|
+
external_id: external_id,
|
234
|
+
label: label,
|
235
|
+
contents: FileUtilities.as_faraday_multipart(file_like: contents),
|
236
|
+
keywords: keywords,
|
237
|
+
metadata: metadata
|
238
|
+
}.compact
|
239
|
+
req.url "#{@request_client.default_environment[:Documents]}/v1/upload-document"
|
240
|
+
end
|
241
|
+
UploadDocumentResponse.from_json(json_object: response.body)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/model_version_read"
|
5
|
+
require "async"
|
6
|
+
|
7
|
+
module Vellum
|
8
|
+
class ModelVersionsClient
|
9
|
+
attr_reader :request_client
|
10
|
+
|
11
|
+
# @param request_client [RequestClient]
|
12
|
+
# @return [ModelVersionsClient]
|
13
|
+
def initialize(request_client:)
|
14
|
+
# @type [RequestClient]
|
15
|
+
@request_client = request_client
|
16
|
+
end
|
17
|
+
|
18
|
+
# Deprecated. Use the `deployments/provider-payload` endpoint to fetch information that we send to Model providers.
|
19
|
+
#
|
20
|
+
# @param id [String] A UUID string identifying this model version.
|
21
|
+
# @param request_options [RequestOptions]
|
22
|
+
# @return [ModelVersionRead]
|
23
|
+
def retrieve(id:, request_options: nil)
|
24
|
+
response = @request_client.conn.get do |req|
|
25
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
26
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
27
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
28
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/model-versions/#{id}"
|
29
|
+
end
|
30
|
+
ModelVersionRead.from_json(json_object: response.body)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class AsyncModelVersionsClient
|
35
|
+
attr_reader :request_client
|
36
|
+
|
37
|
+
# @param request_client [AsyncRequestClient]
|
38
|
+
# @return [AsyncModelVersionsClient]
|
39
|
+
def initialize(request_client:)
|
40
|
+
# @type [AsyncRequestClient]
|
41
|
+
@request_client = request_client
|
42
|
+
end
|
43
|
+
|
44
|
+
# Deprecated. Use the `deployments/provider-payload` endpoint to fetch information that we send to Model providers.
|
45
|
+
#
|
46
|
+
# @param id [String] A UUID string identifying this model version.
|
47
|
+
# @param request_options [RequestOptions]
|
48
|
+
# @return [ModelVersionRead]
|
49
|
+
def retrieve(id:, request_options: nil)
|
50
|
+
Async do
|
51
|
+
response = @request_client.conn.get do |req|
|
52
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
53
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
54
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
55
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/model-versions/#{id}"
|
56
|
+
end
|
57
|
+
ModelVersionRead.from_json(json_object: response.body)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/register_prompt_prompt_info_request"
|
5
|
+
require_relative "../types/provider_enum"
|
6
|
+
require_relative "../types/register_prompt_model_parameters_request"
|
7
|
+
require_relative "../types/register_prompt_response"
|
8
|
+
require "async"
|
9
|
+
|
10
|
+
module Vellum
|
11
|
+
class RegisteredPromptsClient
|
12
|
+
attr_reader :request_client
|
13
|
+
|
14
|
+
# @param request_client [RequestClient]
|
15
|
+
# @return [RegisteredPromptsClient]
|
16
|
+
def initialize(request_client:)
|
17
|
+
# @type [RequestClient]
|
18
|
+
@request_client = request_client
|
19
|
+
end
|
20
|
+
|
21
|
+
# Registers a prompt within Vellum and creates associated Vellum entities. Intended to be used by integration
|
22
|
+
# partners, not directly by Vellum users.
|
23
|
+
#
|
24
|
+
# Under the hood, this endpoint creates a new sandbox, a new model version, and a new deployment.
|
25
|
+
#
|
26
|
+
# @param label [String] A human-friendly label for corresponding entities created in Vellum.
|
27
|
+
# @param name [String] A uniquely-identifying name for corresponding entities created in Vellum.
|
28
|
+
# @param prompt [Hash] Information about how to execute the prompt template.Request of type RegisterPromptPromptInfoRequest, as a Hash
|
29
|
+
# * :prompt_block_data (Hash)
|
30
|
+
# * :version (Integer)
|
31
|
+
# * :blocks (Array<PromptTemplateBlockRequest>)
|
32
|
+
# * :input_variables (Array<RegisteredPromptInputVariableRequest>)
|
33
|
+
# @param provider [PROVIDER_ENUM] The initial LLM provider to use for this prompt
|
34
|
+
# * `ANTHROPIC` - Anthropic
|
35
|
+
# * `AWS_BEDROCK` - AWS Bedrock
|
36
|
+
# * `AZURE_OPENAI` - Azure OpenAI
|
37
|
+
# * `COHERE` - Cohere
|
38
|
+
# * `GOOGLE` - Google
|
39
|
+
# * `HOSTED` - Hosted
|
40
|
+
# * `MOSAICML` - MosaicML
|
41
|
+
# * `OPENAI` - OpenAI
|
42
|
+
# * `FIREWORKS_AI` - Fireworks AI
|
43
|
+
# * `HUGGINGFACE` - HuggingFace
|
44
|
+
# * `MYSTIC` - Mystic
|
45
|
+
# * `PYQ` - Pyq
|
46
|
+
# * `REPLICATE` - Replicate
|
47
|
+
# @param model [String] The initial model to use for this prompt
|
48
|
+
# @param parameters [Hash] The initial model parameters to use for this promptRequest of type RegisterPromptModelParametersRequest, as a Hash
|
49
|
+
# * :temperature (Float)
|
50
|
+
# * :max_tokens (Integer)
|
51
|
+
# * :stop (Array<String>)
|
52
|
+
# * :top_p (Float)
|
53
|
+
# * :top_k (Integer)
|
54
|
+
# * :frequency_penalty (Float)
|
55
|
+
# * :presence_penalty (Float)
|
56
|
+
# * :logit_bias (Hash{String => String})
|
57
|
+
# * :custom_parameters (Hash{String => String})
|
58
|
+
# @param meta [Hash{String => String}] Optionally include additional metadata to store along with the prompt.
|
59
|
+
# @param request_options [RequestOptions]
|
60
|
+
# @return [RegisterPromptResponse]
|
61
|
+
def register_prompt(label:, name:, prompt:, model:, parameters:, provider: nil, meta: nil, request_options: nil)
|
62
|
+
response = @request_client.conn.post do |req|
|
63
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
64
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
65
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
66
|
+
req.body = {
|
67
|
+
**(request_options&.additional_body_parameters || {}),
|
68
|
+
label: label,
|
69
|
+
name: name,
|
70
|
+
prompt: prompt,
|
71
|
+
provider: provider,
|
72
|
+
model: model,
|
73
|
+
parameters: parameters,
|
74
|
+
meta: meta
|
75
|
+
}.compact
|
76
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/registered-prompts/register"
|
77
|
+
end
|
78
|
+
RegisterPromptResponse.from_json(json_object: response.body)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class AsyncRegisteredPromptsClient
|
83
|
+
attr_reader :request_client
|
84
|
+
|
85
|
+
# @param request_client [AsyncRequestClient]
|
86
|
+
# @return [AsyncRegisteredPromptsClient]
|
87
|
+
def initialize(request_client:)
|
88
|
+
# @type [AsyncRequestClient]
|
89
|
+
@request_client = request_client
|
90
|
+
end
|
91
|
+
|
92
|
+
# Registers a prompt within Vellum and creates associated Vellum entities. Intended to be used by integration
|
93
|
+
# partners, not directly by Vellum users.
|
94
|
+
#
|
95
|
+
# Under the hood, this endpoint creates a new sandbox, a new model version, and a new deployment.
|
96
|
+
#
|
97
|
+
# @param label [String] A human-friendly label for corresponding entities created in Vellum.
|
98
|
+
# @param name [String] A uniquely-identifying name for corresponding entities created in Vellum.
|
99
|
+
# @param prompt [Hash] Information about how to execute the prompt template.Request of type RegisterPromptPromptInfoRequest, as a Hash
|
100
|
+
# * :prompt_block_data (Hash)
|
101
|
+
# * :version (Integer)
|
102
|
+
# * :blocks (Array<PromptTemplateBlockRequest>)
|
103
|
+
# * :input_variables (Array<RegisteredPromptInputVariableRequest>)
|
104
|
+
# @param provider [PROVIDER_ENUM] The initial LLM provider to use for this prompt
|
105
|
+
# * `ANTHROPIC` - Anthropic
|
106
|
+
# * `AWS_BEDROCK` - AWS Bedrock
|
107
|
+
# * `AZURE_OPENAI` - Azure OpenAI
|
108
|
+
# * `COHERE` - Cohere
|
109
|
+
# * `GOOGLE` - Google
|
110
|
+
# * `HOSTED` - Hosted
|
111
|
+
# * `MOSAICML` - MosaicML
|
112
|
+
# * `OPENAI` - OpenAI
|
113
|
+
# * `FIREWORKS_AI` - Fireworks AI
|
114
|
+
# * `HUGGINGFACE` - HuggingFace
|
115
|
+
# * `MYSTIC` - Mystic
|
116
|
+
# * `PYQ` - Pyq
|
117
|
+
# * `REPLICATE` - Replicate
|
118
|
+
# @param model [String] The initial model to use for this prompt
|
119
|
+
# @param parameters [Hash] The initial model parameters to use for this promptRequest of type RegisterPromptModelParametersRequest, as a Hash
|
120
|
+
# * :temperature (Float)
|
121
|
+
# * :max_tokens (Integer)
|
122
|
+
# * :stop (Array<String>)
|
123
|
+
# * :top_p (Float)
|
124
|
+
# * :top_k (Integer)
|
125
|
+
# * :frequency_penalty (Float)
|
126
|
+
# * :presence_penalty (Float)
|
127
|
+
# * :logit_bias (Hash{String => String})
|
128
|
+
# * :custom_parameters (Hash{String => String})
|
129
|
+
# @param meta [Hash{String => String}] Optionally include additional metadata to store along with the prompt.
|
130
|
+
# @param request_options [RequestOptions]
|
131
|
+
# @return [RegisterPromptResponse]
|
132
|
+
def register_prompt(label:, name:, prompt:, model:, parameters:, provider: nil, meta: nil, request_options: nil)
|
133
|
+
Async do
|
134
|
+
response = @request_client.conn.post do |req|
|
135
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
136
|
+
req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
137
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
138
|
+
req.body = {
|
139
|
+
**(request_options&.additional_body_parameters || {}),
|
140
|
+
label: label,
|
141
|
+
name: name,
|
142
|
+
prompt: prompt,
|
143
|
+
provider: provider,
|
144
|
+
model: model,
|
145
|
+
parameters: parameters,
|
146
|
+
meta: meta
|
147
|
+
}.compact
|
148
|
+
req.url "#{@request_client.default_environment[:Default]}/v1/registered-prompts/register"
|
149
|
+
end
|
150
|
+
RegisterPromptResponse.from_json(json_object: response.body)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|