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
mirascope/llm/__init__.py
CHANGED
|
@@ -51,24 +51,37 @@ from .content import (
|
|
|
51
51
|
URLImageSource,
|
|
52
52
|
UserContentPart,
|
|
53
53
|
)
|
|
54
|
-
from .context import Context
|
|
54
|
+
from .context import Context, DepsT
|
|
55
55
|
from .exceptions import (
|
|
56
56
|
APIError,
|
|
57
57
|
AuthenticationError,
|
|
58
58
|
BadRequestError,
|
|
59
59
|
ConnectionError,
|
|
60
|
+
Error,
|
|
60
61
|
FeatureNotSupportedError,
|
|
61
|
-
|
|
62
|
-
MirascopeLLMError,
|
|
62
|
+
MissingAPIKeyError,
|
|
63
63
|
NoRegisteredProviderError,
|
|
64
64
|
NotFoundError,
|
|
65
|
+
ParseError,
|
|
65
66
|
PermissionError,
|
|
67
|
+
ProviderError,
|
|
66
68
|
RateLimitError,
|
|
69
|
+
ResponseValidationError,
|
|
67
70
|
ServerError,
|
|
68
71
|
TimeoutError,
|
|
72
|
+
ToolError,
|
|
73
|
+
ToolExecutionError,
|
|
69
74
|
ToolNotFoundError,
|
|
70
75
|
)
|
|
71
|
-
from .formatting import
|
|
76
|
+
from .formatting import (
|
|
77
|
+
Format,
|
|
78
|
+
FormattableT,
|
|
79
|
+
FormattingMode,
|
|
80
|
+
OutputParser,
|
|
81
|
+
Partial,
|
|
82
|
+
format,
|
|
83
|
+
output_parser,
|
|
84
|
+
)
|
|
72
85
|
from .messages import (
|
|
73
86
|
AssistantContent,
|
|
74
87
|
AssistantMessage,
|
|
@@ -78,7 +91,15 @@ from .messages import (
|
|
|
78
91
|
UserContent,
|
|
79
92
|
UserMessage,
|
|
80
93
|
)
|
|
81
|
-
from .models import
|
|
94
|
+
from .models import (
|
|
95
|
+
Model,
|
|
96
|
+
Params,
|
|
97
|
+
ThinkingConfig,
|
|
98
|
+
ThinkingLevel,
|
|
99
|
+
model,
|
|
100
|
+
model_from_context,
|
|
101
|
+
use_model,
|
|
102
|
+
)
|
|
82
103
|
from .prompts import (
|
|
83
104
|
AsyncContextPrompt,
|
|
84
105
|
AsyncPrompt,
|
|
@@ -89,13 +110,13 @@ from .prompts import (
|
|
|
89
110
|
)
|
|
90
111
|
from .providers import (
|
|
91
112
|
ModelId,
|
|
92
|
-
Params,
|
|
93
113
|
Provider,
|
|
94
114
|
ProviderId,
|
|
95
115
|
register_provider,
|
|
96
116
|
reset_provider_registry,
|
|
97
117
|
)
|
|
98
118
|
from .responses import (
|
|
119
|
+
AnyResponse,
|
|
99
120
|
AsyncChunkIterator,
|
|
100
121
|
AsyncContextResponse,
|
|
101
122
|
AsyncContextStreamResponse,
|
|
@@ -111,6 +132,7 @@ from .responses import (
|
|
|
111
132
|
FinishReason,
|
|
112
133
|
RawMessageChunk,
|
|
113
134
|
Response,
|
|
135
|
+
RootResponse,
|
|
114
136
|
Stream,
|
|
115
137
|
StreamResponse,
|
|
116
138
|
StreamResponseChunk,
|
|
@@ -121,19 +143,28 @@ from .responses import (
|
|
|
121
143
|
UsageDeltaChunk,
|
|
122
144
|
)
|
|
123
145
|
from .tools import (
|
|
146
|
+
AnyToolFn,
|
|
147
|
+
AnyToolSchema,
|
|
124
148
|
AsyncContextTool,
|
|
125
149
|
AsyncContextToolkit,
|
|
126
150
|
AsyncTool,
|
|
127
151
|
AsyncToolkit,
|
|
152
|
+
BaseToolkit,
|
|
128
153
|
ContextTool,
|
|
129
154
|
ContextToolkit,
|
|
130
155
|
Tool,
|
|
131
156
|
Toolkit,
|
|
157
|
+
ToolkitT,
|
|
158
|
+
ToolSchema,
|
|
132
159
|
tool,
|
|
133
160
|
)
|
|
161
|
+
from .types import Jsonable
|
|
134
162
|
|
|
135
163
|
__all__ = [
|
|
136
164
|
"APIError",
|
|
165
|
+
"AnyResponse",
|
|
166
|
+
"AnyToolFn",
|
|
167
|
+
"AnyToolSchema",
|
|
137
168
|
"AssistantContent",
|
|
138
169
|
"AssistantContentChunk",
|
|
139
170
|
"AssistantContentPart",
|
|
@@ -160,6 +191,7 @@ __all__ = [
|
|
|
160
191
|
"BadRequestError",
|
|
161
192
|
"Base64AudioSource",
|
|
162
193
|
"Base64ImageSource",
|
|
194
|
+
"BaseToolkit",
|
|
163
195
|
"Call",
|
|
164
196
|
"CallDecorator",
|
|
165
197
|
"ChunkIterator",
|
|
@@ -171,29 +203,37 @@ __all__ = [
|
|
|
171
203
|
"ContextStreamResponse",
|
|
172
204
|
"ContextTool",
|
|
173
205
|
"ContextToolkit",
|
|
206
|
+
"DepsT",
|
|
174
207
|
"Document",
|
|
208
|
+
"Error",
|
|
175
209
|
"FeatureNotSupportedError",
|
|
176
210
|
"FinishReason",
|
|
177
211
|
"Format",
|
|
212
|
+
"FormattableT",
|
|
178
213
|
"FormattingMode",
|
|
179
|
-
"FormattingModeNotSupportedError",
|
|
180
214
|
"Image",
|
|
215
|
+
"Jsonable",
|
|
181
216
|
"Message",
|
|
182
|
-
"
|
|
217
|
+
"MissingAPIKeyError",
|
|
183
218
|
"Model",
|
|
184
219
|
"ModelId",
|
|
185
220
|
"NoRegisteredProviderError",
|
|
186
221
|
"NotFoundError",
|
|
222
|
+
"OutputParser",
|
|
187
223
|
"Params",
|
|
224
|
+
"ParseError",
|
|
188
225
|
"Partial",
|
|
189
226
|
"PermissionError",
|
|
190
227
|
"Prompt",
|
|
191
228
|
"PromptDecorator",
|
|
192
229
|
"Provider",
|
|
230
|
+
"ProviderError",
|
|
193
231
|
"ProviderId",
|
|
194
232
|
"RateLimitError",
|
|
195
233
|
"RawMessageChunk",
|
|
196
234
|
"Response",
|
|
235
|
+
"ResponseValidationError",
|
|
236
|
+
"RootResponse",
|
|
197
237
|
"ServerError",
|
|
198
238
|
"Stream",
|
|
199
239
|
"StreamResponse",
|
|
@@ -205,6 +245,8 @@ __all__ = [
|
|
|
205
245
|
"TextEndChunk",
|
|
206
246
|
"TextStartChunk",
|
|
207
247
|
"TextStream",
|
|
248
|
+
"ThinkingConfig",
|
|
249
|
+
"ThinkingLevel",
|
|
208
250
|
"Thought",
|
|
209
251
|
"ThoughtChunk",
|
|
210
252
|
"ThoughtEndChunk",
|
|
@@ -217,9 +259,13 @@ __all__ = [
|
|
|
217
259
|
"ToolCallEndChunk",
|
|
218
260
|
"ToolCallStartChunk",
|
|
219
261
|
"ToolCallStream",
|
|
262
|
+
"ToolError",
|
|
263
|
+
"ToolExecutionError",
|
|
220
264
|
"ToolNotFoundError",
|
|
221
265
|
"ToolOutput",
|
|
266
|
+
"ToolSchema",
|
|
222
267
|
"Toolkit",
|
|
268
|
+
"ToolkitT",
|
|
223
269
|
"URLImageSource",
|
|
224
270
|
"Usage",
|
|
225
271
|
"UsageDeltaChunk",
|
|
@@ -237,6 +283,7 @@ __all__ = [
|
|
|
237
283
|
"model",
|
|
238
284
|
"model_from_context",
|
|
239
285
|
"models",
|
|
286
|
+
"output_parser",
|
|
240
287
|
"prompt",
|
|
241
288
|
"prompts",
|
|
242
289
|
"providers",
|
mirascope/llm/calls/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""The `llm.calls` module."""
|
|
2
2
|
|
|
3
|
-
from .calls import AsyncCall, AsyncContextCall, Call, ContextCall
|
|
3
|
+
from .calls import AsyncCall, AsyncContextCall, Call, CallT, ContextCall
|
|
4
4
|
from .decorator import (
|
|
5
5
|
CallDecorator,
|
|
6
6
|
call,
|
|
@@ -11,6 +11,7 @@ __all__ = [
|
|
|
11
11
|
"AsyncContextCall",
|
|
12
12
|
"Call",
|
|
13
13
|
"CallDecorator",
|
|
14
|
+
"CallT",
|
|
14
15
|
"ContextCall",
|
|
15
16
|
"call",
|
|
16
17
|
]
|
mirascope/llm/calls/calls.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""The Call module for generating responses using LLMs."""
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Generic, overload
|
|
4
|
+
from typing import Generic, TypeVar, overload
|
|
5
5
|
|
|
6
6
|
from ..context import Context, DepsT
|
|
7
7
|
from ..formatting import FormattableT
|
|
@@ -24,6 +24,8 @@ from ..responses import (
|
|
|
24
24
|
)
|
|
25
25
|
from ..types import P
|
|
26
26
|
|
|
27
|
+
CallT = TypeVar("CallT", bound="BaseCall")
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
@dataclass
|
|
29
31
|
class BaseCall:
|
mirascope/llm/calls/decorator.py
CHANGED
|
@@ -4,11 +4,11 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from collections.abc import Sequence
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import Generic, cast, overload
|
|
7
|
+
from typing import TYPE_CHECKING, Generic, cast, overload
|
|
8
8
|
from typing_extensions import Unpack
|
|
9
9
|
|
|
10
10
|
from ..context import DepsT
|
|
11
|
-
from ..formatting import Format, FormattableT
|
|
11
|
+
from ..formatting import Format, FormattableT, OutputParser
|
|
12
12
|
from ..models import Model
|
|
13
13
|
from ..prompts import (
|
|
14
14
|
AsyncContextMessageTemplate,
|
|
@@ -21,7 +21,7 @@ from ..prompts import (
|
|
|
21
21
|
Prompt,
|
|
22
22
|
_utils,
|
|
23
23
|
)
|
|
24
|
-
from ..providers import ModelId
|
|
24
|
+
from ..providers import ModelId
|
|
25
25
|
from ..tools import (
|
|
26
26
|
AsyncContextTool,
|
|
27
27
|
AsyncContextToolkit,
|
|
@@ -36,6 +36,9 @@ from ..tools import (
|
|
|
36
36
|
from ..types import P
|
|
37
37
|
from .calls import AsyncCall, AsyncContextCall, Call, ContextCall
|
|
38
38
|
|
|
39
|
+
if TYPE_CHECKING:
|
|
40
|
+
from ..models import Params
|
|
41
|
+
|
|
39
42
|
|
|
40
43
|
@dataclass(kw_only=True)
|
|
41
44
|
class CallDecorator(Generic[ToolT, FormattableT]):
|
|
@@ -58,7 +61,9 @@ class CallDecorator(Generic[ToolT, FormattableT]):
|
|
|
58
61
|
tools: Sequence[ToolT] | None
|
|
59
62
|
"""The tools that are included in the prompt, if any."""
|
|
60
63
|
|
|
61
|
-
format:
|
|
64
|
+
format: (
|
|
65
|
+
type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None
|
|
66
|
+
)
|
|
62
67
|
"""The structured output format off the prompt, if any."""
|
|
63
68
|
|
|
64
69
|
@overload
|
|
@@ -154,7 +159,10 @@ def call(
|
|
|
154
159
|
model: ModelId,
|
|
155
160
|
*,
|
|
156
161
|
tools: Sequence[ToolT] | None = None,
|
|
157
|
-
format: type[FormattableT]
|
|
162
|
+
format: type[FormattableT]
|
|
163
|
+
| Format[FormattableT]
|
|
164
|
+
| OutputParser[FormattableT]
|
|
165
|
+
| None = None,
|
|
158
166
|
**params: Unpack[Params],
|
|
159
167
|
) -> CallDecorator[ToolT, FormattableT]:
|
|
160
168
|
"""Decorator for converting prompt functions into LLM calls.
|
|
@@ -169,7 +177,10 @@ def call(
|
|
|
169
177
|
model: Model,
|
|
170
178
|
*,
|
|
171
179
|
tools: Sequence[ToolT] | None = None,
|
|
172
|
-
format: type[FormattableT]
|
|
180
|
+
format: type[FormattableT]
|
|
181
|
+
| Format[FormattableT]
|
|
182
|
+
| OutputParser[FormattableT]
|
|
183
|
+
| None = None,
|
|
173
184
|
) -> CallDecorator[ToolT, FormattableT]:
|
|
174
185
|
"""Decorator for converting prompt functions into LLM calls.
|
|
175
186
|
|
|
@@ -182,7 +193,10 @@ def call(
|
|
|
182
193
|
model: ModelId | Model,
|
|
183
194
|
*,
|
|
184
195
|
tools: Sequence[ToolT] | None = None,
|
|
185
|
-
format: type[FormattableT]
|
|
196
|
+
format: type[FormattableT]
|
|
197
|
+
| Format[FormattableT]
|
|
198
|
+
| OutputParser[FormattableT]
|
|
199
|
+
| None = None,
|
|
186
200
|
**params: Unpack[Params],
|
|
187
201
|
) -> CallDecorator[ToolT, FormattableT]:
|
|
188
202
|
"""Decorates a `MessageTemplate` to create a `Call` that can be invoked directly.
|
|
@@ -49,6 +49,9 @@ class ToolCallChunk:
|
|
|
49
49
|
content_type: Literal["tool_call"] = "tool_call"
|
|
50
50
|
"""The type of content reconstructed by this chunk."""
|
|
51
51
|
|
|
52
|
+
id: str
|
|
53
|
+
"""A unique identifier for this tool call."""
|
|
54
|
+
|
|
52
55
|
delta: str
|
|
53
56
|
"""The incremental json args added in this chunk."""
|
|
54
57
|
|
|
@@ -61,3 +64,6 @@ class ToolCallEndChunk:
|
|
|
61
64
|
|
|
62
65
|
content_type: Literal["tool_call"] = "tool_call"
|
|
63
66
|
"""The type of content reconstructed by this chunk."""
|
|
67
|
+
|
|
68
|
+
id: str
|
|
69
|
+
"""A unique identifier for this tool call."""
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"""The `ToolOutput` content class."""
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Generic, Literal
|
|
4
|
+
from typing import Generic, Literal, cast
|
|
5
5
|
|
|
6
|
-
from ..
|
|
6
|
+
from ..exceptions import ToolError
|
|
7
|
+
from ..types import JsonableCovariantT
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
@dataclass(kw_only=True)
|
|
10
|
-
class ToolOutput(Generic[
|
|
11
|
+
class ToolOutput(Generic[JsonableCovariantT]):
|
|
11
12
|
"""Tool output content for a message.
|
|
12
13
|
|
|
13
14
|
Represents the output from a tool call. This is part of a user message's
|
|
@@ -22,5 +23,21 @@ class ToolOutput(Generic[JsonableT]):
|
|
|
22
23
|
name: str
|
|
23
24
|
"""The name of the tool that created this output."""
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
"""The
|
|
26
|
+
result: JsonableCovariantT | str
|
|
27
|
+
"""The result of calling the tool.
|
|
28
|
+
|
|
29
|
+
If the tool executed successfully, this will be the tool output.
|
|
30
|
+
If the tool errored, this will be the error message, as a string.
|
|
31
|
+
|
|
32
|
+
In either case, the result should be passed back to the LLM (so it can
|
|
33
|
+
either process the output, or re-try with awareness of the error.)
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
error: ToolError | None = None
|
|
37
|
+
"""The error from calling the tool, if any."""
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def output(self) -> JsonableCovariantT:
|
|
41
|
+
if self.error is not None:
|
|
42
|
+
raise self.error
|
|
43
|
+
return cast(JsonableCovariantT, self.result)
|