mirascope 2.0.0a5__py3-none-any.whl → 2.0.1__py3-none-any.whl
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.
- mirascope/__init__.py +10 -1
- mirascope/_stubs.py +363 -0
- mirascope/api/__init__.py +8 -0
- mirascope/api/_generated/__init__.py +285 -2
- mirascope/api/_generated/annotations/__init__.py +33 -0
- mirascope/api/_generated/annotations/client.py +506 -0
- mirascope/api/_generated/annotations/raw_client.py +1414 -0
- mirascope/api/_generated/annotations/types/__init__.py +31 -0
- mirascope/api/_generated/annotations/types/annotations_create_request_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_create_response.py +48 -0
- mirascope/api/_generated/annotations/types/annotations_create_response_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_get_response.py +48 -0
- mirascope/api/_generated/annotations/types/annotations_get_response_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_list_request_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_list_response.py +21 -0
- mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +50 -0
- mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_update_request_label.py +5 -0
- mirascope/api/_generated/annotations/types/annotations_update_response.py +48 -0
- mirascope/api/_generated/annotations/types/annotations_update_response_label.py +5 -0
- mirascope/api/_generated/api_keys/__init__.py +12 -2
- mirascope/api/_generated/api_keys/client.py +77 -0
- mirascope/api/_generated/api_keys/raw_client.py +422 -39
- mirascope/api/_generated/api_keys/types/__init__.py +7 -1
- mirascope/api/_generated/api_keys/types/api_keys_create_response.py +4 -12
- mirascope/api/_generated/api_keys/types/api_keys_get_response.py +4 -12
- mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +40 -0
- mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +4 -12
- mirascope/api/_generated/client.py +42 -0
- mirascope/api/_generated/core/client_wrapper.py +2 -14
- mirascope/api/_generated/core/datetime_utils.py +1 -3
- mirascope/api/_generated/core/file.py +2 -5
- mirascope/api/_generated/core/http_client.py +36 -112
- mirascope/api/_generated/core/jsonable_encoder.py +1 -3
- mirascope/api/_generated/core/pydantic_utilities.py +19 -74
- mirascope/api/_generated/core/query_encoder.py +1 -3
- mirascope/api/_generated/core/serialization.py +4 -10
- mirascope/api/_generated/docs/client.py +2 -6
- mirascope/api/_generated/docs/raw_client.py +51 -5
- mirascope/api/_generated/environment.py +3 -3
- mirascope/api/_generated/environments/__init__.py +6 -0
- mirascope/api/_generated/environments/client.py +117 -0
- mirascope/api/_generated/environments/raw_client.py +530 -51
- mirascope/api/_generated/environments/types/__init__.py +10 -0
- mirascope/api/_generated/environments/types/environments_create_response.py +1 -3
- mirascope/api/_generated/environments/types/environments_get_analytics_response.py +60 -0
- mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +24 -0
- mirascope/api/_generated/environments/types/environments_get_analytics_response_top_models_item.py +22 -0
- mirascope/api/_generated/environments/types/environments_get_response.py +1 -3
- mirascope/api/_generated/environments/types/environments_list_response_item.py +1 -3
- mirascope/api/_generated/environments/types/environments_update_response.py +1 -3
- mirascope/api/_generated/errors/__init__.py +8 -0
- mirascope/api/_generated/errors/bad_request_error.py +1 -2
- mirascope/api/_generated/errors/conflict_error.py +1 -2
- mirascope/api/_generated/errors/forbidden_error.py +1 -5
- mirascope/api/_generated/errors/internal_server_error.py +1 -6
- mirascope/api/_generated/errors/not_found_error.py +1 -5
- mirascope/api/_generated/errors/payment_required_error.py +15 -0
- mirascope/api/_generated/errors/service_unavailable_error.py +14 -0
- mirascope/api/_generated/errors/too_many_requests_error.py +15 -0
- mirascope/api/_generated/errors/unauthorized_error.py +11 -0
- mirascope/api/_generated/functions/__init__.py +39 -0
- mirascope/api/_generated/functions/client.py +647 -0
- mirascope/api/_generated/functions/raw_client.py +1890 -0
- mirascope/api/_generated/functions/types/__init__.py +53 -0
- mirascope/api/_generated/functions/types/functions_create_request_dependencies_value.py +20 -0
- mirascope/api/_generated/functions/types/functions_create_response.py +37 -0
- mirascope/api/_generated/functions/types/functions_create_response_dependencies_value.py +20 -0
- mirascope/api/_generated/functions/types/functions_find_by_hash_response.py +39 -0
- mirascope/api/_generated/functions/types/functions_find_by_hash_response_dependencies_value.py +20 -0
- mirascope/api/_generated/functions/types/functions_get_by_env_response.py +53 -0
- mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +22 -0
- mirascope/api/_generated/functions/types/functions_get_response.py +37 -0
- mirascope/api/_generated/functions/types/functions_get_response_dependencies_value.py +20 -0
- mirascope/api/_generated/functions/types/functions_list_by_env_response.py +25 -0
- mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +56 -0
- mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +22 -0
- mirascope/api/_generated/functions/types/functions_list_response.py +21 -0
- mirascope/api/_generated/functions/types/functions_list_response_functions_item.py +41 -0
- mirascope/api/_generated/functions/types/functions_list_response_functions_item_dependencies_value.py +20 -0
- mirascope/api/_generated/health/client.py +2 -6
- mirascope/api/_generated/health/raw_client.py +51 -5
- mirascope/api/_generated/health/types/health_check_response.py +1 -3
- mirascope/api/_generated/organization_invitations/__init__.py +33 -0
- mirascope/api/_generated/organization_invitations/client.py +546 -0
- mirascope/api/_generated/organization_invitations/raw_client.py +1519 -0
- mirascope/api/_generated/organization_invitations/types/__init__.py +53 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +34 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +48 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +48 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +48 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +7 -0
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +7 -0
- mirascope/api/_generated/organization_memberships/__init__.py +19 -0
- mirascope/api/_generated/organization_memberships/client.py +302 -0
- mirascope/api/_generated/organization_memberships/raw_client.py +736 -0
- mirascope/api/_generated/organization_memberships/types/__init__.py +27 -0
- mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +33 -0
- mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +7 -0
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +7 -0
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +31 -0
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +7 -0
- mirascope/api/_generated/organizations/__init__.py +26 -0
- mirascope/api/_generated/organizations/client.py +465 -0
- mirascope/api/_generated/organizations/raw_client.py +1799 -108
- mirascope/api/_generated/organizations/types/__init__.py +48 -0
- mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
- mirascope/api/_generated/organizations/types/organizations_create_response.py +4 -3
- mirascope/api/_generated/organizations/types/organizations_create_response_role.py +1 -3
- mirascope/api/_generated/organizations/types/organizations_get_response.py +4 -3
- mirascope/api/_generated/organizations/types/organizations_get_response_role.py +1 -3
- mirascope/api/_generated/organizations/types/organizations_list_response_item.py +4 -3
- mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +1 -3
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +47 -0
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +33 -0
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +24 -0
- mirascope/api/_generated/organizations/types/organizations_subscription_response.py +53 -0
- mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +26 -0
- mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +34 -0
- mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_update_response.py +4 -3
- mirascope/api/_generated/organizations/types/organizations_update_response_role.py +1 -3
- mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +35 -0
- mirascope/api/_generated/project_memberships/__init__.py +25 -0
- mirascope/api/_generated/project_memberships/client.py +437 -0
- mirascope/api/_generated/project_memberships/raw_client.py +1039 -0
- mirascope/api/_generated/project_memberships/types/__init__.py +29 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +7 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +35 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +7 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +33 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +7 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +7 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +35 -0
- mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +7 -0
- mirascope/api/_generated/projects/__init__.py +2 -12
- mirascope/api/_generated/projects/client.py +17 -71
- mirascope/api/_generated/projects/raw_client.py +295 -51
- mirascope/api/_generated/projects/types/__init__.py +1 -6
- mirascope/api/_generated/projects/types/projects_create_response.py +3 -9
- mirascope/api/_generated/projects/types/projects_get_response.py +3 -9
- mirascope/api/_generated/projects/types/projects_list_response_item.py +3 -9
- mirascope/api/_generated/projects/types/projects_update_response.py +3 -9
- mirascope/api/_generated/reference.md +3619 -182
- mirascope/api/_generated/tags/__init__.py +19 -0
- mirascope/api/_generated/tags/client.py +504 -0
- mirascope/api/_generated/tags/raw_client.py +1288 -0
- mirascope/api/_generated/tags/types/__init__.py +17 -0
- mirascope/api/_generated/tags/types/tags_create_response.py +41 -0
- mirascope/api/_generated/tags/types/tags_get_response.py +41 -0
- mirascope/api/_generated/tags/types/tags_list_response.py +23 -0
- mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +41 -0
- mirascope/api/_generated/tags/types/tags_update_response.py +41 -0
- mirascope/api/_generated/token_cost/__init__.py +7 -0
- mirascope/api/_generated/token_cost/client.py +160 -0
- mirascope/api/_generated/token_cost/raw_client.py +264 -0
- mirascope/api/_generated/token_cost/types/__init__.py +8 -0
- mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +54 -0
- mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +52 -0
- mirascope/api/_generated/traces/__init__.py +42 -0
- mirascope/api/_generated/traces/client.py +941 -0
- mirascope/api/_generated/traces/raw_client.py +2177 -23
- mirascope/api/_generated/traces/types/__init__.py +60 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +4 -11
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +1 -3
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +8 -24
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +3 -9
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +3 -9
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +4 -8
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +8 -24
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +3 -9
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +1 -3
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +6 -18
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +3 -9
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +8 -24
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +1 -3
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +2 -6
- mirascope/api/_generated/traces/types/traces_create_response.py +2 -5
- mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +3 -9
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +60 -0
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_functions_item.py +24 -0
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_models_item.py +22 -0
- mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +33 -0
- mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +88 -0
- mirascope/api/_generated/traces/types/traces_get_trace_detail_response.py +33 -0
- mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +88 -0
- mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +25 -0
- mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +44 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +26 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +7 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +7 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +7 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_response.py +26 -0
- mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +50 -0
- mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item.py +26 -0
- mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item_operator.py +7 -0
- mirascope/api/_generated/traces/types/traces_search_request_sort_by.py +7 -0
- mirascope/api/_generated/traces/types/traces_search_request_sort_order.py +5 -0
- mirascope/api/_generated/traces/types/traces_search_response.py +26 -0
- mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +50 -0
- mirascope/api/_generated/types/__init__.py +48 -0
- mirascope/api/_generated/types/already_exists_error.py +1 -3
- mirascope/api/_generated/types/bad_request_error_body.py +50 -0
- mirascope/api/_generated/types/click_house_error.py +22 -0
- mirascope/api/_generated/types/database_error.py +1 -3
- mirascope/api/_generated/types/date.py +3 -0
- mirascope/api/_generated/types/http_api_decode_error.py +1 -3
- mirascope/api/_generated/types/immutable_resource_error.py +22 -0
- mirascope/api/_generated/types/internal_server_error_body.py +49 -0
- mirascope/api/_generated/types/issue.py +1 -3
- mirascope/api/_generated/types/issue_tag.py +1 -8
- mirascope/api/_generated/types/not_found_error_body.py +1 -3
- mirascope/api/_generated/types/number_from_string.py +3 -0
- mirascope/api/_generated/types/permission_denied_error.py +1 -3
- mirascope/api/_generated/types/permission_denied_error_tag.py +1 -3
- mirascope/api/_generated/types/plan_limit_exceeded_error.py +32 -0
- mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +7 -0
- mirascope/api/_generated/types/pricing_unavailable_error.py +23 -0
- mirascope/api/_generated/types/property_key_key.py +1 -3
- mirascope/api/_generated/types/rate_limit_error.py +31 -0
- mirascope/api/_generated/types/rate_limit_error_tag.py +5 -0
- mirascope/api/_generated/types/service_unavailable_error_body.py +24 -0
- mirascope/api/_generated/types/service_unavailable_error_tag.py +7 -0
- mirascope/api/_generated/types/stripe_error.py +20 -0
- mirascope/api/_generated/types/subscription_past_due_error.py +31 -0
- mirascope/api/_generated/types/subscription_past_due_error_tag.py +7 -0
- mirascope/api/_generated/types/unauthorized_error_body.py +21 -0
- mirascope/api/_generated/types/unauthorized_error_tag.py +5 -0
- mirascope/api/settings.py +19 -1
- mirascope/llm/__init__.py +55 -8
- mirascope/llm/calls/__init__.py +2 -1
- mirascope/llm/calls/calls.py +3 -1
- mirascope/llm/calls/decorator.py +21 -7
- mirascope/llm/content/tool_call.py +6 -0
- mirascope/llm/content/tool_output.py +22 -5
- mirascope/llm/exceptions.py +284 -71
- mirascope/llm/formatting/__init__.py +19 -2
- mirascope/llm/formatting/format.py +219 -30
- mirascope/llm/formatting/output_parser.py +178 -0
- mirascope/llm/formatting/partial.py +80 -7
- mirascope/llm/formatting/primitives.py +192 -0
- mirascope/llm/formatting/types.py +21 -64
- mirascope/llm/mcp/__init__.py +2 -2
- mirascope/llm/mcp/mcp_client.py +130 -0
- mirascope/llm/messages/__init__.py +3 -0
- mirascope/llm/messages/_utils.py +34 -0
- mirascope/llm/models/__init__.py +5 -0
- mirascope/llm/models/models.py +137 -69
- mirascope/llm/{providers/base → models}/params.py +16 -37
- mirascope/llm/models/thinking_config.py +61 -0
- mirascope/llm/prompts/_utils.py +0 -32
- mirascope/llm/prompts/decorator.py +16 -5
- mirascope/llm/prompts/prompts.py +131 -68
- mirascope/llm/providers/__init__.py +18 -2
- mirascope/llm/providers/anthropic/__init__.py +3 -21
- mirascope/llm/providers/anthropic/_utils/__init__.py +2 -0
- mirascope/llm/providers/anthropic/_utils/beta_decode.py +22 -11
- mirascope/llm/providers/anthropic/_utils/beta_encode.py +75 -25
- mirascope/llm/providers/anthropic/_utils/decode.py +22 -11
- mirascope/llm/providers/anthropic/_utils/encode.py +82 -20
- mirascope/llm/providers/anthropic/_utils/errors.py +2 -2
- mirascope/llm/providers/anthropic/beta_provider.py +64 -18
- mirascope/llm/providers/anthropic/provider.py +91 -33
- mirascope/llm/providers/base/__init__.py +0 -2
- mirascope/llm/providers/base/_utils.py +55 -11
- mirascope/llm/providers/base/base_provider.py +116 -37
- mirascope/llm/providers/google/__init__.py +2 -17
- mirascope/llm/providers/google/_utils/__init__.py +2 -0
- mirascope/llm/providers/google/_utils/decode.py +37 -15
- mirascope/llm/providers/google/_utils/encode.py +127 -19
- mirascope/llm/providers/google/_utils/errors.py +3 -2
- mirascope/llm/providers/google/model_info.py +1 -0
- mirascope/llm/providers/google/provider.py +68 -19
- mirascope/llm/providers/mirascope/__init__.py +5 -0
- mirascope/llm/providers/mirascope/_utils.py +73 -0
- mirascope/llm/providers/mirascope/provider.py +349 -0
- mirascope/llm/providers/mlx/__init__.py +2 -17
- mirascope/llm/providers/mlx/_utils.py +8 -3
- mirascope/llm/providers/mlx/encoding/base.py +5 -2
- mirascope/llm/providers/mlx/encoding/transformers.py +5 -2
- mirascope/llm/providers/mlx/mlx.py +23 -6
- mirascope/llm/providers/mlx/provider.py +42 -13
- mirascope/llm/providers/ollama/__init__.py +1 -13
- mirascope/llm/providers/openai/_utils/errors.py +2 -2
- mirascope/llm/providers/openai/completions/__init__.py +2 -20
- mirascope/llm/providers/openai/completions/_utils/decode.py +14 -3
- mirascope/llm/providers/openai/completions/_utils/encode.py +35 -28
- mirascope/llm/providers/openai/completions/base_provider.py +40 -11
- mirascope/llm/providers/openai/provider.py +40 -10
- mirascope/llm/providers/openai/responses/__init__.py +1 -17
- mirascope/llm/providers/openai/responses/_utils/__init__.py +2 -0
- mirascope/llm/providers/openai/responses/_utils/decode.py +21 -8
- mirascope/llm/providers/openai/responses/_utils/encode.py +59 -19
- mirascope/llm/providers/openai/responses/provider.py +56 -18
- mirascope/llm/providers/provider_id.py +1 -0
- mirascope/llm/providers/provider_registry.py +96 -19
- mirascope/llm/providers/together/__init__.py +1 -13
- mirascope/llm/responses/__init__.py +6 -1
- mirascope/llm/responses/_utils.py +102 -12
- mirascope/llm/responses/base_response.py +5 -2
- mirascope/llm/responses/base_stream_response.py +139 -45
- mirascope/llm/responses/response.py +2 -1
- mirascope/llm/responses/root_response.py +89 -17
- mirascope/llm/responses/stream_response.py +6 -9
- mirascope/llm/tools/decorator.py +17 -8
- mirascope/llm/tools/tool_schema.py +43 -10
- mirascope/llm/tools/toolkit.py +35 -27
- mirascope/llm/tools/tools.py +123 -30
- mirascope/ops/__init__.py +64 -109
- mirascope/ops/_internal/configuration.py +82 -31
- mirascope/ops/_internal/exporters/exporters.py +64 -11
- mirascope/ops/_internal/instrumentation/llm/common.py +530 -0
- mirascope/ops/_internal/instrumentation/llm/cost.py +190 -0
- mirascope/ops/_internal/instrumentation/llm/encode.py +1 -1
- mirascope/ops/_internal/instrumentation/llm/llm.py +116 -1243
- mirascope/ops/_internal/instrumentation/llm/model.py +1798 -0
- mirascope/ops/_internal/instrumentation/llm/response.py +521 -0
- mirascope/ops/_internal/instrumentation/llm/serialize.py +300 -0
- mirascope/ops/_internal/protocols.py +83 -1
- mirascope/ops/_internal/traced_calls.py +4 -0
- mirascope/ops/_internal/traced_functions.py +141 -12
- mirascope/ops/_internal/tracing.py +78 -1
- mirascope/ops/_internal/utils.py +52 -4
- mirascope/ops/_internal/versioned_functions.py +54 -43
- {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/METADATA +14 -13
- mirascope-2.0.1.dist-info/RECORD +423 -0
- {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/licenses/LICENSE +1 -1
- mirascope/llm/formatting/_utils.py +0 -78
- mirascope/llm/mcp/client.py +0 -118
- mirascope/llm/providers/_missing_import_stubs.py +0 -49
- mirascope-2.0.0a5.dist-info/RECORD +0 -265
- {mirascope-2.0.0a5.dist-info → mirascope-2.0.1.dist-info}/WHEEL +0 -0
|
@@ -12,21 +12,13 @@ class ApiKeysGetResponse(UniversalBaseModel):
|
|
|
12
12
|
id: str
|
|
13
13
|
name: str
|
|
14
14
|
key_prefix: typing_extensions.Annotated[str, FieldMetadata(alias="keyPrefix")]
|
|
15
|
-
environment_id: typing_extensions.Annotated[
|
|
16
|
-
str, FieldMetadata(alias="environmentId")
|
|
17
|
-
]
|
|
15
|
+
environment_id: typing_extensions.Annotated[str, FieldMetadata(alias="environmentId")]
|
|
18
16
|
owner_id: typing_extensions.Annotated[str, FieldMetadata(alias="ownerId")]
|
|
19
|
-
created_at: typing_extensions.Annotated[
|
|
20
|
-
|
|
21
|
-
] = None
|
|
22
|
-
last_used_at: typing_extensions.Annotated[
|
|
23
|
-
typing.Optional[str], FieldMetadata(alias="lastUsedAt")
|
|
24
|
-
] = None
|
|
17
|
+
created_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="createdAt")] = None
|
|
18
|
+
last_used_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="lastUsedAt")] = None
|
|
25
19
|
|
|
26
20
|
if IS_PYDANTIC_V2:
|
|
27
|
-
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
28
|
-
extra="allow", frozen=True
|
|
29
|
-
) # type: ignore # Pydantic v2
|
|
21
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
30
22
|
else:
|
|
31
23
|
|
|
32
24
|
class Config:
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
import typing_extensions
|
|
7
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
8
|
+
from ...core.serialization import FieldMetadata
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ApiKeysListAllForOrgResponseItem(UniversalBaseModel):
|
|
12
|
+
id: str
|
|
13
|
+
name: str
|
|
14
|
+
key_prefix: typing_extensions.Annotated[str, FieldMetadata(alias="keyPrefix")]
|
|
15
|
+
environment_id: typing_extensions.Annotated[
|
|
16
|
+
str, FieldMetadata(alias="environmentId")
|
|
17
|
+
]
|
|
18
|
+
owner_id: typing_extensions.Annotated[str, FieldMetadata(alias="ownerId")]
|
|
19
|
+
created_at: typing_extensions.Annotated[
|
|
20
|
+
typing.Optional[str], FieldMetadata(alias="createdAt")
|
|
21
|
+
] = None
|
|
22
|
+
last_used_at: typing_extensions.Annotated[
|
|
23
|
+
typing.Optional[str], FieldMetadata(alias="lastUsedAt")
|
|
24
|
+
] = None
|
|
25
|
+
project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")]
|
|
26
|
+
project_name: typing_extensions.Annotated[str, FieldMetadata(alias="projectName")]
|
|
27
|
+
environment_name: typing_extensions.Annotated[
|
|
28
|
+
str, FieldMetadata(alias="environmentName")
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
if IS_PYDANTIC_V2:
|
|
32
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
33
|
+
extra="allow", frozen=True
|
|
34
|
+
) # type: ignore # Pydantic v2
|
|
35
|
+
else:
|
|
36
|
+
|
|
37
|
+
class Config:
|
|
38
|
+
frozen = True
|
|
39
|
+
smart_union = True
|
|
40
|
+
extra = pydantic.Extra.allow
|
|
@@ -12,21 +12,13 @@ class ApiKeysListResponseItem(UniversalBaseModel):
|
|
|
12
12
|
id: str
|
|
13
13
|
name: str
|
|
14
14
|
key_prefix: typing_extensions.Annotated[str, FieldMetadata(alias="keyPrefix")]
|
|
15
|
-
environment_id: typing_extensions.Annotated[
|
|
16
|
-
str, FieldMetadata(alias="environmentId")
|
|
17
|
-
]
|
|
15
|
+
environment_id: typing_extensions.Annotated[str, FieldMetadata(alias="environmentId")]
|
|
18
16
|
owner_id: typing_extensions.Annotated[str, FieldMetadata(alias="ownerId")]
|
|
19
|
-
created_at: typing_extensions.Annotated[
|
|
20
|
-
|
|
21
|
-
] = None
|
|
22
|
-
last_used_at: typing_extensions.Annotated[
|
|
23
|
-
typing.Optional[str], FieldMetadata(alias="lastUsedAt")
|
|
24
|
-
] = None
|
|
17
|
+
created_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="createdAt")] = None
|
|
18
|
+
last_used_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="lastUsedAt")] = None
|
|
25
19
|
|
|
26
20
|
if IS_PYDANTIC_V2:
|
|
27
|
-
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
28
|
-
extra="allow", frozen=True
|
|
29
|
-
) # type: ignore # Pydantic v2
|
|
21
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
30
22
|
else:
|
|
31
23
|
|
|
32
24
|
class Config:
|
|
@@ -3,14 +3,30 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
|
+
from .annotations.client import AnnotationsClient, AsyncAnnotationsClient
|
|
6
7
|
from .api_keys.client import ApiKeysClient, AsyncApiKeysClient
|
|
7
8
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
9
|
from .docs.client import AsyncDocsClient, DocsClient
|
|
9
10
|
from .environment import MirascopeEnvironment
|
|
10
11
|
from .environments.client import AsyncEnvironmentsClient, EnvironmentsClient
|
|
12
|
+
from .functions.client import AsyncFunctionsClient, FunctionsClient
|
|
11
13
|
from .health.client import AsyncHealthClient, HealthClient
|
|
14
|
+
from .organization_invitations.client import (
|
|
15
|
+
AsyncOrganizationInvitationsClient,
|
|
16
|
+
OrganizationInvitationsClient,
|
|
17
|
+
)
|
|
18
|
+
from .organization_memberships.client import (
|
|
19
|
+
AsyncOrganizationMembershipsClient,
|
|
20
|
+
OrganizationMembershipsClient,
|
|
21
|
+
)
|
|
12
22
|
from .organizations.client import AsyncOrganizationsClient, OrganizationsClient
|
|
23
|
+
from .project_memberships.client import (
|
|
24
|
+
AsyncProjectMembershipsClient,
|
|
25
|
+
ProjectMembershipsClient,
|
|
26
|
+
)
|
|
13
27
|
from .projects.client import AsyncProjectsClient, ProjectsClient
|
|
28
|
+
from .tags.client import AsyncTagsClient, TagsClient
|
|
29
|
+
from .token_cost.client import AsyncTokenCostClient, TokenCostClient
|
|
14
30
|
from .traces.client import AsyncTracesClient, TracesClient
|
|
15
31
|
|
|
16
32
|
|
|
@@ -79,9 +95,22 @@ class Mirascope:
|
|
|
79
95
|
self.traces = TracesClient(client_wrapper=self._client_wrapper)
|
|
80
96
|
self.docs = DocsClient(client_wrapper=self._client_wrapper)
|
|
81
97
|
self.organizations = OrganizationsClient(client_wrapper=self._client_wrapper)
|
|
98
|
+
self.organization_invitations = OrganizationInvitationsClient(
|
|
99
|
+
client_wrapper=self._client_wrapper
|
|
100
|
+
)
|
|
101
|
+
self.organization_memberships = OrganizationMembershipsClient(
|
|
102
|
+
client_wrapper=self._client_wrapper
|
|
103
|
+
)
|
|
82
104
|
self.projects = ProjectsClient(client_wrapper=self._client_wrapper)
|
|
105
|
+
self.project_memberships = ProjectMembershipsClient(
|
|
106
|
+
client_wrapper=self._client_wrapper
|
|
107
|
+
)
|
|
83
108
|
self.environments = EnvironmentsClient(client_wrapper=self._client_wrapper)
|
|
84
109
|
self.api_keys = ApiKeysClient(client_wrapper=self._client_wrapper)
|
|
110
|
+
self.functions = FunctionsClient(client_wrapper=self._client_wrapper)
|
|
111
|
+
self.annotations = AnnotationsClient(client_wrapper=self._client_wrapper)
|
|
112
|
+
self.tags = TagsClient(client_wrapper=self._client_wrapper)
|
|
113
|
+
self.token_cost = TokenCostClient(client_wrapper=self._client_wrapper)
|
|
85
114
|
|
|
86
115
|
|
|
87
116
|
class AsyncMirascope:
|
|
@@ -151,9 +180,22 @@ class AsyncMirascope:
|
|
|
151
180
|
self.organizations = AsyncOrganizationsClient(
|
|
152
181
|
client_wrapper=self._client_wrapper
|
|
153
182
|
)
|
|
183
|
+
self.organization_invitations = AsyncOrganizationInvitationsClient(
|
|
184
|
+
client_wrapper=self._client_wrapper
|
|
185
|
+
)
|
|
186
|
+
self.organization_memberships = AsyncOrganizationMembershipsClient(
|
|
187
|
+
client_wrapper=self._client_wrapper
|
|
188
|
+
)
|
|
154
189
|
self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
|
|
190
|
+
self.project_memberships = AsyncProjectMembershipsClient(
|
|
191
|
+
client_wrapper=self._client_wrapper
|
|
192
|
+
)
|
|
155
193
|
self.environments = AsyncEnvironmentsClient(client_wrapper=self._client_wrapper)
|
|
156
194
|
self.api_keys = AsyncApiKeysClient(client_wrapper=self._client_wrapper)
|
|
195
|
+
self.functions = AsyncFunctionsClient(client_wrapper=self._client_wrapper)
|
|
196
|
+
self.annotations = AsyncAnnotationsClient(client_wrapper=self._client_wrapper)
|
|
197
|
+
self.tags = AsyncTagsClient(client_wrapper=self._client_wrapper)
|
|
198
|
+
self.token_cost = AsyncTokenCostClient(client_wrapper=self._client_wrapper)
|
|
157
199
|
|
|
158
200
|
|
|
159
201
|
def _get_base_url(
|
|
@@ -25,13 +25,7 @@ class BaseClientWrapper:
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class SyncClientWrapper(BaseClientWrapper):
|
|
28
|
-
def __init__(
|
|
29
|
-
self,
|
|
30
|
-
*,
|
|
31
|
-
base_url: str,
|
|
32
|
-
timeout: typing.Optional[float] = None,
|
|
33
|
-
httpx_client: httpx.Client,
|
|
34
|
-
):
|
|
28
|
+
def __init__(self, *, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client):
|
|
35
29
|
super().__init__(base_url=base_url, timeout=timeout)
|
|
36
30
|
self.httpx_client = HttpClient(
|
|
37
31
|
httpx_client=httpx_client,
|
|
@@ -42,13 +36,7 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
|
42
36
|
|
|
43
37
|
|
|
44
38
|
class AsyncClientWrapper(BaseClientWrapper):
|
|
45
|
-
def __init__(
|
|
46
|
-
self,
|
|
47
|
-
*,
|
|
48
|
-
base_url: str,
|
|
49
|
-
timeout: typing.Optional[float] = None,
|
|
50
|
-
httpx_client: httpx.AsyncClient,
|
|
51
|
-
):
|
|
39
|
+
def __init__(self, *, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient):
|
|
52
40
|
super().__init__(base_url=base_url, timeout=timeout)
|
|
53
41
|
self.httpx_client = AsyncHttpClient(
|
|
54
42
|
httpx_client=httpx_client,
|
|
@@ -13,9 +13,7 @@ def serialize_datetime(v: dt.datetime) -> str:
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
def _serialize_zoned_datetime(v: dt.datetime) -> str:
|
|
16
|
-
if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(
|
|
17
|
-
None
|
|
18
|
-
):
|
|
16
|
+
if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
|
|
19
17
|
# UTC is a special case where we use "Z" at the end instead of "+00:00"
|
|
20
18
|
return v.isoformat().replace("+00:00", "Z")
|
|
21
19
|
else:
|
|
@@ -53,15 +53,12 @@ def with_content_type(*, file: File, default_content_type: str) -> File:
|
|
|
53
53
|
filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
|
|
54
54
|
return (filename, content, default_content_type)
|
|
55
55
|
elif len(file) == 3:
|
|
56
|
-
filename, content, file_content_type = cast(
|
|
57
|
-
Tuple[Optional[str], FileContent, Optional[str]], file
|
|
58
|
-
) # type: ignore
|
|
56
|
+
filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
|
|
59
57
|
out_content_type = file_content_type or default_content_type
|
|
60
58
|
return (filename, content, out_content_type)
|
|
61
59
|
elif len(file) == 4:
|
|
62
60
|
filename, content, file_content_type, headers = cast( # type: ignore
|
|
63
|
-
Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
|
|
64
|
-
file,
|
|
61
|
+
Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file
|
|
65
62
|
)
|
|
66
63
|
out_content_type = file_content_type or default_content_type
|
|
67
64
|
return (filename, content, out_content_type, headers)
|
|
@@ -77,9 +77,7 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float:
|
|
|
77
77
|
return retry_after
|
|
78
78
|
|
|
79
79
|
# Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS.
|
|
80
|
-
retry_delay = min(
|
|
81
|
-
INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS
|
|
82
|
-
)
|
|
80
|
+
retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS)
|
|
83
81
|
|
|
84
82
|
# Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries.
|
|
85
83
|
timeout = retry_delay * (1 - 0.25 * random())
|
|
@@ -111,8 +109,7 @@ def maybe_filter_request_body(
|
|
|
111
109
|
) -> typing.Optional[typing.Any]:
|
|
112
110
|
if data is None:
|
|
113
111
|
return (
|
|
114
|
-
jsonable_encoder(request_options.get("additional_body_parameters", {}))
|
|
115
|
-
or {}
|
|
112
|
+
jsonable_encoder(request_options.get("additional_body_parameters", {})) or {}
|
|
116
113
|
if request_options is not None
|
|
117
114
|
else None
|
|
118
115
|
)
|
|
@@ -122,8 +119,7 @@ def maybe_filter_request_body(
|
|
|
122
119
|
data_content = {
|
|
123
120
|
**(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore
|
|
124
121
|
**(
|
|
125
|
-
jsonable_encoder(request_options.get("additional_body_parameters", {}))
|
|
126
|
-
or {}
|
|
122
|
+
jsonable_encoder(request_options.get("additional_body_parameters", {})) or {}
|
|
127
123
|
if request_options is not None
|
|
128
124
|
else {}
|
|
129
125
|
),
|
|
@@ -148,9 +144,7 @@ def get_request_body(
|
|
|
148
144
|
json_body = maybe_filter_request_body(json, request_options, omit)
|
|
149
145
|
|
|
150
146
|
# If you have an empty JSON body, you should just send None
|
|
151
|
-
return (
|
|
152
|
-
json_body if json_body != {} else None
|
|
153
|
-
), data_body if data_body != {} else None
|
|
147
|
+
return (json_body if json_body != {} else None), data_body if data_body != {} else None
|
|
154
148
|
|
|
155
149
|
|
|
156
150
|
class HttpClient:
|
|
@@ -173,9 +167,7 @@ class HttpClient:
|
|
|
173
167
|
base_url = self.base_url()
|
|
174
168
|
|
|
175
169
|
if base_url is None:
|
|
176
|
-
raise ValueError(
|
|
177
|
-
"A base_url is required to make this request, please provide one and try again."
|
|
178
|
-
)
|
|
170
|
+
raise ValueError("A base_url is required to make this request, please provide one and try again.")
|
|
179
171
|
return base_url
|
|
180
172
|
|
|
181
173
|
def request(
|
|
@@ -187,14 +179,10 @@ class HttpClient:
|
|
|
187
179
|
params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
188
180
|
json: typing.Optional[typing.Any] = None,
|
|
189
181
|
data: typing.Optional[typing.Any] = None,
|
|
190
|
-
content: typing.Optional[
|
|
191
|
-
typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]
|
|
192
|
-
] = None,
|
|
182
|
+
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
193
183
|
files: typing.Optional[
|
|
194
184
|
typing.Union[
|
|
195
|
-
typing.Dict[
|
|
196
|
-
str, typing.Optional[typing.Union[File, typing.List[File]]]
|
|
197
|
-
],
|
|
185
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
198
186
|
typing.List[typing.Tuple[str, File]],
|
|
199
187
|
]
|
|
200
188
|
] = None,
|
|
@@ -207,19 +195,14 @@ class HttpClient:
|
|
|
207
195
|
base_url = self.get_base_url(base_url)
|
|
208
196
|
timeout = (
|
|
209
197
|
request_options.get("timeout_in_seconds")
|
|
210
|
-
if request_options is not None
|
|
211
|
-
and request_options.get("timeout_in_seconds") is not None
|
|
198
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
|
212
199
|
else self.base_timeout()
|
|
213
200
|
)
|
|
214
201
|
|
|
215
|
-
json_body, data_body = get_request_body(
|
|
216
|
-
json=json, data=data, request_options=request_options, omit=omit
|
|
217
|
-
)
|
|
202
|
+
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
218
203
|
|
|
219
204
|
request_files: typing.Optional[RequestFiles] = (
|
|
220
|
-
convert_file_dict_to_httpx_tuples(
|
|
221
|
-
remove_omit_from_dict(remove_none_from_dict(files), omit)
|
|
222
|
-
)
|
|
205
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
223
206
|
if (files is not None and files is not omit and isinstance(files, dict))
|
|
224
207
|
else None
|
|
225
208
|
)
|
|
@@ -235,11 +218,7 @@ class HttpClient:
|
|
|
235
218
|
{
|
|
236
219
|
**self.base_headers(),
|
|
237
220
|
**(headers if headers is not None else {}),
|
|
238
|
-
**(
|
|
239
|
-
request_options.get("additional_headers", {}) or {}
|
|
240
|
-
if request_options is not None
|
|
241
|
-
else {}
|
|
242
|
-
),
|
|
221
|
+
**(request_options.get("additional_headers", {}) or {} if request_options is not None else {}),
|
|
243
222
|
}
|
|
244
223
|
)
|
|
245
224
|
),
|
|
@@ -250,10 +229,7 @@ class HttpClient:
|
|
|
250
229
|
{
|
|
251
230
|
**(params if params is not None else {}),
|
|
252
231
|
**(
|
|
253
|
-
request_options.get(
|
|
254
|
-
"additional_query_parameters", {}
|
|
255
|
-
)
|
|
256
|
-
or {}
|
|
232
|
+
request_options.get("additional_query_parameters", {}) or {}
|
|
257
233
|
if request_options is not None
|
|
258
234
|
else {}
|
|
259
235
|
),
|
|
@@ -270,9 +246,7 @@ class HttpClient:
|
|
|
270
246
|
timeout=timeout,
|
|
271
247
|
)
|
|
272
248
|
|
|
273
|
-
max_retries: int = (
|
|
274
|
-
request_options.get("max_retries", 0) if request_options is not None else 0
|
|
275
|
-
)
|
|
249
|
+
max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0
|
|
276
250
|
if _should_retry(response=response):
|
|
277
251
|
if max_retries > retries:
|
|
278
252
|
time.sleep(_retry_timeout(response=response, retries=retries))
|
|
@@ -302,14 +276,10 @@ class HttpClient:
|
|
|
302
276
|
params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
303
277
|
json: typing.Optional[typing.Any] = None,
|
|
304
278
|
data: typing.Optional[typing.Any] = None,
|
|
305
|
-
content: typing.Optional[
|
|
306
|
-
typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]
|
|
307
|
-
] = None,
|
|
279
|
+
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
308
280
|
files: typing.Optional[
|
|
309
281
|
typing.Union[
|
|
310
|
-
typing.Dict[
|
|
311
|
-
str, typing.Optional[typing.Union[File, typing.List[File]]]
|
|
312
|
-
],
|
|
282
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
313
283
|
typing.List[typing.Tuple[str, File]],
|
|
314
284
|
]
|
|
315
285
|
] = None,
|
|
@@ -322,15 +292,12 @@ class HttpClient:
|
|
|
322
292
|
base_url = self.get_base_url(base_url)
|
|
323
293
|
timeout = (
|
|
324
294
|
request_options.get("timeout_in_seconds")
|
|
325
|
-
if request_options is not None
|
|
326
|
-
and request_options.get("timeout_in_seconds") is not None
|
|
295
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
|
327
296
|
else self.base_timeout()
|
|
328
297
|
)
|
|
329
298
|
|
|
330
299
|
request_files: typing.Optional[RequestFiles] = (
|
|
331
|
-
convert_file_dict_to_httpx_tuples(
|
|
332
|
-
remove_omit_from_dict(remove_none_from_dict(files), omit)
|
|
333
|
-
)
|
|
300
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
334
301
|
if (files is not None and files is not omit and isinstance(files, dict))
|
|
335
302
|
else None
|
|
336
303
|
)
|
|
@@ -338,9 +305,7 @@ class HttpClient:
|
|
|
338
305
|
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
339
306
|
request_files = FORCE_MULTIPART
|
|
340
307
|
|
|
341
|
-
json_body, data_body = get_request_body(
|
|
342
|
-
json=json, data=data, request_options=request_options, omit=omit
|
|
343
|
-
)
|
|
308
|
+
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
344
309
|
|
|
345
310
|
with self.httpx_client.stream(
|
|
346
311
|
method=method,
|
|
@@ -350,11 +315,7 @@ class HttpClient:
|
|
|
350
315
|
{
|
|
351
316
|
**self.base_headers(),
|
|
352
317
|
**(headers if headers is not None else {}),
|
|
353
|
-
**(
|
|
354
|
-
request_options.get("additional_headers", {})
|
|
355
|
-
if request_options is not None
|
|
356
|
-
else {}
|
|
357
|
-
),
|
|
318
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
|
358
319
|
}
|
|
359
320
|
)
|
|
360
321
|
),
|
|
@@ -365,9 +326,7 @@ class HttpClient:
|
|
|
365
326
|
{
|
|
366
327
|
**(params if params is not None else {}),
|
|
367
328
|
**(
|
|
368
|
-
request_options.get(
|
|
369
|
-
"additional_query_parameters", {}
|
|
370
|
-
)
|
|
329
|
+
request_options.get("additional_query_parameters", {})
|
|
371
330
|
if request_options is not None
|
|
372
331
|
else {}
|
|
373
332
|
),
|
|
@@ -406,9 +365,7 @@ class AsyncHttpClient:
|
|
|
406
365
|
base_url = self.base_url()
|
|
407
366
|
|
|
408
367
|
if base_url is None:
|
|
409
|
-
raise ValueError(
|
|
410
|
-
"A base_url is required to make this request, please provide one and try again."
|
|
411
|
-
)
|
|
368
|
+
raise ValueError("A base_url is required to make this request, please provide one and try again.")
|
|
412
369
|
return base_url
|
|
413
370
|
|
|
414
371
|
async def request(
|
|
@@ -420,14 +377,10 @@ class AsyncHttpClient:
|
|
|
420
377
|
params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
421
378
|
json: typing.Optional[typing.Any] = None,
|
|
422
379
|
data: typing.Optional[typing.Any] = None,
|
|
423
|
-
content: typing.Optional[
|
|
424
|
-
typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]
|
|
425
|
-
] = None,
|
|
380
|
+
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
426
381
|
files: typing.Optional[
|
|
427
382
|
typing.Union[
|
|
428
|
-
typing.Dict[
|
|
429
|
-
str, typing.Optional[typing.Union[File, typing.List[File]]]
|
|
430
|
-
],
|
|
383
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
431
384
|
typing.List[typing.Tuple[str, File]],
|
|
432
385
|
]
|
|
433
386
|
] = None,
|
|
@@ -440,15 +393,12 @@ class AsyncHttpClient:
|
|
|
440
393
|
base_url = self.get_base_url(base_url)
|
|
441
394
|
timeout = (
|
|
442
395
|
request_options.get("timeout_in_seconds")
|
|
443
|
-
if request_options is not None
|
|
444
|
-
and request_options.get("timeout_in_seconds") is not None
|
|
396
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
|
445
397
|
else self.base_timeout()
|
|
446
398
|
)
|
|
447
399
|
|
|
448
400
|
request_files: typing.Optional[RequestFiles] = (
|
|
449
|
-
convert_file_dict_to_httpx_tuples(
|
|
450
|
-
remove_omit_from_dict(remove_none_from_dict(files), omit)
|
|
451
|
-
)
|
|
401
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
452
402
|
if (files is not None and files is not omit and isinstance(files, dict))
|
|
453
403
|
else None
|
|
454
404
|
)
|
|
@@ -456,9 +406,7 @@ class AsyncHttpClient:
|
|
|
456
406
|
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
457
407
|
request_files = FORCE_MULTIPART
|
|
458
408
|
|
|
459
|
-
json_body, data_body = get_request_body(
|
|
460
|
-
json=json, data=data, request_options=request_options, omit=omit
|
|
461
|
-
)
|
|
409
|
+
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
462
410
|
|
|
463
411
|
# Add the input to each of these and do None-safety checks
|
|
464
412
|
response = await self.httpx_client.request(
|
|
@@ -469,11 +417,7 @@ class AsyncHttpClient:
|
|
|
469
417
|
{
|
|
470
418
|
**self.base_headers(),
|
|
471
419
|
**(headers if headers is not None else {}),
|
|
472
|
-
**(
|
|
473
|
-
request_options.get("additional_headers", {}) or {}
|
|
474
|
-
if request_options is not None
|
|
475
|
-
else {}
|
|
476
|
-
),
|
|
420
|
+
**(request_options.get("additional_headers", {}) or {} if request_options is not None else {}),
|
|
477
421
|
}
|
|
478
422
|
)
|
|
479
423
|
),
|
|
@@ -484,10 +428,7 @@ class AsyncHttpClient:
|
|
|
484
428
|
{
|
|
485
429
|
**(params if params is not None else {}),
|
|
486
430
|
**(
|
|
487
|
-
request_options.get(
|
|
488
|
-
"additional_query_parameters", {}
|
|
489
|
-
)
|
|
490
|
-
or {}
|
|
431
|
+
request_options.get("additional_query_parameters", {}) or {}
|
|
491
432
|
if request_options is not None
|
|
492
433
|
else {}
|
|
493
434
|
),
|
|
@@ -504,9 +445,7 @@ class AsyncHttpClient:
|
|
|
504
445
|
timeout=timeout,
|
|
505
446
|
)
|
|
506
447
|
|
|
507
|
-
max_retries: int = (
|
|
508
|
-
request_options.get("max_retries", 0) if request_options is not None else 0
|
|
509
|
-
)
|
|
448
|
+
max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0
|
|
510
449
|
if _should_retry(response=response):
|
|
511
450
|
if max_retries > retries:
|
|
512
451
|
await asyncio.sleep(_retry_timeout(response=response, retries=retries))
|
|
@@ -535,14 +474,10 @@ class AsyncHttpClient:
|
|
|
535
474
|
params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
536
475
|
json: typing.Optional[typing.Any] = None,
|
|
537
476
|
data: typing.Optional[typing.Any] = None,
|
|
538
|
-
content: typing.Optional[
|
|
539
|
-
typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]
|
|
540
|
-
] = None,
|
|
477
|
+
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
541
478
|
files: typing.Optional[
|
|
542
479
|
typing.Union[
|
|
543
|
-
typing.Dict[
|
|
544
|
-
str, typing.Optional[typing.Union[File, typing.List[File]]]
|
|
545
|
-
],
|
|
480
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
546
481
|
typing.List[typing.Tuple[str, File]],
|
|
547
482
|
]
|
|
548
483
|
] = None,
|
|
@@ -555,15 +490,12 @@ class AsyncHttpClient:
|
|
|
555
490
|
base_url = self.get_base_url(base_url)
|
|
556
491
|
timeout = (
|
|
557
492
|
request_options.get("timeout_in_seconds")
|
|
558
|
-
if request_options is not None
|
|
559
|
-
and request_options.get("timeout_in_seconds") is not None
|
|
493
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
|
560
494
|
else self.base_timeout()
|
|
561
495
|
)
|
|
562
496
|
|
|
563
497
|
request_files: typing.Optional[RequestFiles] = (
|
|
564
|
-
convert_file_dict_to_httpx_tuples(
|
|
565
|
-
remove_omit_from_dict(remove_none_from_dict(files), omit)
|
|
566
|
-
)
|
|
498
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
567
499
|
if (files is not None and files is not omit and isinstance(files, dict))
|
|
568
500
|
else None
|
|
569
501
|
)
|
|
@@ -571,9 +503,7 @@ class AsyncHttpClient:
|
|
|
571
503
|
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
572
504
|
request_files = FORCE_MULTIPART
|
|
573
505
|
|
|
574
|
-
json_body, data_body = get_request_body(
|
|
575
|
-
json=json, data=data, request_options=request_options, omit=omit
|
|
576
|
-
)
|
|
506
|
+
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
577
507
|
|
|
578
508
|
async with self.httpx_client.stream(
|
|
579
509
|
method=method,
|
|
@@ -583,11 +513,7 @@ class AsyncHttpClient:
|
|
|
583
513
|
{
|
|
584
514
|
**self.base_headers(),
|
|
585
515
|
**(headers if headers is not None else {}),
|
|
586
|
-
**(
|
|
587
|
-
request_options.get("additional_headers", {})
|
|
588
|
-
if request_options is not None
|
|
589
|
-
else {}
|
|
590
|
-
),
|
|
516
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
|
591
517
|
}
|
|
592
518
|
)
|
|
593
519
|
),
|
|
@@ -598,9 +524,7 @@ class AsyncHttpClient:
|
|
|
598
524
|
{
|
|
599
525
|
**(params if params is not None else {}),
|
|
600
526
|
**(
|
|
601
|
-
request_options.get(
|
|
602
|
-
"additional_query_parameters", {}
|
|
603
|
-
)
|
|
527
|
+
request_options.get("additional_query_parameters", {})
|
|
604
528
|
if request_options is not None
|
|
605
529
|
else {}
|
|
606
530
|
),
|
|
@@ -28,9 +28,7 @@ SetIntStr = Set[Union[int, str]]
|
|
|
28
28
|
DictIntStrAny = Dict[Union[int, str], Any]
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def jsonable_encoder(
|
|
32
|
-
obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None
|
|
33
|
-
) -> Any:
|
|
31
|
+
def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
|
|
34
32
|
custom_encoder = custom_encoder or {}
|
|
35
33
|
if custom_encoder:
|
|
36
34
|
if type(obj) in custom_encoder:
|