vellum-ai 0.7.11__py3-none-any.whl → 0.8.4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/__init__.py +7 -474
- vellum/client.py +751 -246
- vellum/core/__init__.py +19 -3
- vellum/core/client_wrapper.py +6 -7
- vellum/core/file.py +7 -2
- vellum/core/http_client.py +4 -2
- vellum/core/jsonable_encoder.py +30 -31
- vellum/core/pydantic_utilities.py +190 -12
- vellum/core/query_encoder.py +38 -13
- vellum/core/serialization.py +170 -0
- vellum/errors/bad_request_error.py +2 -3
- vellum/errors/forbidden_error.py +2 -3
- vellum/errors/internal_server_error.py +2 -3
- vellum/errors/not_found_error.py +2 -3
- vellum/lib/test_suites/resources.py +4 -4
- vellum/resources/deployments/client.py +194 -46
- vellum/resources/document_indexes/client.py +174 -76
- vellum/resources/documents/client.py +162 -44
- vellum/resources/folder_entities/client.py +12 -8
- vellum/resources/ml_models/client.py +99 -33
- vellum/resources/sandboxes/client.py +70 -20
- vellum/resources/test_suite_runs/client.py +80 -34
- vellum/resources/test_suites/client.py +95 -37
- vellum/resources/workflow_deployments/client.py +89 -27
- vellum/resources/workflow_sandboxes/client.py +22 -10
- vellum/types/__init__.py +48 -595
- vellum/types/api_node_result.py +12 -21
- vellum/types/api_node_result_data.py +12 -24
- vellum/types/array_chat_message_content.py +12 -21
- vellum/types/array_chat_message_content_item.py +4 -79
- vellum/types/array_chat_message_content_item_request.py +4 -81
- vellum/types/array_chat_message_content_request.py +12 -21
- vellum/types/array_variable_value_item.py +12 -154
- vellum/types/array_vellum_value_item.py +7 -154
- vellum/types/array_vellum_value_item_request.py +12 -154
- vellum/types/basic_vectorizer_intfloat_multilingual_e_5_large.py +13 -22
- vellum/types/basic_vectorizer_intfloat_multilingual_e_5_large_request.py +13 -22
- vellum/types/basic_vectorizer_sentence_transformers_multi_qa_mpnet_base_cos_v_1.py +15 -22
- vellum/types/basic_vectorizer_sentence_transformers_multi_qa_mpnet_base_cos_v_1_request.py +15 -22
- vellum/types/basic_vectorizer_sentence_transformers_multi_qa_mpnet_base_dot_v_1.py +15 -22
- vellum/types/basic_vectorizer_sentence_transformers_multi_qa_mpnet_base_dot_v_1_request.py +15 -22
- vellum/types/chat_history_input_request.py +13 -22
- vellum/types/chat_message.py +13 -23
- vellum/types/chat_message_content.py +5 -103
- vellum/types/chat_message_content_request.py +8 -106
- vellum/types/chat_message_request.py +13 -23
- vellum/types/code_execution_node_array_result.py +12 -21
- vellum/types/code_execution_node_chat_history_result.py +12 -21
- vellum/types/code_execution_node_error_result.py +12 -21
- vellum/types/code_execution_node_function_call_result.py +12 -21
- vellum/types/code_execution_node_json_result.py +13 -22
- vellum/types/code_execution_node_number_result.py +12 -21
- vellum/types/code_execution_node_result.py +12 -21
- vellum/types/code_execution_node_result_data.py +12 -22
- vellum/types/code_execution_node_result_output.py +16 -212
- vellum/types/code_execution_node_search_results_result.py +12 -21
- vellum/types/code_execution_node_string_result.py +12 -21
- vellum/types/compile_prompt_deployment_expand_meta_request.py +14 -24
- vellum/types/compile_prompt_meta.py +11 -21
- vellum/types/components_schemas_pdf_search_result_meta_source.py +5 -0
- vellum/types/components_schemas_pdf_search_result_meta_source_request.py +5 -0
- vellum/types/conditional_node_result.py +12 -21
- vellum/types/conditional_node_result_data.py +11 -21
- vellum/types/create_test_suite_test_case_request.py +15 -25
- vellum/types/deployment_provider_payload_response.py +12 -22
- vellum/types/deployment_provider_payload_response_payload.py +1 -1
- vellum/types/deployment_read.py +18 -27
- vellum/types/deployment_release_tag_deployment_history_item.py +11 -20
- vellum/types/deployment_release_tag_read.py +16 -26
- vellum/types/document_document_to_document_index.py +14 -24
- vellum/types/document_index_chunking.py +4 -84
- vellum/types/document_index_chunking_request.py +4 -82
- vellum/types/document_index_indexing_config.py +12 -22
- vellum/types/document_index_indexing_config_request.py +12 -22
- vellum/types/document_index_read.py +16 -25
- vellum/types/document_read.py +19 -28
- vellum/types/enriched_normalized_completion.py +17 -27
- vellum/types/error_variable_value.py +12 -21
- vellum/types/error_vellum_value.py +12 -21
- vellum/types/error_vellum_value_request.py +12 -21
- vellum/types/execute_prompt_event.py +5 -118
- vellum/types/execute_prompt_response.py +3 -63
- vellum/types/execute_workflow_response.py +11 -21
- vellum/types/execute_workflow_workflow_result_event.py +3 -60
- vellum/types/execution_array_vellum_value.py +13 -22
- vellum/types/execution_chat_history_vellum_value.py +13 -22
- vellum/types/execution_error_vellum_value.py +13 -22
- vellum/types/execution_function_call_vellum_value.py +13 -22
- vellum/types/execution_json_vellum_value.py +14 -23
- vellum/types/execution_number_vellum_value.py +13 -22
- vellum/types/execution_search_results_vellum_value.py +13 -22
- vellum/types/execution_string_vellum_value.py +13 -22
- vellum/types/execution_vellum_value.py +16 -220
- vellum/types/external_test_case_execution.py +12 -22
- vellum/types/external_test_case_execution_request.py +12 -22
- vellum/types/fulfilled_execute_prompt_event.py +13 -22
- vellum/types/fulfilled_execute_prompt_response.py +14 -23
- vellum/types/fulfilled_execute_workflow_workflow_result_event.py +13 -21
- vellum/types/fulfilled_prompt_execution_meta.py +11 -21
- vellum/types/fulfilled_workflow_node_result_event.py +14 -22
- vellum/types/function_call.py +12 -22
- vellum/types/function_call_chat_message_content.py +12 -21
- vellum/types/function_call_chat_message_content_request.py +12 -21
- vellum/types/function_call_chat_message_content_value.py +12 -22
- vellum/types/function_call_chat_message_content_value_request.py +12 -22
- vellum/types/function_call_request.py +12 -22
- vellum/types/function_call_variable_value.py +12 -21
- vellum/types/function_call_vellum_value.py +12 -21
- vellum/types/function_call_vellum_value_request.py +12 -21
- vellum/types/generate_options_request.py +12 -22
- vellum/types/generate_request.py +14 -24
- vellum/types/generate_result.py +13 -23
- vellum/types/generate_result_data.py +12 -22
- vellum/types/generate_result_error.py +12 -22
- vellum/types/generate_stream_response.py +12 -22
- vellum/types/generate_stream_result.py +12 -22
- vellum/types/generate_stream_result_data.py +12 -22
- vellum/types/hkunlp_instructor_xl_vectorizer.py +12 -21
- vellum/types/hkunlp_instructor_xl_vectorizer_request.py +12 -21
- vellum/types/hugging_face_tokenizer_config.py +12 -21
- vellum/types/hugging_face_tokenizer_config_request.py +12 -21
- vellum/types/image_chat_message_content.py +12 -21
- vellum/types/image_chat_message_content_request.py +12 -21
- vellum/types/image_variable_value.py +12 -21
- vellum/types/image_vellum_value.py +12 -21
- vellum/types/image_vellum_value_request.py +12 -21
- vellum/types/indexing_config_vectorizer.py +18 -181
- vellum/types/indexing_config_vectorizer_request.py +18 -181
- vellum/types/initiated_execute_prompt_event.py +12 -21
- vellum/types/initiated_prompt_execution_meta.py +11 -21
- vellum/types/initiated_workflow_node_result_event.py +14 -22
- vellum/types/instructor_vectorizer_config.py +11 -21
- vellum/types/instructor_vectorizer_config_request.py +11 -21
- vellum/types/json_input_request.py +14 -23
- vellum/types/json_variable_value.py +13 -22
- vellum/types/json_vellum_value.py +13 -22
- vellum/types/json_vellum_value_request.py +13 -22
- vellum/types/map_node_result.py +12 -21
- vellum/types/map_node_result_data.py +11 -21
- vellum/types/merge_node_result.py +12 -21
- vellum/types/merge_node_result_data.py +12 -22
- vellum/types/metadata_filter_config_request.py +12 -22
- vellum/types/metadata_filter_rule_request.py +15 -25
- vellum/types/metric_node_result.py +12 -20
- vellum/types/ml_model_developer_enum_value_label.py +12 -22
- vellum/types/ml_model_display_config_labelled.py +12 -22
- vellum/types/ml_model_display_config_request.py +12 -22
- vellum/types/ml_model_display_tag_enum_value_label.py +12 -22
- vellum/types/ml_model_exec_config.py +14 -24
- vellum/types/ml_model_exec_config_request.py +14 -24
- vellum/types/ml_model_family_enum_value_label.py +12 -22
- vellum/types/ml_model_parameter_config.py +13 -23
- vellum/types/ml_model_parameter_config_request.py +13 -23
- vellum/types/ml_model_read.py +23 -33
- vellum/types/ml_model_request_authorization_config.py +12 -22
- vellum/types/ml_model_request_authorization_config_request.py +12 -22
- vellum/types/ml_model_request_config.py +11 -21
- vellum/types/ml_model_request_config_request.py +11 -21
- vellum/types/ml_model_response_config.py +11 -21
- vellum/types/ml_model_response_config_request.py +11 -21
- vellum/types/ml_model_tokenizer_config.py +3 -55
- vellum/types/ml_model_tokenizer_config_request.py +3 -57
- vellum/types/ml_model_usage.py +11 -21
- vellum/types/named_scenario_input_chat_history_variable_value_request.py +12 -21
- vellum/types/named_scenario_input_json_variable_value_request.py +13 -22
- vellum/types/named_scenario_input_request.py +6 -81
- vellum/types/named_scenario_input_string_variable_value_request.py +12 -21
- vellum/types/named_test_case_array_variable_value.py +12 -21
- vellum/types/named_test_case_array_variable_value_request.py +12 -21
- vellum/types/named_test_case_chat_history_variable_value.py +12 -21
- vellum/types/named_test_case_chat_history_variable_value_request.py +12 -21
- vellum/types/named_test_case_error_variable_value.py +12 -21
- vellum/types/named_test_case_error_variable_value_request.py +12 -21
- vellum/types/named_test_case_function_call_variable_value.py +12 -21
- vellum/types/named_test_case_function_call_variable_value_request.py +12 -21
- vellum/types/named_test_case_json_variable_value.py +13 -22
- vellum/types/named_test_case_json_variable_value_request.py +13 -22
- vellum/types/named_test_case_number_variable_value.py +12 -21
- vellum/types/named_test_case_number_variable_value_request.py +12 -21
- vellum/types/named_test_case_search_results_variable_value.py +12 -21
- vellum/types/named_test_case_search_results_variable_value_request.py +12 -21
- vellum/types/named_test_case_string_variable_value.py +12 -21
- vellum/types/named_test_case_string_variable_value_request.py +12 -21
- vellum/types/named_test_case_variable_value.py +16 -212
- vellum/types/named_test_case_variable_value_request.py +16 -212
- vellum/types/node_input_compiled_array_value.py +12 -21
- vellum/types/node_input_compiled_chat_history_value.py +12 -21
- vellum/types/node_input_compiled_error_value.py +12 -21
- vellum/types/node_input_compiled_function_call.py +12 -21
- vellum/types/node_input_compiled_json_value.py +13 -22
- vellum/types/node_input_compiled_number_value.py +12 -21
- vellum/types/node_input_compiled_search_results_value.py +12 -21
- vellum/types/node_input_compiled_string_value.py +12 -21
- vellum/types/node_input_variable_compiled_value.py +16 -220
- vellum/types/node_output_compiled_array_value.py +12 -21
- vellum/types/node_output_compiled_chat_history_value.py +12 -21
- vellum/types/node_output_compiled_error_value.py +12 -21
- vellum/types/node_output_compiled_function_call_value.py +12 -21
- vellum/types/node_output_compiled_json_value.py +13 -22
- vellum/types/node_output_compiled_number_value.py +12 -21
- vellum/types/node_output_compiled_search_results_value.py +12 -21
- vellum/types/node_output_compiled_string_value.py +12 -21
- vellum/types/node_output_compiled_value.py +16 -221
- vellum/types/normalized_log_probs.py +11 -21
- vellum/types/normalized_token_log_probs.py +11 -21
- vellum/types/number_variable_value.py +12 -21
- vellum/types/number_vellum_value.py +12 -21
- vellum/types/number_vellum_value_request.py +12 -21
- vellum/types/open_ai_vectorizer_config.py +11 -21
- vellum/types/open_ai_vectorizer_config_request.py +11 -21
- vellum/types/open_ai_vectorizer_text_embedding_3_large.py +13 -22
- vellum/types/open_ai_vectorizer_text_embedding_3_large_request.py +13 -22
- vellum/types/open_ai_vectorizer_text_embedding_3_small.py +13 -22
- vellum/types/open_ai_vectorizer_text_embedding_3_small_request.py +13 -22
- vellum/types/open_ai_vectorizer_text_embedding_ada_002.py +13 -22
- vellum/types/open_ai_vectorizer_text_embedding_ada_002_request.py +13 -22
- vellum/types/open_api_array_property.py +18 -27
- vellum/types/open_api_array_property_request.py +18 -27
- vellum/types/open_api_boolean_property.py +12 -21
- vellum/types/open_api_boolean_property_request.py +12 -21
- vellum/types/open_api_const_property.py +12 -21
- vellum/types/open_api_const_property_request.py +12 -21
- vellum/types/open_api_integer_property.py +12 -21
- vellum/types/open_api_integer_property_request.py +12 -21
- vellum/types/open_api_number_property.py +12 -21
- vellum/types/open_api_number_property_request.py +12 -21
- vellum/types/open_api_object_property.py +19 -28
- vellum/types/open_api_object_property_request.py +19 -28
- vellum/types/open_api_one_of_property.py +15 -26
- vellum/types/open_api_one_of_property_request.py +15 -26
- vellum/types/open_api_property.py +20 -270
- vellum/types/open_api_property_request.py +20 -270
- vellum/types/open_api_ref_property.py +12 -21
- vellum/types/open_api_ref_property_request.py +12 -21
- vellum/types/open_api_string_property.py +12 -21
- vellum/types/open_api_string_property_request.py +12 -21
- vellum/types/paginated_document_index_read_list.py +11 -21
- vellum/types/paginated_ml_model_read_list.py +11 -21
- vellum/types/paginated_slim_deployment_read_list.py +11 -21
- vellum/types/paginated_slim_document_list.py +11 -21
- vellum/types/paginated_slim_workflow_deployment_list.py +11 -21
- vellum/types/paginated_test_suite_run_execution_list.py +11 -21
- vellum/types/paginated_test_suite_test_case_list.py +11 -21
- vellum/types/pdf_search_result_meta_source.py +14 -23
- vellum/types/pdf_search_result_meta_source_request.py +14 -23
- vellum/types/prompt_deployment_expand_meta_request_request.py +17 -27
- vellum/types/prompt_deployment_input_request.py +4 -83
- vellum/types/prompt_execution_meta.py +11 -21
- vellum/types/prompt_node_execution_meta.py +11 -21
- vellum/types/prompt_node_result.py +12 -21
- vellum/types/prompt_node_result_data.py +11 -21
- vellum/types/prompt_output.py +5 -102
- vellum/types/raw_prompt_execution_overrides_request.py +14 -24
- vellum/types/reducto_chunker_config.py +11 -21
- vellum/types/reducto_chunker_config_request.py +11 -21
- vellum/types/reducto_chunking.py +12 -21
- vellum/types/reducto_chunking_request.py +12 -21
- vellum/types/rejected_execute_prompt_event.py +13 -22
- vellum/types/rejected_execute_prompt_response.py +14 -23
- vellum/types/rejected_execute_workflow_workflow_result_event.py +13 -21
- vellum/types/rejected_prompt_execution_meta.py +11 -21
- vellum/types/rejected_workflow_node_result_event.py +14 -22
- vellum/types/replace_test_suite_test_case_request.py +16 -26
- vellum/types/sandbox_scenario.py +13 -23
- vellum/types/scenario_input.py +6 -81
- vellum/types/scenario_input_chat_history_variable_value.py +12 -21
- vellum/types/scenario_input_json_variable_value.py +13 -22
- vellum/types/scenario_input_string_variable_value.py +12 -21
- vellum/types/search_filters_request.py +13 -23
- vellum/types/search_node_result.py +12 -21
- vellum/types/search_node_result_data.py +12 -22
- vellum/types/search_request_options_request.py +17 -27
- vellum/types/search_response.py +12 -22
- vellum/types/search_result.py +15 -25
- vellum/types/search_result_document.py +15 -25
- vellum/types/search_result_document_request.py +15 -25
- vellum/types/search_result_merging_request.py +12 -22
- vellum/types/search_result_meta.py +13 -23
- vellum/types/search_result_meta_request.py +13 -23
- vellum/types/search_result_request.py +15 -25
- vellum/types/search_weights_request.py +13 -23
- vellum/types/sentence_chunker_config.py +11 -21
- vellum/types/sentence_chunker_config_request.py +11 -21
- vellum/types/sentence_chunking.py +12 -21
- vellum/types/sentence_chunking_request.py +12 -21
- vellum/types/slim_deployment_read.py +16 -25
- vellum/types/slim_document.py +24 -33
- vellum/types/slim_workflow_deployment.py +19 -28
- vellum/types/streaming_execute_prompt_event.py +13 -22
- vellum/types/streaming_prompt_execution_meta.py +11 -21
- vellum/types/streaming_workflow_node_result_event.py +14 -22
- vellum/types/string_chat_message_content.py +12 -21
- vellum/types/string_chat_message_content_request.py +12 -21
- vellum/types/string_input_request.py +13 -22
- vellum/types/string_variable_value.py +12 -21
- vellum/types/string_vellum_value.py +12 -21
- vellum/types/string_vellum_value_request.py +12 -21
- vellum/types/submit_completion_actual_request.py +18 -27
- vellum/types/submit_workflow_execution_actual_request.py +4 -95
- vellum/types/subworkflow_node_result.py +12 -21
- vellum/types/subworkflow_node_result_data.py +11 -21
- vellum/types/templating_node_array_result.py +12 -21
- vellum/types/templating_node_chat_history_result.py +12 -21
- vellum/types/templating_node_error_result.py +12 -21
- vellum/types/templating_node_function_call_result.py +12 -21
- vellum/types/templating_node_json_result.py +13 -22
- vellum/types/templating_node_number_result.py +12 -21
- vellum/types/templating_node_result.py +12 -21
- vellum/types/templating_node_result_data.py +12 -22
- vellum/types/templating_node_result_output.py +16 -212
- vellum/types/templating_node_search_results_result.py +12 -21
- vellum/types/templating_node_string_result.py +12 -21
- vellum/types/terminal_node_array_result.py +13 -22
- vellum/types/terminal_node_chat_history_result.py +13 -22
- vellum/types/terminal_node_error_result.py +13 -22
- vellum/types/terminal_node_function_call_result.py +13 -22
- vellum/types/terminal_node_json_result.py +14 -23
- vellum/types/terminal_node_number_result.py +13 -22
- vellum/types/terminal_node_result.py +12 -21
- vellum/types/terminal_node_result_data.py +12 -22
- vellum/types/terminal_node_result_output.py +16 -220
- vellum/types/terminal_node_search_results_result.py +13 -22
- vellum/types/terminal_node_string_result.py +13 -22
- vellum/types/test_case_array_variable_value.py +12 -21
- vellum/types/test_case_chat_history_variable_value.py +12 -21
- vellum/types/test_case_error_variable_value.py +12 -21
- vellum/types/test_case_function_call_variable_value.py +12 -21
- vellum/types/test_case_json_variable_value.py +13 -22
- vellum/types/test_case_number_variable_value.py +12 -21
- vellum/types/test_case_search_results_variable_value.py +12 -21
- vellum/types/test_case_string_variable_value.py +12 -21
- vellum/types/test_case_variable_value.py +16 -220
- vellum/types/test_suite_run_deployment_release_tag_exec_config.py +13 -22
- vellum/types/test_suite_run_deployment_release_tag_exec_config_data.py +13 -23
- vellum/types/test_suite_run_deployment_release_tag_exec_config_data_request.py +13 -23
- vellum/types/test_suite_run_deployment_release_tag_exec_config_request.py +13 -22
- vellum/types/test_suite_run_exec_config.py +4 -85
- vellum/types/test_suite_run_exec_config_request.py +6 -89
- vellum/types/test_suite_run_execution.py +12 -22
- vellum/types/test_suite_run_execution_array_output.py +12 -21
- vellum/types/test_suite_run_execution_chat_history_output.py +12 -21
- vellum/types/test_suite_run_execution_error_output.py +12 -21
- vellum/types/test_suite_run_execution_function_call_output.py +12 -21
- vellum/types/test_suite_run_execution_json_output.py +13 -22
- vellum/types/test_suite_run_execution_metric_definition.py +11 -21
- vellum/types/test_suite_run_execution_metric_result.py +12 -22
- vellum/types/test_suite_run_execution_number_output.py +12 -21
- vellum/types/test_suite_run_execution_output.py +16 -220
- vellum/types/test_suite_run_execution_search_results_output.py +12 -21
- vellum/types/test_suite_run_execution_string_output.py +12 -21
- vellum/types/test_suite_run_external_exec_config.py +14 -22
- vellum/types/test_suite_run_external_exec_config_data.py +12 -22
- vellum/types/test_suite_run_external_exec_config_data_request.py +12 -22
- vellum/types/test_suite_run_external_exec_config_request.py +14 -22
- vellum/types/test_suite_run_metric_error_output.py +13 -22
- vellum/types/test_suite_run_metric_number_output.py +12 -21
- vellum/types/test_suite_run_metric_output.py +4 -81
- vellum/types/test_suite_run_metric_string_output.py +12 -21
- vellum/types/test_suite_run_read.py +15 -24
- vellum/types/test_suite_run_test_suite.py +11 -21
- vellum/types/test_suite_run_workflow_release_tag_exec_config.py +13 -22
- vellum/types/test_suite_run_workflow_release_tag_exec_config_data.py +13 -23
- vellum/types/test_suite_run_workflow_release_tag_exec_config_data_request.py +13 -23
- vellum/types/test_suite_run_workflow_release_tag_exec_config_request.py +13 -22
- vellum/types/test_suite_test_case.py +11 -21
- vellum/types/test_suite_test_case_bulk_operation_request.py +8 -111
- vellum/types/test_suite_test_case_bulk_result.py +8 -110
- vellum/types/test_suite_test_case_create_bulk_operation_request.py +13 -22
- vellum/types/test_suite_test_case_created_bulk_result.py +12 -21
- vellum/types/test_suite_test_case_created_bulk_result_data.py +11 -21
- vellum/types/test_suite_test_case_delete_bulk_operation_data_request.py +11 -21
- vellum/types/test_suite_test_case_delete_bulk_operation_request.py +14 -23
- vellum/types/test_suite_test_case_deleted_bulk_result.py +13 -22
- vellum/types/test_suite_test_case_deleted_bulk_result_data.py +11 -21
- vellum/types/test_suite_test_case_rejected_bulk_result.py +14 -23
- vellum/types/test_suite_test_case_replace_bulk_operation_request.py +13 -22
- vellum/types/test_suite_test_case_replaced_bulk_result.py +13 -22
- vellum/types/test_suite_test_case_replaced_bulk_result_data.py +11 -21
- vellum/types/test_suite_test_case_upsert_bulk_operation_request.py +13 -22
- vellum/types/tik_token_tokenizer_config.py +12 -21
- vellum/types/tik_token_tokenizer_config_request.py +12 -21
- vellum/types/token_overlapping_window_chunker_config.py +11 -21
- vellum/types/token_overlapping_window_chunker_config_request.py +11 -21
- vellum/types/token_overlapping_window_chunking.py +12 -21
- vellum/types/token_overlapping_window_chunking_request.py +12 -21
- vellum/types/upload_document_response.py +12 -22
- vellum/types/upsert_test_suite_test_case_request.py +16 -26
- vellum/types/vellum_error.py +12 -22
- vellum/types/vellum_error_request.py +12 -22
- vellum/types/vellum_image.py +12 -22
- vellum/types/vellum_image_request.py +12 -22
- vellum/types/vellum_variable.py +12 -22
- vellum/types/workflow_deployment_read.py +20 -29
- vellum/types/workflow_event_error.py +12 -22
- vellum/types/workflow_execution_actual_chat_history_request.py +18 -27
- vellum/types/workflow_execution_actual_json_request.py +18 -27
- vellum/types/workflow_execution_actual_string_request.py +18 -27
- vellum/types/workflow_execution_node_result_event.py +12 -21
- vellum/types/workflow_execution_workflow_result_event.py +12 -21
- vellum/types/workflow_expand_meta_request.py +12 -22
- vellum/types/workflow_node_result_data.py +22 -280
- vellum/types/workflow_node_result_event.py +8 -133
- vellum/types/workflow_output.py +18 -247
- vellum/types/workflow_output_array.py +13 -22
- vellum/types/workflow_output_chat_history.py +13 -22
- vellum/types/workflow_output_error.py +13 -22
- vellum/types/workflow_output_function_call.py +13 -22
- vellum/types/workflow_output_image.py +13 -22
- vellum/types/workflow_output_json.py +14 -23
- vellum/types/workflow_output_number.py +13 -22
- vellum/types/workflow_output_search_results.py +13 -22
- vellum/types/workflow_output_string.py +13 -22
- vellum/types/workflow_release_tag_read.py +15 -25
- vellum/types/workflow_release_tag_workflow_deployment_history_item.py +13 -22
- vellum/types/workflow_request_chat_history_input_request.py +13 -22
- vellum/types/workflow_request_input_request.py +8 -108
- vellum/types/workflow_request_json_input_request.py +14 -23
- vellum/types/workflow_request_number_input_request.py +13 -22
- vellum/types/workflow_request_string_input_request.py +13 -22
- vellum/types/workflow_result_event.py +14 -23
- vellum/types/workflow_result_event_output_data.py +16 -245
- vellum/types/workflow_result_event_output_data_array.py +14 -23
- vellum/types/workflow_result_event_output_data_chat_history.py +14 -23
- vellum/types/workflow_result_event_output_data_error.py +14 -23
- vellum/types/workflow_result_event_output_data_function_call.py +14 -23
- vellum/types/workflow_result_event_output_data_json.py +14 -23
- vellum/types/workflow_result_event_output_data_number.py +13 -22
- vellum/types/workflow_result_event_output_data_search_results.py +14 -23
- vellum/types/workflow_result_event_output_data_string.py +14 -23
- vellum/types/workflow_stream_event.py +3 -62
- vellum/version.py +0 -1
- {vellum_ai-0.7.11.dist-info → vellum_ai-0.8.4.dist-info}/METADATA +5 -4
- vellum_ai-0.8.4.dist-info/RECORD +507 -0
- vellum/types/search_result_meta_source.py +0 -36
- vellum/types/search_result_meta_source_request.py +0 -36
- vellum_ai-0.7.11.dist-info/RECORD +0 -506
- {vellum_ai-0.7.11.dist-info → vellum_ai-0.8.4.dist-info}/LICENSE +0 -0
- {vellum_ai-0.7.11.dist-info → vellum_ai-0.8.4.dist-info}/WHEEL +0 -0
vellum/core/__init__.py
CHANGED
@@ -6,25 +6,41 @@ 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
|
9
|
+
from .pydantic_utilities import (
|
10
|
+
IS_PYDANTIC_V2,
|
11
|
+
UniversalBaseModel,
|
12
|
+
UniversalRootModel,
|
13
|
+
parse_obj_as,
|
14
|
+
universal_field_validator,
|
15
|
+
universal_root_validator,
|
16
|
+
update_forward_refs,
|
17
|
+
)
|
10
18
|
from .query_encoder import encode_query
|
11
19
|
from .remove_none_from_dict import remove_none_from_dict
|
12
20
|
from .request_options import RequestOptions
|
21
|
+
from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
|
13
22
|
|
14
23
|
__all__ = [
|
15
24
|
"ApiError",
|
16
25
|
"AsyncClientWrapper",
|
17
26
|
"AsyncHttpClient",
|
18
27
|
"BaseClientWrapper",
|
28
|
+
"FieldMetadata",
|
19
29
|
"File",
|
20
30
|
"HttpClient",
|
31
|
+
"IS_PYDANTIC_V2",
|
21
32
|
"RequestOptions",
|
22
33
|
"SyncClientWrapper",
|
34
|
+
"UniversalBaseModel",
|
35
|
+
"UniversalRootModel",
|
36
|
+
"convert_and_respect_annotation_metadata",
|
23
37
|
"convert_file_dict_to_httpx_tuples",
|
24
|
-
"deep_union_pydantic_dicts",
|
25
38
|
"encode_query",
|
26
39
|
"jsonable_encoder",
|
27
|
-
"
|
40
|
+
"parse_obj_as",
|
28
41
|
"remove_none_from_dict",
|
29
42
|
"serialize_datetime",
|
43
|
+
"universal_field_validator",
|
44
|
+
"universal_root_validator",
|
45
|
+
"update_forward_refs",
|
30
46
|
]
|
vellum/core/client_wrapper.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
+
from ..environment import VellumEnvironment
|
3
4
|
import typing
|
4
|
-
|
5
5
|
import httpx
|
6
|
-
|
7
|
-
from
|
8
|
-
from .http_client import AsyncHttpClient, HttpClient
|
6
|
+
from .http_client import HttpClient
|
7
|
+
from .http_client import AsyncHttpClient
|
9
8
|
|
10
9
|
|
11
10
|
class BaseClientWrapper:
|
@@ -18,7 +17,7 @@ class BaseClientWrapper:
|
|
18
17
|
headers: typing.Dict[str, str] = {
|
19
18
|
"X-Fern-Language": "Python",
|
20
19
|
"X-Fern-SDK-Name": "vellum-ai",
|
21
|
-
"X-Fern-SDK-Version": "0.
|
20
|
+
"X-Fern-SDK-Version": "0.8.4",
|
22
21
|
}
|
23
22
|
headers["X_API_KEY"] = self.api_key
|
24
23
|
return headers
|
@@ -37,7 +36,7 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
37
36
|
api_key: str,
|
38
37
|
environment: VellumEnvironment,
|
39
38
|
timeout: typing.Optional[float] = None,
|
40
|
-
httpx_client: httpx.Client
|
39
|
+
httpx_client: httpx.Client,
|
41
40
|
):
|
42
41
|
super().__init__(api_key=api_key, environment=environment, timeout=timeout)
|
43
42
|
self.httpx_client = HttpClient(
|
@@ -52,7 +51,7 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
52
51
|
api_key: str,
|
53
52
|
environment: VellumEnvironment,
|
54
53
|
timeout: typing.Optional[float] = None,
|
55
|
-
httpx_client: httpx.AsyncClient
|
54
|
+
httpx_client: httpx.AsyncClient,
|
56
55
|
):
|
57
56
|
super().__init__(api_key=api_key, environment=environment, timeout=timeout)
|
58
57
|
self.httpx_client = AsyncHttpClient(
|
vellum/core/file.py
CHANGED
@@ -13,12 +13,17 @@ File = typing.Union[
|
|
13
13
|
# (filename, file (or bytes), content_type)
|
14
14
|
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]],
|
15
15
|
# (filename, file (or bytes), content_type, headers)
|
16
|
-
typing.Tuple[
|
16
|
+
typing.Tuple[
|
17
|
+
typing.Optional[str],
|
18
|
+
FileContent,
|
19
|
+
typing.Optional[str],
|
20
|
+
typing.Mapping[str, str],
|
21
|
+
],
|
17
22
|
]
|
18
23
|
|
19
24
|
|
20
25
|
def convert_file_dict_to_httpx_tuples(
|
21
|
-
d: typing.Dict[str, typing.Union[File, typing.List[File]]]
|
26
|
+
d: typing.Dict[str, typing.Union[File, typing.List[File]]],
|
22
27
|
) -> typing.List[typing.Tuple[str, File]]:
|
23
28
|
"""
|
24
29
|
The format we use is a list of tuples, where the first element is the
|
vellum/core/http_client.py
CHANGED
@@ -90,7 +90,8 @@ def _should_retry(response: httpx.Response) -> bool:
|
|
90
90
|
|
91
91
|
|
92
92
|
def remove_omit_from_dict(
|
93
|
-
original: typing.Dict[str, typing.Optional[typing.Any]],
|
93
|
+
original: typing.Dict[str, typing.Optional[typing.Any]],
|
94
|
+
omit: typing.Optional[typing.Any],
|
94
95
|
) -> typing.Dict[str, typing.Any]:
|
95
96
|
if omit is None:
|
96
97
|
return original
|
@@ -142,7 +143,8 @@ def get_request_body(
|
|
142
143
|
# If both data and json are None, we send json data in the event extra properties are specified
|
143
144
|
json_body = maybe_filter_request_body(json, request_options, omit)
|
144
145
|
|
145
|
-
|
146
|
+
# If you have an empty JSON body, you should just send None
|
147
|
+
return (json_body if json_body != {} else None), data_body if data_body != {} else None
|
146
148
|
|
147
149
|
|
148
150
|
class HttpClient:
|
vellum/core/jsonable_encoder.py
CHANGED
@@ -11,31 +11,24 @@ https://github.com/tiangolo/fastapi/blob/master/fastapi/encoders.py
|
|
11
11
|
import base64
|
12
12
|
import dataclasses
|
13
13
|
import datetime as dt
|
14
|
-
from collections import defaultdict
|
15
14
|
from enum import Enum
|
16
15
|
from pathlib import PurePath
|
17
16
|
from types import GeneratorType
|
18
|
-
from typing import Any, Callable, Dict, List, Optional, Set,
|
17
|
+
from typing import Any, Callable, Dict, List, Optional, Set, Union
|
18
|
+
|
19
|
+
import pydantic
|
19
20
|
|
20
21
|
from .datetime_utils import serialize_datetime
|
21
|
-
from .pydantic_utilities import
|
22
|
+
from .pydantic_utilities import (
|
23
|
+
IS_PYDANTIC_V2,
|
24
|
+
encode_by_type,
|
25
|
+
to_jsonable_with_fallback,
|
26
|
+
)
|
22
27
|
|
23
28
|
SetIntStr = Set[Union[int, str]]
|
24
29
|
DictIntStrAny = Dict[Union[int, str], Any]
|
25
30
|
|
26
31
|
|
27
|
-
def generate_encoders_by_class_tuples(
|
28
|
-
type_encoder_map: Dict[Any, Callable[[Any], Any]]
|
29
|
-
) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]:
|
30
|
-
encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple)
|
31
|
-
for type_, encoder in type_encoder_map.items():
|
32
|
-
encoders_by_class_tuples[encoder] += (type_,)
|
33
|
-
return encoders_by_class_tuples
|
34
|
-
|
35
|
-
|
36
|
-
encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE)
|
37
|
-
|
38
|
-
|
39
32
|
def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
|
40
33
|
custom_encoder = custom_encoder or {}
|
41
34
|
if custom_encoder:
|
@@ -45,16 +38,21 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
45
38
|
for encoder_type, encoder_instance in custom_encoder.items():
|
46
39
|
if isinstance(obj, encoder_type):
|
47
40
|
return encoder_instance(obj)
|
48
|
-
if isinstance(obj,
|
49
|
-
|
41
|
+
if isinstance(obj, pydantic.BaseModel):
|
42
|
+
if IS_PYDANTIC_V2:
|
43
|
+
encoder = getattr(obj.model_config, "json_encoders", {}) # type: ignore # Pydantic v2
|
44
|
+
else:
|
45
|
+
encoder = getattr(obj.__config__, "json_encoders", {}) # type: ignore # Pydantic v1
|
50
46
|
if custom_encoder:
|
51
47
|
encoder.update(custom_encoder)
|
52
48
|
obj_dict = obj.dict(by_alias=True)
|
53
49
|
if "__root__" in obj_dict:
|
54
50
|
obj_dict = obj_dict["__root__"]
|
51
|
+
if "root" in obj_dict:
|
52
|
+
obj_dict = obj_dict["root"]
|
55
53
|
return jsonable_encoder(obj_dict, custom_encoder=encoder)
|
56
54
|
if dataclasses.is_dataclass(obj):
|
57
|
-
obj_dict = dataclasses.asdict(obj)
|
55
|
+
obj_dict = dataclasses.asdict(obj) # type: ignore
|
58
56
|
return jsonable_encoder(obj_dict, custom_encoder=custom_encoder)
|
59
57
|
if isinstance(obj, bytes):
|
60
58
|
return base64.b64encode(obj).decode("utf-8")
|
@@ -83,20 +81,21 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
83
81
|
encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder))
|
84
82
|
return encoded_list
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
return encoder(obj)
|
84
|
+
def fallback_serializer(o: Any) -> Any:
|
85
|
+
attempt_encode = encode_by_type(o)
|
86
|
+
if attempt_encode is not None:
|
87
|
+
return attempt_encode
|
91
88
|
|
92
|
-
try:
|
93
|
-
data = dict(obj)
|
94
|
-
except Exception as e:
|
95
|
-
errors: List[Exception] = []
|
96
|
-
errors.append(e)
|
97
89
|
try:
|
98
|
-
data =
|
90
|
+
data = dict(o)
|
99
91
|
except Exception as e:
|
92
|
+
errors: List[Exception] = []
|
100
93
|
errors.append(e)
|
101
|
-
|
102
|
-
|
94
|
+
try:
|
95
|
+
data = vars(o)
|
96
|
+
except Exception as e:
|
97
|
+
errors.append(e)
|
98
|
+
raise ValueError(errors) from e
|
99
|
+
return jsonable_encoder(data, custom_encoder=custom_encoder)
|
100
|
+
|
101
|
+
return to_jsonable_with_fallback(obj, fallback_serializer)
|
@@ -1,28 +1,206 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
+
# nopycln: file
|
4
|
+
import datetime as dt
|
3
5
|
import typing
|
6
|
+
from collections import defaultdict
|
7
|
+
|
8
|
+
import typing_extensions
|
4
9
|
|
5
10
|
import pydantic
|
6
11
|
|
12
|
+
from .datetime_utils import serialize_datetime
|
13
|
+
|
7
14
|
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
|
8
15
|
|
9
16
|
if IS_PYDANTIC_V2:
|
10
|
-
|
17
|
+
# isort will try to reformat the comments on these imports, which breaks mypy
|
18
|
+
# isort: off
|
19
|
+
from pydantic.v1.datetime_parse import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2
|
20
|
+
parse_date as parse_date,
|
21
|
+
)
|
22
|
+
from pydantic.v1.datetime_parse import ( # pyright: ignore[reportMissingImports] # Pydantic v2
|
23
|
+
parse_datetime as parse_datetime,
|
24
|
+
)
|
25
|
+
from pydantic.v1.json import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2
|
26
|
+
ENCODERS_BY_TYPE as encoders_by_type,
|
27
|
+
)
|
28
|
+
from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2
|
29
|
+
get_args as get_args,
|
30
|
+
)
|
31
|
+
from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2
|
32
|
+
get_origin as get_origin,
|
33
|
+
)
|
34
|
+
from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2
|
35
|
+
is_literal_type as is_literal_type,
|
36
|
+
)
|
37
|
+
from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2
|
38
|
+
is_union as is_union,
|
39
|
+
)
|
40
|
+
from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2
|
41
|
+
else:
|
42
|
+
from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1
|
43
|
+
from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore # Pydantic v1
|
44
|
+
from pydantic.fields import ModelField as ModelField # type: ignore # Pydantic v1
|
45
|
+
from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore # Pydantic v1
|
46
|
+
from pydantic.typing import get_args as get_args # type: ignore # Pydantic v1
|
47
|
+
from pydantic.typing import get_origin as get_origin # type: ignore # Pydantic v1
|
48
|
+
from pydantic.typing import is_literal_type as is_literal_type # type: ignore # Pydantic v1
|
49
|
+
from pydantic.typing import is_union as is_union # type: ignore # Pydantic v1
|
50
|
+
|
51
|
+
# isort: on
|
52
|
+
|
53
|
+
|
54
|
+
T = typing.TypeVar("T")
|
55
|
+
Model = typing.TypeVar("Model", bound=pydantic.BaseModel)
|
56
|
+
|
57
|
+
|
58
|
+
def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T:
|
59
|
+
if IS_PYDANTIC_V2:
|
60
|
+
adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2
|
61
|
+
return adapter.validate_python(object_)
|
62
|
+
else:
|
63
|
+
return pydantic.parse_obj_as(type_, object_)
|
64
|
+
|
65
|
+
|
66
|
+
def to_jsonable_with_fallback(
|
67
|
+
obj: typing.Any, fallback_serializer: typing.Callable[[typing.Any], typing.Any]
|
68
|
+
) -> typing.Any:
|
69
|
+
if IS_PYDANTIC_V2:
|
70
|
+
from pydantic_core import to_jsonable_python
|
71
|
+
|
72
|
+
return to_jsonable_python(obj, fallback=fallback_serializer)
|
73
|
+
else:
|
74
|
+
return fallback_serializer(obj)
|
75
|
+
|
76
|
+
|
77
|
+
class UniversalBaseModel(pydantic.BaseModel):
|
78
|
+
class Config:
|
79
|
+
populate_by_name = True
|
80
|
+
smart_union = True
|
81
|
+
allow_population_by_field_name = True
|
82
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
83
|
+
|
84
|
+
def json(self, **kwargs: typing.Any) -> str:
|
85
|
+
kwargs_with_defaults: typing.Any = {
|
86
|
+
"by_alias": True,
|
87
|
+
"exclude_unset": True,
|
88
|
+
**kwargs,
|
89
|
+
}
|
90
|
+
if IS_PYDANTIC_V2:
|
91
|
+
return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2
|
92
|
+
else:
|
93
|
+
return super().json(**kwargs_with_defaults)
|
94
|
+
|
95
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
96
|
+
"""
|
97
|
+
Override the default dict method to `exclude_unset` by default. This function patches
|
98
|
+
`exclude_unset` to work include fields within non-None default values.
|
99
|
+
"""
|
100
|
+
_fields_set = self.__fields_set__
|
101
|
+
|
102
|
+
fields = _get_model_fields(self.__class__)
|
103
|
+
for name, field in fields.items():
|
104
|
+
if name not in _fields_set:
|
105
|
+
default = _get_field_default(field)
|
106
|
+
|
107
|
+
# If the default values are non-null act like they've been set
|
108
|
+
# This effectively allows exclude_unset to work like exclude_none where
|
109
|
+
# the latter passes through intentionally set none values.
|
110
|
+
if default != None:
|
111
|
+
_fields_set.add(name)
|
112
|
+
|
113
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {
|
114
|
+
"by_alias": True,
|
115
|
+
"exclude_unset": True,
|
116
|
+
"include": _fields_set,
|
117
|
+
**kwargs,
|
118
|
+
}
|
119
|
+
|
120
|
+
if IS_PYDANTIC_V2:
|
121
|
+
return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2
|
122
|
+
else:
|
123
|
+
return super().dict(**kwargs_with_defaults_exclude_unset)
|
124
|
+
|
125
|
+
|
126
|
+
if IS_PYDANTIC_V2:
|
127
|
+
|
128
|
+
class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2
|
129
|
+
pass
|
130
|
+
|
131
|
+
UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore
|
11
132
|
else:
|
12
|
-
|
133
|
+
UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore
|
134
|
+
|
135
|
+
|
136
|
+
def encode_by_type(o: typing.Any) -> typing.Any:
|
137
|
+
encoders_by_class_tuples: typing.Dict[typing.Callable[[typing.Any], typing.Any], typing.Tuple[typing.Any, ...]] = (
|
138
|
+
defaultdict(tuple)
|
139
|
+
)
|
140
|
+
for type_, encoder in encoders_by_type.items():
|
141
|
+
encoders_by_class_tuples[encoder] += (type_,)
|
142
|
+
|
143
|
+
if type(o) in encoders_by_type:
|
144
|
+
return encoders_by_type[type(o)](o)
|
145
|
+
for encoder, classes_tuple in encoders_by_class_tuples.items():
|
146
|
+
if isinstance(o, classes_tuple):
|
147
|
+
return encoder(o)
|
148
|
+
|
149
|
+
|
150
|
+
def update_forward_refs(model: typing.Type["Model"]) -> None:
|
151
|
+
if IS_PYDANTIC_V2:
|
152
|
+
model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2
|
153
|
+
else:
|
154
|
+
model.update_forward_refs()
|
155
|
+
|
13
156
|
|
157
|
+
# Mirrors Pydantic's internal typing
|
158
|
+
AnyCallable = typing.Callable[..., typing.Any]
|
14
159
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
160
|
+
|
161
|
+
def universal_root_validator(
|
162
|
+
pre: bool = False,
|
163
|
+
) -> typing.Callable[[AnyCallable], AnyCallable]:
|
164
|
+
def decorator(func: AnyCallable) -> AnyCallable:
|
165
|
+
if IS_PYDANTIC_V2:
|
166
|
+
return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2
|
167
|
+
else:
|
168
|
+
return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1
|
169
|
+
|
170
|
+
return decorator
|
171
|
+
|
172
|
+
|
173
|
+
def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]:
|
174
|
+
def decorator(func: AnyCallable) -> AnyCallable:
|
175
|
+
if IS_PYDANTIC_V2:
|
176
|
+
return pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2
|
22
177
|
else:
|
23
|
-
|
178
|
+
return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1
|
179
|
+
|
180
|
+
return decorator
|
181
|
+
|
182
|
+
|
183
|
+
PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo]
|
184
|
+
|
185
|
+
|
186
|
+
def _get_model_fields(
|
187
|
+
model: typing.Type["Model"],
|
188
|
+
) -> typing.Mapping[str, PydanticField]:
|
189
|
+
if IS_PYDANTIC_V2:
|
190
|
+
return model.model_fields # type: ignore # Pydantic v2
|
191
|
+
else:
|
192
|
+
return model.__fields__ # type: ignore # Pydantic v1
|
24
193
|
|
25
|
-
return destination
|
26
194
|
|
195
|
+
def _get_field_default(field: PydanticField) -> typing.Any:
|
196
|
+
try:
|
197
|
+
value = field.get_default() # type: ignore # Pydantic < v1.10.15
|
198
|
+
except:
|
199
|
+
value = field.default
|
200
|
+
if IS_PYDANTIC_V2:
|
201
|
+
from pydantic_core import PydanticUndefined
|
27
202
|
|
28
|
-
|
203
|
+
if value == PydanticUndefined:
|
204
|
+
return None
|
205
|
+
return value
|
206
|
+
return value
|
vellum/core/query_encoder.py
CHANGED
@@ -1,33 +1,58 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
from
|
4
|
-
from typing import Any, Dict, Optional
|
3
|
+
from typing import Any, Dict, List, Optional, Tuple
|
5
4
|
|
6
|
-
|
5
|
+
import pydantic
|
7
6
|
|
8
7
|
|
9
8
|
# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict
|
10
|
-
def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) ->
|
11
|
-
result =
|
9
|
+
def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]:
|
10
|
+
result = []
|
12
11
|
for k, v in dict_flat.items():
|
13
12
|
key = f"{key_prefix}[{k}]" if key_prefix is not None else k
|
14
13
|
if isinstance(v, dict):
|
15
|
-
result.
|
14
|
+
result.extend(traverse_query_dict(v, key))
|
15
|
+
elif isinstance(v, list):
|
16
|
+
for arr_v in v:
|
17
|
+
if isinstance(arr_v, dict):
|
18
|
+
result.extend(traverse_query_dict(arr_v, key))
|
19
|
+
else:
|
20
|
+
result.append((key, arr_v))
|
16
21
|
else:
|
17
|
-
result
|
22
|
+
result.append((key, v))
|
18
23
|
return result
|
19
24
|
|
20
25
|
|
21
|
-
def single_query_encoder(query_key: str, query_value: Any) ->
|
22
|
-
if isinstance(query_value,
|
23
|
-
if isinstance(query_value,
|
26
|
+
def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]:
|
27
|
+
if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict):
|
28
|
+
if isinstance(query_value, pydantic.BaseModel):
|
24
29
|
obj_dict = query_value.dict(by_alias=True)
|
25
30
|
else:
|
26
31
|
obj_dict = query_value
|
27
32
|
return traverse_query_dict(obj_dict, query_key)
|
33
|
+
elif isinstance(query_value, list):
|
34
|
+
encoded_values: List[Tuple[str, Any]] = []
|
35
|
+
for value in query_value:
|
36
|
+
if isinstance(value, pydantic.BaseModel) or isinstance(value, dict):
|
37
|
+
if isinstance(value, pydantic.BaseModel):
|
38
|
+
obj_dict = value.dict(by_alias=True)
|
39
|
+
elif isinstance(value, dict):
|
40
|
+
obj_dict = value
|
28
41
|
|
29
|
-
|
42
|
+
encoded_values.extend(single_query_encoder(query_key, obj_dict))
|
43
|
+
else:
|
44
|
+
encoded_values.append((query_key, value))
|
30
45
|
|
46
|
+
return encoded_values
|
31
47
|
|
32
|
-
|
33
|
-
|
48
|
+
return [(query_key, query_value)]
|
49
|
+
|
50
|
+
|
51
|
+
def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]:
|
52
|
+
if query is None:
|
53
|
+
return None
|
54
|
+
|
55
|
+
encoded_query = []
|
56
|
+
for k, v in query.items():
|
57
|
+
encoded_query.extend(single_query_encoder(k, v))
|
58
|
+
return encoded_query
|