vellum-ai 0.3.23__py3-none-any.whl → 0.5.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/__init__.py +37 -60
- vellum/client.py +139 -137
- vellum/core/__init__.py +2 -0
- vellum/core/client_wrapper.py +1 -1
- vellum/core/jsonable_encoder.py +5 -9
- vellum/core/pydantic_utilities.py +12 -0
- vellum/errors/__init__.py +1 -2
- vellum/lib/__init__.py +5 -0
- vellum/lib/test_suites/__init__.py +5 -0
- vellum/lib/test_suites/constants.py +2 -0
- vellum/lib/test_suites/exceptions.py +2 -0
- vellum/lib/test_suites/resources.py +253 -0
- vellum/lib/utils/__init__.py +0 -0
- vellum/lib/utils/env.py +11 -0
- vellum/lib/utils/exceptions.py +2 -0
- vellum/lib/utils/paginator.py +28 -0
- vellum/resources/__init__.py +0 -4
- vellum/resources/deployments/client.py +27 -31
- vellum/resources/deployments/types/deployments_list_request_status.py +1 -13
- vellum/resources/document_indexes/client.py +35 -39
- vellum/resources/document_indexes/types/document_indexes_list_request_status.py +1 -13
- vellum/resources/documents/client.py +131 -35
- vellum/resources/folder_entities/client.py +4 -4
- vellum/resources/sandboxes/client.py +18 -46
- vellum/resources/test_suite_runs/client.py +19 -23
- vellum/resources/test_suites/client.py +17 -21
- vellum/resources/workflow_deployments/client.py +13 -17
- vellum/resources/workflow_deployments/types/workflow_deployments_list_request_status.py +1 -13
- vellum/types/__init__.py +37 -55
- vellum/types/api_node_result.py +3 -7
- vellum/types/api_node_result_data.py +4 -8
- vellum/types/array_chat_message_content.py +3 -7
- vellum/types/array_chat_message_content_request.py +3 -7
- vellum/types/chat_history_input_request.py +4 -8
- vellum/types/chat_history_variable_value.py +3 -7
- vellum/types/chat_message.py +4 -8
- vellum/types/chat_message_request.py +4 -8
- vellum/types/chat_message_role.py +1 -32
- vellum/types/code_execution_node_array_result.py +3 -7
- vellum/types/code_execution_node_chat_history_result.py +3 -7
- vellum/types/code_execution_node_error_result.py +3 -7
- vellum/types/code_execution_node_function_call_result.py +3 -7
- vellum/types/code_execution_node_json_result.py +3 -7
- vellum/types/code_execution_node_number_result.py +3 -7
- vellum/types/code_execution_node_result.py +3 -7
- vellum/types/code_execution_node_result_data.py +3 -7
- vellum/types/code_execution_node_search_results_result.py +3 -7
- vellum/types/code_execution_node_string_result.py +3 -7
- vellum/types/conditional_node_result.py +3 -7
- vellum/types/conditional_node_result_data.py +3 -7
- vellum/types/deployment_provider_payload_response.py +3 -7
- vellum/types/deployment_read.py +8 -12
- vellum/types/document_document_to_document_index.py +6 -10
- vellum/types/document_index_read.py +8 -12
- vellum/types/document_read.py +8 -12
- vellum/types/enriched_normalized_completion.py +9 -13
- vellum/types/entity_status.py +1 -18
- vellum/types/environment_enum.py +1 -27
- vellum/types/error_variable_value.py +3 -7
- vellum/types/execute_prompt_api_error_response.py +4 -8
- vellum/types/execute_workflow_error_response.py +4 -8
- vellum/types/execute_workflow_response.py +3 -7
- vellum/types/execute_workflow_stream_error_response.py +4 -8
- vellum/types/execution_array_vellum_value.py +4 -8
- vellum/types/execution_chat_history_vellum_value.py +4 -8
- vellum/types/execution_error_vellum_value.py +4 -8
- vellum/types/execution_function_call_vellum_value.py +4 -8
- vellum/types/execution_json_vellum_value.py +4 -8
- vellum/types/execution_number_vellum_value.py +4 -8
- vellum/types/execution_search_results_vellum_value.py +4 -8
- vellum/types/execution_string_vellum_value.py +4 -8
- vellum/types/external_test_case_execution.py +4 -8
- vellum/types/external_test_case_execution_request.py +4 -8
- vellum/types/finish_reason_enum.py +1 -27
- vellum/types/fulfilled_execute_prompt_event.py +3 -7
- vellum/types/fulfilled_execute_prompt_response.py +5 -9
- vellum/types/fulfilled_execute_workflow_workflow_result_event.py +3 -7
- vellum/types/fulfilled_function_call.py +3 -7
- vellum/types/{registered_prompt_input_variable_request.py → fulfilled_function_call_request.py} +10 -9
- vellum/types/fulfilled_prompt_execution_meta.py +3 -7
- vellum/types/fulfilled_workflow_node_result_event.py +3 -7
- vellum/types/function_call_chat_message_content.py +3 -7
- vellum/types/function_call_chat_message_content_request.py +3 -7
- vellum/types/function_call_chat_message_content_value.py +3 -7
- vellum/types/function_call_chat_message_content_value_request.py +3 -7
- vellum/types/function_call_variable_value.py +3 -7
- vellum/types/generate_error_response.py +4 -8
- vellum/types/generate_options_request.py +4 -8
- vellum/types/generate_request.py +6 -10
- vellum/types/generate_result.py +5 -9
- vellum/types/generate_result_data.py +4 -8
- vellum/types/generate_result_error.py +4 -8
- vellum/types/generate_stream_response.py +3 -7
- vellum/types/generate_stream_result.py +3 -7
- vellum/types/generate_stream_result_data.py +3 -7
- vellum/types/image_chat_message_content.py +3 -7
- vellum/types/image_chat_message_content_request.py +3 -7
- vellum/types/image_variable_value.py +3 -7
- vellum/types/indexing_state_enum.py +3 -37
- vellum/types/initiated_execute_prompt_event.py +3 -7
- vellum/types/initiated_prompt_execution_meta.py +3 -7
- vellum/types/initiated_workflow_node_result_event.py +3 -7
- vellum/types/json_input_request.py +4 -8
- vellum/types/json_variable_value.py +3 -7
- vellum/types/logical_operator.py +23 -173
- vellum/types/logprobs_enum.py +1 -18
- vellum/types/metadata_filter_config_request.py +3 -7
- vellum/types/metadata_filter_rule_combinator.py +1 -18
- vellum/types/metadata_filter_rule_request.py +3 -7
- vellum/types/ml_model_usage.py +3 -7
- vellum/types/named_scenario_input_chat_history_variable_value_request.py +31 -0
- vellum/types/named_scenario_input_request.py +31 -0
- vellum/types/{registered_prompt_sandbox_snapshot.py → named_scenario_input_string_variable_value_request.py} +7 -9
- vellum/types/named_test_case_chat_history_variable_value.py +3 -7
- vellum/types/named_test_case_chat_history_variable_value_request.py +3 -7
- vellum/types/named_test_case_error_variable_value.py +3 -7
- vellum/types/named_test_case_error_variable_value_request.py +3 -7
- vellum/types/{register_prompt_prompt.py → named_test_case_function_call_variable_value.py} +7 -13
- vellum/types/named_test_case_function_call_variable_value_request.py +31 -0
- vellum/types/named_test_case_json_variable_value.py +3 -7
- vellum/types/named_test_case_json_variable_value_request.py +3 -7
- vellum/types/named_test_case_number_variable_value.py +3 -7
- vellum/types/named_test_case_number_variable_value_request.py +3 -7
- vellum/types/named_test_case_search_results_variable_value.py +3 -7
- vellum/types/named_test_case_search_results_variable_value_request.py +3 -7
- vellum/types/named_test_case_string_variable_value.py +3 -7
- vellum/types/named_test_case_string_variable_value_request.py +3 -7
- vellum/types/named_test_case_variable_value.py +12 -0
- vellum/types/named_test_case_variable_value_request.py +12 -0
- vellum/types/node_input_compiled_array_value.py +3 -7
- vellum/types/node_input_compiled_chat_history_value.py +3 -7
- vellum/types/node_input_compiled_error_value.py +3 -7
- vellum/types/node_input_compiled_function_call.py +3 -7
- vellum/types/node_input_compiled_json_value.py +3 -7
- vellum/types/node_input_compiled_number_value.py +3 -7
- vellum/types/node_input_compiled_search_results_value.py +3 -7
- vellum/types/node_input_compiled_string_value.py +3 -7
- vellum/types/node_output_compiled_array_value.py +3 -7
- vellum/types/node_output_compiled_chat_history_value.py +3 -7
- vellum/types/node_output_compiled_error_value.py +3 -7
- vellum/types/node_output_compiled_function_value.py +3 -7
- vellum/types/node_output_compiled_json_value.py +3 -7
- vellum/types/node_output_compiled_number_value.py +3 -7
- vellum/types/node_output_compiled_search_results_value.py +3 -7
- vellum/types/node_output_compiled_string_value.py +3 -7
- vellum/types/normalized_log_probs.py +3 -7
- vellum/types/normalized_token_log_probs.py +3 -7
- vellum/types/number_variable_value.py +3 -7
- vellum/types/paginated_document_index_read_list.py +3 -7
- vellum/types/paginated_slim_deployment_read_list.py +3 -7
- vellum/types/paginated_slim_document_list.py +3 -7
- vellum/types/paginated_slim_workflow_deployment_list.py +3 -7
- vellum/types/paginated_test_suite_run_execution_list.py +3 -7
- vellum/types/paginated_test_suite_test_case_list.py +3 -7
- vellum/types/processing_failure_reason_enum.py +1 -20
- vellum/types/processing_state_enum.py +1 -32
- vellum/types/prompt_deployment_expand_meta_request_request.py +9 -13
- vellum/types/prompt_execution_meta.py +3 -7
- vellum/types/prompt_node_result.py +3 -7
- vellum/types/prompt_node_result_data.py +3 -7
- vellum/types/raw_prompt_execution_overrides_request.py +5 -9
- vellum/types/rejected_execute_prompt_event.py +3 -7
- vellum/types/rejected_execute_prompt_response.py +5 -9
- vellum/types/rejected_execute_workflow_workflow_result_event.py +3 -7
- vellum/types/rejected_function_call.py +3 -7
- vellum/types/rejected_prompt_execution_meta.py +3 -7
- vellum/types/rejected_workflow_node_result_event.py +3 -7
- vellum/types/sandbox_scenario.py +5 -9
- vellum/types/scenario_input.py +18 -21
- vellum/types/{registered_prompt_sandbox.py → scenario_input_chat_history_variable_value.py} +7 -13
- vellum/types/{register_prompt_error_response.py → scenario_input_string_variable_value.py} +7 -9
- vellum/types/search_error_response.py +4 -8
- vellum/types/search_filters_request.py +5 -9
- vellum/types/search_node_result.py +3 -7
- vellum/types/search_node_result_data.py +4 -8
- vellum/types/search_request_options_request.py +7 -11
- vellum/types/search_response.py +4 -8
- vellum/types/search_result.py +6 -10
- vellum/types/search_result_document.py +7 -11
- vellum/types/search_result_document_request.py +6 -10
- vellum/types/search_result_merging_request.py +4 -8
- vellum/types/search_result_request.py +6 -10
- vellum/types/search_results_variable_value.py +3 -7
- vellum/types/search_weights_request.py +5 -9
- vellum/types/slim_deployment_read.py +7 -11
- vellum/types/slim_document.py +12 -16
- vellum/types/slim_workflow_deployment.py +9 -13
- vellum/types/streaming_execute_prompt_event.py +4 -8
- vellum/types/streaming_prompt_execution_meta.py +3 -7
- vellum/types/streaming_workflow_node_result_event.py +3 -7
- vellum/types/string_chat_message_content.py +3 -7
- vellum/types/string_chat_message_content_request.py +3 -7
- vellum/types/string_input_request.py +4 -8
- vellum/types/string_variable_value.py +3 -7
- vellum/types/submit_completion_actual_request.py +8 -12
- vellum/types/submit_completion_actuals_error_response.py +3 -7
- vellum/types/subworkflow_node_result.py +3 -7
- vellum/types/templating_node_array_result.py +3 -7
- vellum/types/templating_node_chat_history_result.py +3 -7
- vellum/types/templating_node_error_result.py +3 -7
- vellum/types/templating_node_function_call_result.py +3 -7
- vellum/types/templating_node_json_result.py +3 -7
- vellum/types/templating_node_number_result.py +3 -7
- vellum/types/templating_node_result.py +3 -7
- vellum/types/templating_node_result_data.py +3 -7
- vellum/types/templating_node_search_results_result.py +3 -7
- vellum/types/templating_node_string_result.py +3 -7
- vellum/types/terminal_node_array_result.py +4 -8
- vellum/types/terminal_node_chat_history_result.py +4 -8
- vellum/types/terminal_node_error_result.py +4 -8
- vellum/types/terminal_node_function_call_result.py +4 -8
- vellum/types/terminal_node_json_result.py +4 -8
- vellum/types/terminal_node_number_result.py +4 -8
- vellum/types/terminal_node_result.py +3 -7
- vellum/types/terminal_node_result_data.py +3 -7
- vellum/types/terminal_node_search_results_result.py +4 -8
- vellum/types/terminal_node_string_result.py +4 -8
- vellum/types/test_case_chat_history_variable_value.py +3 -7
- vellum/types/test_case_error_variable_value.py +3 -7
- vellum/types/test_case_function_call_variable_value.py +32 -0
- vellum/types/test_case_json_variable_value.py +3 -7
- vellum/types/test_case_number_variable_value.py +3 -7
- vellum/types/test_case_search_results_variable_value.py +3 -7
- vellum/types/test_case_string_variable_value.py +3 -7
- vellum/types/test_case_variable_value.py +12 -0
- vellum/types/test_suite_run_deployment_release_tag_exec_config.py +4 -8
- vellum/types/test_suite_run_deployment_release_tag_exec_config_data.py +5 -9
- vellum/types/test_suite_run_deployment_release_tag_exec_config_data_request.py +5 -9
- vellum/types/test_suite_run_deployment_release_tag_exec_config_request.py +4 -8
- vellum/types/test_suite_run_execution.py +3 -7
- vellum/types/test_suite_run_execution_chat_history_output.py +3 -7
- vellum/types/test_suite_run_execution_error_output.py +3 -7
- vellum/types/{registered_prompt_model_version.py → test_suite_run_execution_function_call_output.py} +8 -13
- vellum/types/test_suite_run_execution_json_output.py +3 -7
- vellum/types/test_suite_run_execution_metric_definition.py +3 -7
- vellum/types/test_suite_run_execution_metric_result.py +3 -7
- vellum/types/test_suite_run_execution_number_output.py +3 -7
- vellum/types/test_suite_run_execution_output.py +12 -0
- vellum/types/test_suite_run_execution_search_results_output.py +3 -7
- vellum/types/test_suite_run_execution_string_output.py +3 -7
- vellum/types/test_suite_run_external_exec_config.py +4 -8
- vellum/types/test_suite_run_external_exec_config_data.py +4 -8
- vellum/types/test_suite_run_external_exec_config_data_request.py +4 -8
- vellum/types/test_suite_run_external_exec_config_request.py +4 -8
- vellum/types/test_suite_run_metric_error_output.py +3 -7
- vellum/types/test_suite_run_metric_number_output.py +3 -7
- vellum/types/test_suite_run_metric_string_output.py +3 -7
- vellum/types/test_suite_run_read.py +5 -9
- vellum/types/test_suite_run_state.py +1 -37
- vellum/types/test_suite_run_test_suite.py +3 -7
- vellum/types/test_suite_run_workflow_release_tag_exec_config.py +4 -8
- vellum/types/test_suite_run_workflow_release_tag_exec_config_data.py +5 -9
- vellum/types/test_suite_run_workflow_release_tag_exec_config_data_request.py +5 -9
- vellum/types/test_suite_run_workflow_release_tag_exec_config_request.py +4 -8
- vellum/types/test_suite_test_case.py +3 -7
- vellum/types/upload_document_error_response.py +3 -7
- vellum/types/upload_document_response.py +4 -8
- vellum/types/vellum_error.py +3 -7
- vellum/types/vellum_error_code_enum.py +3 -32
- vellum/types/vellum_error_request.py +3 -7
- vellum/types/vellum_image.py +3 -7
- vellum/types/vellum_image_request.py +3 -7
- vellum/types/vellum_variable.py +3 -7
- vellum/types/vellum_variable_type.py +6 -57
- vellum/types/workflow_deployment_read.py +9 -13
- vellum/types/workflow_event_error.py +3 -7
- vellum/types/workflow_execution_actual_chat_history_request.py +8 -12
- vellum/types/workflow_execution_actual_json_request.py +8 -12
- vellum/types/workflow_execution_actual_string_request.py +8 -12
- vellum/types/workflow_execution_event_error_code.py +13 -52
- vellum/types/workflow_execution_event_type.py +1 -18
- vellum/types/workflow_execution_node_result_event.py +3 -7
- vellum/types/workflow_execution_workflow_result_event.py +3 -7
- vellum/types/workflow_node_result_event_state.py +3 -32
- vellum/types/workflow_output_array.py +4 -8
- vellum/types/workflow_output_chat_history.py +4 -8
- vellum/types/workflow_output_error.py +4 -8
- vellum/types/workflow_output_function_call.py +4 -8
- vellum/types/workflow_output_image.py +4 -8
- vellum/types/workflow_output_json.py +4 -8
- vellum/types/workflow_output_number.py +4 -8
- vellum/types/workflow_output_search_results.py +4 -8
- vellum/types/workflow_output_string.py +4 -8
- vellum/types/workflow_request_chat_history_input_request.py +4 -8
- vellum/types/workflow_request_json_input_request.py +4 -8
- vellum/types/workflow_request_number_input_request.py +4 -8
- vellum/types/workflow_request_string_input_request.py +4 -8
- vellum/types/workflow_result_event.py +3 -7
- vellum/types/workflow_result_event_output_data_array.py +4 -8
- vellum/types/workflow_result_event_output_data_chat_history.py +4 -8
- vellum/types/workflow_result_event_output_data_error.py +4 -8
- vellum/types/workflow_result_event_output_data_function_call.py +4 -8
- vellum/types/workflow_result_event_output_data_json.py +4 -8
- vellum/types/workflow_result_event_output_data_number.py +4 -8
- vellum/types/workflow_result_event_output_data_search_results.py +4 -8
- vellum/types/workflow_result_event_output_data_string.py +5 -9
- {vellum_ai-0.3.23.dist-info → vellum_ai-0.5.0.dist-info}/METADATA +1 -2
- vellum_ai-0.5.0.dist-info/RECORD +382 -0
- vellum/errors/conflict_error.py +0 -9
- vellum/resources/model_versions/__init__.py +0 -2
- vellum/resources/model_versions/client.py +0 -123
- vellum/resources/registered_prompts/__init__.py +0 -2
- vellum/resources/registered_prompts/client.py +0 -327
- vellum/types/block_type_enum.py +0 -36
- vellum/types/model_version_build_config.py +0 -40
- vellum/types/model_version_exec_config.py +0 -48
- vellum/types/model_version_exec_config_parameters.py +0 -37
- vellum/types/model_version_read.py +0 -82
- vellum/types/model_version_read_status_enum.py +0 -36
- vellum/types/model_version_sandbox_snapshot.py +0 -44
- vellum/types/prompt_template_block.py +0 -41
- vellum/types/prompt_template_block_data.py +0 -31
- vellum/types/prompt_template_block_data_request.py +0 -31
- vellum/types/prompt_template_block_properties.py +0 -47
- vellum/types/prompt_template_block_properties_request.py +0 -47
- vellum/types/prompt_template_block_request.py +0 -41
- vellum/types/prompt_template_block_state.py +0 -22
- vellum/types/provider_enum.py +0 -81
- vellum/types/register_prompt_model_parameters_request.py +0 -37
- vellum/types/register_prompt_prompt_info_request.py +0 -35
- vellum/types/register_prompt_response.py +0 -62
- vellum/types/registered_prompt_deployment.py +0 -42
- vellum/types/scenario_input_request.py +0 -34
- vellum/types/scenario_input_type_enum.py +0 -22
- vellum_ai-0.3.23.dist-info/RECORD +0 -394
- {vellum_ai-0.3.23.dist-info → vellum_ai-0.5.0.dist-info}/LICENSE +0 -0
- {vellum_ai-0.3.23.dist-info → vellum_ai-0.5.0.dist-info}/WHEEL +0 -0
vellum/core/__init__.py
CHANGED
@@ -6,6 +6,7 @@ from .datetime_utils import serialize_datetime
|
|
6
6
|
from .file import File, convert_file_dict_to_httpx_tuples
|
7
7
|
from .http_client import AsyncHttpClient, HttpClient
|
8
8
|
from .jsonable_encoder import jsonable_encoder
|
9
|
+
from .pydantic_utilities import pydantic_v1
|
9
10
|
from .remove_none_from_dict import remove_none_from_dict
|
10
11
|
from .request_options import RequestOptions
|
11
12
|
|
@@ -20,6 +21,7 @@ __all__ = [
|
|
20
21
|
"SyncClientWrapper",
|
21
22
|
"convert_file_dict_to_httpx_tuples",
|
22
23
|
"jsonable_encoder",
|
24
|
+
"pydantic_v1",
|
23
25
|
"remove_none_from_dict",
|
24
26
|
"serialize_datetime",
|
25
27
|
]
|
vellum/core/client_wrapper.py
CHANGED
@@ -18,7 +18,7 @@ class BaseClientWrapper:
|
|
18
18
|
headers: typing.Dict[str, str] = {
|
19
19
|
"X-Fern-Language": "Python",
|
20
20
|
"X-Fern-SDK-Name": "vellum-ai",
|
21
|
-
"X-Fern-SDK-Version": "0.
|
21
|
+
"X-Fern-SDK-Version": "0.5.0",
|
22
22
|
}
|
23
23
|
headers["X_API_KEY"] = self.api_key
|
24
24
|
return headers
|
vellum/core/jsonable_encoder.py
CHANGED
@@ -16,12 +16,8 @@ from pathlib import PurePath
|
|
16
16
|
from types import GeneratorType
|
17
17
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
|
18
18
|
|
19
|
-
try:
|
20
|
-
import pydantic.v1 as pydantic # type: ignore
|
21
|
-
except ImportError:
|
22
|
-
import pydantic # type: ignore
|
23
|
-
|
24
19
|
from .datetime_utils import serialize_datetime
|
20
|
+
from .pydantic_utilities import pydantic_v1
|
25
21
|
|
26
22
|
SetIntStr = Set[Union[int, str]]
|
27
23
|
DictIntStrAny = Dict[Union[int, str], Any]
|
@@ -36,7 +32,7 @@ def generate_encoders_by_class_tuples(
|
|
36
32
|
return encoders_by_class_tuples
|
37
33
|
|
38
34
|
|
39
|
-
encoders_by_class_tuples = generate_encoders_by_class_tuples(
|
35
|
+
encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE)
|
40
36
|
|
41
37
|
|
42
38
|
def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
|
@@ -48,7 +44,7 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
48
44
|
for encoder_type, encoder_instance in custom_encoder.items():
|
49
45
|
if isinstance(obj, encoder_type):
|
50
46
|
return encoder_instance(obj)
|
51
|
-
if isinstance(obj,
|
47
|
+
if isinstance(obj, pydantic_v1.BaseModel):
|
52
48
|
encoder = getattr(obj.__config__, "json_encoders", {})
|
53
49
|
if custom_encoder:
|
54
50
|
encoder.update(custom_encoder)
|
@@ -84,8 +80,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
84
80
|
encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder))
|
85
81
|
return encoded_list
|
86
82
|
|
87
|
-
if type(obj) in
|
88
|
-
return
|
83
|
+
if type(obj) in pydantic_v1.json.ENCODERS_BY_TYPE:
|
84
|
+
return pydantic_v1.json.ENCODERS_BY_TYPE[type(obj)](obj)
|
89
85
|
for encoder, classes_tuple in encoders_by_class_tuples.items():
|
90
86
|
if isinstance(obj, classes_tuple):
|
91
87
|
return encoder(obj)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import pydantic
|
4
|
+
|
5
|
+
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
|
6
|
+
|
7
|
+
if IS_PYDANTIC_V2:
|
8
|
+
import pydantic.v1 as pydantic_v1 # type: ignore # nopycln: import
|
9
|
+
else:
|
10
|
+
import pydantic as pydantic_v1 # type: ignore # nopycln: import
|
11
|
+
|
12
|
+
__all__ = ["pydantic_v1"]
|
vellum/errors/__init__.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
from .bad_request_error import BadRequestError
|
4
|
-
from .conflict_error import ConflictError
|
5
4
|
from .forbidden_error import ForbiddenError
|
6
5
|
from .internal_server_error import InternalServerError
|
7
6
|
from .not_found_error import NotFoundError
|
8
7
|
|
9
|
-
__all__ = ["BadRequestError", "
|
8
|
+
__all__ = ["BadRequestError", "ForbiddenError", "InternalServerError", "NotFoundError"]
|
vellum/lib/__init__.py
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import logging
|
4
|
+
import time
|
5
|
+
from typing import Callable, Generator, List
|
6
|
+
|
7
|
+
from vellum.client import Vellum
|
8
|
+
from vellum.lib.test_suites.constants import (
|
9
|
+
DEFAULT_MAX_POLLING_DURATION_MS,
|
10
|
+
DEFAULT_POLLING_INTERVAL_MS,
|
11
|
+
)
|
12
|
+
from vellum.lib.test_suites.exceptions import TestSuiteRunResultsException
|
13
|
+
from vellum.lib.utils.env import get_api_key
|
14
|
+
from vellum.types import (
|
15
|
+
ExternalTestCaseExecutionRequest,
|
16
|
+
NamedTestCaseVariableValueRequest,
|
17
|
+
TestCaseVariableValue,
|
18
|
+
TestSuiteRunExecConfigRequest_External,
|
19
|
+
TestSuiteRunExecution,
|
20
|
+
TestSuiteRunExternalExecConfigDataRequest,
|
21
|
+
TestSuiteRunMetricOutput,
|
22
|
+
TestSuiteRunState,
|
23
|
+
)
|
24
|
+
|
25
|
+
from vellum.lib.utils.paginator import PaginatedResults, get_all_results
|
26
|
+
|
27
|
+
|
28
|
+
logger = logging.getLogger(__name__)
|
29
|
+
|
30
|
+
|
31
|
+
class VellumTestSuiteRunExecution(TestSuiteRunExecution):
|
32
|
+
@classmethod
|
33
|
+
def from_api(cls, execution: TestSuiteRunExecution) -> VellumTestSuiteRunExecution:
|
34
|
+
return cls(
|
35
|
+
id=execution.id,
|
36
|
+
test_case_id=execution.test_case_id,
|
37
|
+
outputs=execution.outputs,
|
38
|
+
metric_results=execution.metric_results,
|
39
|
+
)
|
40
|
+
|
41
|
+
def get_metric_output(
|
42
|
+
self,
|
43
|
+
metric_identifier: str | None = None,
|
44
|
+
output_identifier: str | None = None,
|
45
|
+
) -> TestSuiteRunMetricOutput:
|
46
|
+
"""Retrieve a metric's output by specifying the info needed to uniquely identify that metric and output.
|
47
|
+
|
48
|
+
metric_identifier: Anything that uniquely identifies the metric to retrieve (e.g. it's label, name or id)
|
49
|
+
output_identifier: Anything that uniquely identifies the output to retrieve (e.g. it's name)
|
50
|
+
"""
|
51
|
+
|
52
|
+
metric_outputs = self.get_metric_outputs(metric_identifier)
|
53
|
+
|
54
|
+
filtered_metric_outputs = [
|
55
|
+
metric_output
|
56
|
+
for metric_output in metric_outputs
|
57
|
+
if output_identifier is None or metric_output.name == output_identifier
|
58
|
+
]
|
59
|
+
|
60
|
+
if len(filtered_metric_outputs) == 0:
|
61
|
+
raise TestSuiteRunResultsException(
|
62
|
+
f"No metric outputs found with identifier: {output_identifier}"
|
63
|
+
)
|
64
|
+
|
65
|
+
if len(filtered_metric_outputs) > 1:
|
66
|
+
raise TestSuiteRunResultsException(
|
67
|
+
f"Multiple metric outputs found with identifier: {output_identifier}"
|
68
|
+
)
|
69
|
+
|
70
|
+
return filtered_metric_outputs[0]
|
71
|
+
|
72
|
+
def get_metric_outputs(
|
73
|
+
self,
|
74
|
+
metric_identifier: str | None = None,
|
75
|
+
) -> List[TestSuiteRunMetricOutput]:
|
76
|
+
"""Return a metric's output across all executions by providing the info needed to uniquely identify it.
|
77
|
+
|
78
|
+
metric_identifier: Anything that uniquely identifies the metric to retrieve (e.g. it's label, name or id).
|
79
|
+
"""
|
80
|
+
|
81
|
+
filtered_metric_results = [
|
82
|
+
metric_output
|
83
|
+
for metric_output in self.metric_results
|
84
|
+
if metric_identifier is None
|
85
|
+
or (metric_output.metric_id == metric_identifier)
|
86
|
+
or (metric_output.metric_label == metric_identifier)
|
87
|
+
or (
|
88
|
+
metric_output.metric_definition
|
89
|
+
and metric_output.metric_definition.id == metric_identifier
|
90
|
+
)
|
91
|
+
or (
|
92
|
+
metric_output.metric_definition
|
93
|
+
and metric_output.metric_definition.name == metric_identifier
|
94
|
+
)
|
95
|
+
or (
|
96
|
+
metric_output.metric_definition
|
97
|
+
and metric_output.metric_definition.label == metric_identifier
|
98
|
+
)
|
99
|
+
]
|
100
|
+
|
101
|
+
if len(filtered_metric_results) == 0:
|
102
|
+
raise TestSuiteRunResultsException(
|
103
|
+
f"No metric results found with identifier: {metric_identifier}"
|
104
|
+
)
|
105
|
+
|
106
|
+
if len(filtered_metric_results) > 1:
|
107
|
+
raise TestSuiteRunResultsException(
|
108
|
+
f"Multiple metric results found with identifier: {metric_identifier}"
|
109
|
+
)
|
110
|
+
|
111
|
+
return filtered_metric_results[0].outputs
|
112
|
+
|
113
|
+
|
114
|
+
class VellumTestSuiteRunResults:
|
115
|
+
"""A utility class with methods for conveniently operating on a Test Suite Run and its results."""
|
116
|
+
|
117
|
+
def __init__(
|
118
|
+
self,
|
119
|
+
test_suite_run_id: str,
|
120
|
+
*,
|
121
|
+
client: Vellum | None = None,
|
122
|
+
polling_interval: int = DEFAULT_POLLING_INTERVAL_MS,
|
123
|
+
max_polling_duration: int = DEFAULT_MAX_POLLING_DURATION_MS,
|
124
|
+
) -> None:
|
125
|
+
self._test_suite_run_id = test_suite_run_id
|
126
|
+
self._client = client or Vellum(
|
127
|
+
api_key=get_api_key(),
|
128
|
+
)
|
129
|
+
self._state = "QUEUED"
|
130
|
+
self._executions: Generator[VellumTestSuiteRunExecution, None, None] | None = (
|
131
|
+
None
|
132
|
+
)
|
133
|
+
self._polling_interval = polling_interval
|
134
|
+
self._max_polling_duration = max_polling_duration
|
135
|
+
|
136
|
+
def get_metric_outputs(
|
137
|
+
self, metric_identifier: str | None = None, output_identifier: str | None = None
|
138
|
+
) -> Generator[TestSuiteRunMetricOutput, None, None]:
|
139
|
+
"""Retrieve a metric's output across all executions by providing the info needed to uniquely identify it."""
|
140
|
+
|
141
|
+
executions = self._get_test_suite_run_executions()
|
142
|
+
|
143
|
+
for execution in executions:
|
144
|
+
yield execution.get_metric_output(
|
145
|
+
metric_identifier=metric_identifier, output_identifier=output_identifier
|
146
|
+
)
|
147
|
+
|
148
|
+
def _refresh_test_suite_run_state(self):
|
149
|
+
test_suite_run = self._client.test_suite_runs.retrieve(self._test_suite_run_id)
|
150
|
+
self._state = test_suite_run.state
|
151
|
+
|
152
|
+
def _list_paginated_executions(
|
153
|
+
self, offset: int | None, limit: int | None
|
154
|
+
) -> PaginatedResults[TestSuiteRunExecution]:
|
155
|
+
response = self._client.test_suite_runs.list_executions(
|
156
|
+
self._test_suite_run_id,
|
157
|
+
offset=offset,
|
158
|
+
limit=limit,
|
159
|
+
expand=[
|
160
|
+
"results.metric_results.metric_definition",
|
161
|
+
"results.metric_results.metric_label",
|
162
|
+
],
|
163
|
+
)
|
164
|
+
return PaginatedResults(results=response.results, count=response.count)
|
165
|
+
|
166
|
+
def _wrap_api_executions(
|
167
|
+
self, executions: Generator[TestSuiteRunExecution, None, None]
|
168
|
+
) -> Generator[VellumTestSuiteRunExecution, None, None]:
|
169
|
+
for execution in executions:
|
170
|
+
yield VellumTestSuiteRunExecution.from_api(execution)
|
171
|
+
|
172
|
+
def _get_test_suite_run_executions(
|
173
|
+
self,
|
174
|
+
) -> Generator[VellumTestSuiteRunExecution, None, None]:
|
175
|
+
if self._executions is not None:
|
176
|
+
return self._executions
|
177
|
+
|
178
|
+
start_time = time.time_ns()
|
179
|
+
while True:
|
180
|
+
logger.debug("Polling for latest test suite run state...")
|
181
|
+
self._refresh_test_suite_run_state()
|
182
|
+
if self._state not in {"QUEUED", "RUNNING"}:
|
183
|
+
break
|
184
|
+
|
185
|
+
current_time = time.time_ns()
|
186
|
+
if ((current_time - start_time) / 1e6) > self._max_polling_duration:
|
187
|
+
raise TestSuiteRunResultsException(
|
188
|
+
"Test suite run timed out polling for executions"
|
189
|
+
)
|
190
|
+
|
191
|
+
time.sleep(self._polling_interval / 1000.0)
|
192
|
+
|
193
|
+
if self._state == "FAILED":
|
194
|
+
raise TestSuiteRunResultsException("Test suite run failed")
|
195
|
+
|
196
|
+
if self._state == "CANCELLED":
|
197
|
+
raise TestSuiteRunResultsException("Test suite run was cancelled")
|
198
|
+
|
199
|
+
raw_api_executions = get_all_results(self._list_paginated_executions)
|
200
|
+
self._executions = self._wrap_api_executions(raw_api_executions)
|
201
|
+
return self._executions
|
202
|
+
|
203
|
+
|
204
|
+
class VellumTestSuite:
|
205
|
+
"""A utility class that provides methods for running a Vellum Test Suite and interacting with its results."""
|
206
|
+
|
207
|
+
def __init__(
|
208
|
+
self,
|
209
|
+
test_suite_id: str,
|
210
|
+
*,
|
211
|
+
client: Vellum | None = None,
|
212
|
+
) -> None:
|
213
|
+
self.client = client or Vellum(
|
214
|
+
api_key=get_api_key(),
|
215
|
+
)
|
216
|
+
self._test_suite_id = test_suite_id
|
217
|
+
|
218
|
+
def run_external(
|
219
|
+
self,
|
220
|
+
executable: Callable[
|
221
|
+
[List[TestCaseVariableValue]], List[NamedTestCaseVariableValueRequest]
|
222
|
+
],
|
223
|
+
) -> VellumTestSuiteRunResults:
|
224
|
+
"""
|
225
|
+
Runs this Vellum Test Suite on any executable function defined external to Vellum.
|
226
|
+
|
227
|
+
Returns a wrapper that polls the generated Test Suite Run until it's done running and returns its results.
|
228
|
+
"""
|
229
|
+
test_cases = self.client.test_suites.list_test_suite_test_cases(
|
230
|
+
id=self._test_suite_id
|
231
|
+
)
|
232
|
+
executions: List[ExternalTestCaseExecutionRequest] = []
|
233
|
+
|
234
|
+
for test_case in test_cases.results:
|
235
|
+
outputs = executable(test_case.input_values)
|
236
|
+
|
237
|
+
executions.append(
|
238
|
+
ExternalTestCaseExecutionRequest(
|
239
|
+
test_case_id=test_case.id, # type: ignore[arg-type]
|
240
|
+
outputs=outputs,
|
241
|
+
)
|
242
|
+
)
|
243
|
+
|
244
|
+
test_suite_run = self.client.test_suite_runs.create(
|
245
|
+
test_suite_id=self._test_suite_id,
|
246
|
+
exec_config=TestSuiteRunExecConfigRequest_External(
|
247
|
+
type="EXTERNAL",
|
248
|
+
data=TestSuiteRunExternalExecConfigDataRequest(
|
249
|
+
executions=executions,
|
250
|
+
),
|
251
|
+
),
|
252
|
+
)
|
253
|
+
return VellumTestSuiteRunResults(test_suite_run.id, client=self.client)
|
File without changes
|
vellum/lib/utils/env.py
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from .exceptions import VellumClientException
|
4
|
+
|
5
|
+
|
6
|
+
def get_api_key() -> str:
|
7
|
+
api_key = os.environ.get("VELLUM_API_KEY")
|
8
|
+
if api_key is None:
|
9
|
+
raise VellumClientException("`VELLUM_API_KEY` environment variable id required to be set.")
|
10
|
+
|
11
|
+
return api_key
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from typing import Callable, Generator, Generic, List, TypeVar, Union
|
3
|
+
|
4
|
+
|
5
|
+
Result = TypeVar("Result")
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass
|
9
|
+
class PaginatedResults(Generic[Result]):
|
10
|
+
count: int
|
11
|
+
results: List[Result]
|
12
|
+
|
13
|
+
|
14
|
+
def get_all_results(
|
15
|
+
paginated_api: Callable[[int, Union[int, None]], PaginatedResults[Result]], page_size: Union[int, None] = None
|
16
|
+
) -> Generator[Result, None, None]:
|
17
|
+
offset = 0
|
18
|
+
count = 0
|
19
|
+
while True:
|
20
|
+
paginated_results = paginated_api(offset, page_size)
|
21
|
+
for result in paginated_results.results:
|
22
|
+
yield result
|
23
|
+
count += 1
|
24
|
+
|
25
|
+
if paginated_results.count <= count:
|
26
|
+
break
|
27
|
+
|
28
|
+
offset = count
|
vellum/resources/__init__.py
CHANGED
@@ -5,8 +5,6 @@ from . import (
|
|
5
5
|
document_indexes,
|
6
6
|
documents,
|
7
7
|
folder_entities,
|
8
|
-
model_versions,
|
9
|
-
registered_prompts,
|
10
8
|
sandboxes,
|
11
9
|
test_suite_runs,
|
12
10
|
test_suites,
|
@@ -24,8 +22,6 @@ __all__ = [
|
|
24
22
|
"document_indexes",
|
25
23
|
"documents",
|
26
24
|
"folder_entities",
|
27
|
-
"model_versions",
|
28
|
-
"registered_prompts",
|
29
25
|
"sandboxes",
|
30
26
|
"test_suite_runs",
|
31
27
|
"test_suites",
|
@@ -7,6 +7,7 @@ from json.decoder import JSONDecodeError
|
|
7
7
|
from ...core.api_error import ApiError
|
8
8
|
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ...core.jsonable_encoder import jsonable_encoder
|
10
|
+
from ...core.pydantic_utilities import pydantic_v1
|
10
11
|
from ...core.remove_none_from_dict import remove_none_from_dict
|
11
12
|
from ...core.request_options import RequestOptions
|
12
13
|
from ...errors.bad_request_error import BadRequestError
|
@@ -19,11 +20,6 @@ from ...types.paginated_slim_deployment_read_list import PaginatedSlimDeployment
|
|
19
20
|
from ...types.prompt_deployment_input_request import PromptDeploymentInputRequest
|
20
21
|
from .types.deployments_list_request_status import DeploymentsListRequestStatus
|
21
22
|
|
22
|
-
try:
|
23
|
-
import pydantic.v1 as pydantic # type: ignore
|
24
|
-
except ImportError:
|
25
|
-
import pydantic # type: ignore
|
26
|
-
|
27
23
|
# this is used as the default value for optional parameters
|
28
24
|
OMIT = typing.cast(typing.Any, ...)
|
29
25
|
|
@@ -61,8 +57,8 @@ class DeploymentsClient:
|
|
61
57
|
client.deployments.list()
|
62
58
|
"""
|
63
59
|
_response = self._client_wrapper.httpx_client.request(
|
64
|
-
"GET",
|
65
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_environment().default}/", "v1/deployments"),
|
60
|
+
method="GET",
|
61
|
+
url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().default}/", "v1/deployments"),
|
66
62
|
params=jsonable_encoder(
|
67
63
|
remove_none_from_dict(
|
68
64
|
{
|
@@ -93,7 +89,7 @@ class DeploymentsClient:
|
|
93
89
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
94
90
|
)
|
95
91
|
if 200 <= _response.status_code < 300:
|
96
|
-
return
|
92
|
+
return pydantic_v1.parse_obj_as(PaginatedSlimDeploymentReadList, _response.json()) # type: ignore
|
97
93
|
try:
|
98
94
|
_response_json = _response.json()
|
99
95
|
except JSONDecodeError:
|
@@ -119,8 +115,8 @@ class DeploymentsClient:
|
|
119
115
|
)
|
120
116
|
"""
|
121
117
|
_response = self._client_wrapper.httpx_client.request(
|
122
|
-
"GET",
|
123
|
-
urllib.parse.urljoin(
|
118
|
+
method="GET",
|
119
|
+
url=urllib.parse.urljoin(
|
124
120
|
f"{self._client_wrapper.get_environment().default}/", f"v1/deployments/{jsonable_encoder(id)}"
|
125
121
|
),
|
126
122
|
params=jsonable_encoder(
|
@@ -141,7 +137,7 @@ class DeploymentsClient:
|
|
141
137
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
142
138
|
)
|
143
139
|
if 200 <= _response.status_code < 300:
|
144
|
-
return
|
140
|
+
return pydantic_v1.parse_obj_as(DeploymentRead, _response.json()) # type: ignore
|
145
141
|
try:
|
146
142
|
_response_json = _response.json()
|
147
143
|
except JSONDecodeError:
|
@@ -186,8 +182,8 @@ class DeploymentsClient:
|
|
186
182
|
if release_tag is not OMIT:
|
187
183
|
_request["release_tag"] = release_tag
|
188
184
|
_response = self._client_wrapper.httpx_client.request(
|
189
|
-
"POST",
|
190
|
-
urllib.parse.urljoin(
|
185
|
+
method="POST",
|
186
|
+
url=urllib.parse.urljoin(
|
191
187
|
f"{self._client_wrapper.get_environment().default}/", "v1/deployments/provider-payload"
|
192
188
|
),
|
193
189
|
params=jsonable_encoder(
|
@@ -214,15 +210,15 @@ class DeploymentsClient:
|
|
214
210
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
215
211
|
)
|
216
212
|
if 200 <= _response.status_code < 300:
|
217
|
-
return
|
213
|
+
return pydantic_v1.parse_obj_as(DeploymentProviderPayloadResponse, _response.json()) # type: ignore
|
218
214
|
if _response.status_code == 400:
|
219
|
-
raise BadRequestError(
|
215
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
220
216
|
if _response.status_code == 403:
|
221
|
-
raise ForbiddenError(
|
217
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
222
218
|
if _response.status_code == 404:
|
223
|
-
raise NotFoundError(
|
219
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
224
220
|
if _response.status_code == 500:
|
225
|
-
raise InternalServerError(
|
221
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
226
222
|
try:
|
227
223
|
_response_json = _response.json()
|
228
224
|
except JSONDecodeError:
|
@@ -263,8 +259,8 @@ class AsyncDeploymentsClient:
|
|
263
259
|
await client.deployments.list()
|
264
260
|
"""
|
265
261
|
_response = await self._client_wrapper.httpx_client.request(
|
266
|
-
"GET",
|
267
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_environment().default}/", "v1/deployments"),
|
262
|
+
method="GET",
|
263
|
+
url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().default}/", "v1/deployments"),
|
268
264
|
params=jsonable_encoder(
|
269
265
|
remove_none_from_dict(
|
270
266
|
{
|
@@ -295,7 +291,7 @@ class AsyncDeploymentsClient:
|
|
295
291
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
296
292
|
)
|
297
293
|
if 200 <= _response.status_code < 300:
|
298
|
-
return
|
294
|
+
return pydantic_v1.parse_obj_as(PaginatedSlimDeploymentReadList, _response.json()) # type: ignore
|
299
295
|
try:
|
300
296
|
_response_json = _response.json()
|
301
297
|
except JSONDecodeError:
|
@@ -321,8 +317,8 @@ class AsyncDeploymentsClient:
|
|
321
317
|
)
|
322
318
|
"""
|
323
319
|
_response = await self._client_wrapper.httpx_client.request(
|
324
|
-
"GET",
|
325
|
-
urllib.parse.urljoin(
|
320
|
+
method="GET",
|
321
|
+
url=urllib.parse.urljoin(
|
326
322
|
f"{self._client_wrapper.get_environment().default}/", f"v1/deployments/{jsonable_encoder(id)}"
|
327
323
|
),
|
328
324
|
params=jsonable_encoder(
|
@@ -343,7 +339,7 @@ class AsyncDeploymentsClient:
|
|
343
339
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
344
340
|
)
|
345
341
|
if 200 <= _response.status_code < 300:
|
346
|
-
return
|
342
|
+
return pydantic_v1.parse_obj_as(DeploymentRead, _response.json()) # type: ignore
|
347
343
|
try:
|
348
344
|
_response_json = _response.json()
|
349
345
|
except JSONDecodeError:
|
@@ -388,8 +384,8 @@ class AsyncDeploymentsClient:
|
|
388
384
|
if release_tag is not OMIT:
|
389
385
|
_request["release_tag"] = release_tag
|
390
386
|
_response = await self._client_wrapper.httpx_client.request(
|
391
|
-
"POST",
|
392
|
-
urllib.parse.urljoin(
|
387
|
+
method="POST",
|
388
|
+
url=urllib.parse.urljoin(
|
393
389
|
f"{self._client_wrapper.get_environment().default}/", "v1/deployments/provider-payload"
|
394
390
|
),
|
395
391
|
params=jsonable_encoder(
|
@@ -416,15 +412,15 @@ class AsyncDeploymentsClient:
|
|
416
412
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
417
413
|
)
|
418
414
|
if 200 <= _response.status_code < 300:
|
419
|
-
return
|
415
|
+
return pydantic_v1.parse_obj_as(DeploymentProviderPayloadResponse, _response.json()) # type: ignore
|
420
416
|
if _response.status_code == 400:
|
421
|
-
raise BadRequestError(
|
417
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
422
418
|
if _response.status_code == 403:
|
423
|
-
raise ForbiddenError(
|
419
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
424
420
|
if _response.status_code == 404:
|
425
|
-
raise NotFoundError(
|
421
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
426
422
|
if _response.status_code == 500:
|
427
|
-
raise InternalServerError(
|
423
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
428
424
|
try:
|
429
425
|
_response_json = _response.json()
|
430
426
|
except JSONDecodeError:
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
import enum
|
4
3
|
import typing
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
class DeploymentsListRequestStatus(str, enum.Enum):
|
10
|
-
ACTIVE = "ACTIVE"
|
11
|
-
ARCHIVED = "ARCHIVED"
|
12
|
-
|
13
|
-
def visit(self, active: typing.Callable[[], T_Result], archived: typing.Callable[[], T_Result]) -> T_Result:
|
14
|
-
if self is DeploymentsListRequestStatus.ACTIVE:
|
15
|
-
return active()
|
16
|
-
if self is DeploymentsListRequestStatus.ARCHIVED:
|
17
|
-
return archived()
|
5
|
+
DeploymentsListRequestStatus = typing.Union[typing.Literal["ACTIVE", "ARCHIVED"], typing.Any]
|