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
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from typing import TypedDict
|
|
4
4
|
|
|
5
|
+
from .thinking_config import ThinkingConfig
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
class Params(TypedDict, total=False):
|
|
7
9
|
"""Common parameters shared across LLM providers.
|
|
@@ -23,8 +25,8 @@ class Params(TypedDict, total=False):
|
|
|
23
25
|
|
|
24
26
|
top_p: float
|
|
25
27
|
"""Nucleus sampling parameter (0.0 to 1.0).
|
|
26
|
-
|
|
27
|
-
Tokens are selected from the most to least probable until the sum of their
|
|
28
|
+
|
|
29
|
+
Tokens are selected from the most to least probable until the sum of their
|
|
28
30
|
probabilities equals this value. Use a lower value for less random responses and a
|
|
29
31
|
higher value for more random responses.
|
|
30
32
|
"""
|
|
@@ -41,7 +43,7 @@ class Params(TypedDict, total=False):
|
|
|
41
43
|
|
|
42
44
|
seed: int
|
|
43
45
|
"""Random seed for reproducibility.
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
When ``seed`` is fixed to a specific number, the model makes a best
|
|
46
48
|
effort to provide the same response for repeated requests.
|
|
47
49
|
|
|
@@ -50,44 +52,21 @@ class Params(TypedDict, total=False):
|
|
|
50
52
|
|
|
51
53
|
stop_sequences: list[str]
|
|
52
54
|
"""Stop sequences to end generation.
|
|
53
|
-
|
|
55
|
+
|
|
54
56
|
The model will stop generating text if one of these strings is encountered in the
|
|
55
57
|
response.
|
|
56
58
|
"""
|
|
57
59
|
|
|
58
|
-
thinking:
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
Thinking is a process where the model spends additional tokens thinking about the
|
|
62
|
-
prompt before generating a response. You may configure thinking either by passing
|
|
63
|
-
a bool to enable or disable it.
|
|
64
|
-
|
|
65
|
-
If `params.thinking` is `True`, then thinking and thought summaries will be enabled
|
|
66
|
-
(if supported by the model/provider), with a default budget for thinking tokens.
|
|
67
|
-
|
|
68
|
-
If `params.thinking` is `False`, then thinking will be wholly disabled, assuming
|
|
69
|
-
the model allows this (some models, e.g. `google:gemini-2.5-pro`, do not allow
|
|
70
|
-
disabling thinking).
|
|
71
|
-
|
|
72
|
-
If `params.thinking` is unset (or `None`), then we will use provider-specific default
|
|
73
|
-
behavior for the chosen model.
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
encode_thoughts_as_text: bool
|
|
77
|
-
"""Configures whether `Thought` content should be re-encoded as text for model consumption.
|
|
78
|
-
|
|
79
|
-
If `True`, then when an `AssistantMessage` contains `Thoughts` and is being passed back
|
|
80
|
-
to an LLM, those `Thoughts` will be encoded as `Text`, so that the assistant can read
|
|
81
|
-
those thoughts. That ensures the assistant has access to (at least the summarized output of)
|
|
82
|
-
its reasoning process, and contrasts with provider default behaviors which may ignore
|
|
83
|
-
prior thoughts, particularly if tool calls are not involved.
|
|
84
|
-
|
|
85
|
-
When `True`, we will always re-encode Mirascope messages being passed to the provider,
|
|
86
|
-
rather than reusing raw provider response content. This may disable provider-specific
|
|
87
|
-
behavior like cached reasoning tokens.
|
|
60
|
+
thinking: ThinkingConfig | None
|
|
61
|
+
"""Configuration for extended reasoning/thinking.
|
|
88
62
|
|
|
89
|
-
|
|
90
|
-
is
|
|
63
|
+
Pass a `ThinkingConfig` to configure thinking behavior. The `level` field controls
|
|
64
|
+
whether thinking is enabled and how much reasoning to use. Level may be one of
|
|
65
|
+
"minimal", "low", "medium", or "high". If level is unset, then thinking is enabled
|
|
66
|
+
with a provider-specific default level.
|
|
91
67
|
|
|
92
|
-
|
|
68
|
+
`ThinkingConfig` can also include `encode_thoughts_as_text`, which is an advanced
|
|
69
|
+
feature for providing past thoughts back to the model as text content. This is
|
|
70
|
+
primarily useful for making thoughts transferable when passing a conversation
|
|
71
|
+
to a different model or provider than the one that generated the thinking.
|
|
93
72
|
"""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Configuration for extended reasoning/thinking in LLM responses."""
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
from typing_extensions import Required, TypedDict
|
|
5
|
+
|
|
6
|
+
ThinkingLevel = Literal["none", "default", "minimal", "low", "medium", "high", "max"]
|
|
7
|
+
"""Level of effort/reasoning to apply to thinking."""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ThinkingConfig(TypedDict, total=False):
|
|
11
|
+
"""Configuration for extended reasoning/thinking in LLM responses.
|
|
12
|
+
|
|
13
|
+
Thinking is a process where the model spends additional tokens reasoning about
|
|
14
|
+
the prompt before generating a response. Providing any `ThinkingConfig` will enable
|
|
15
|
+
thinking (unless it is specifically disabled via level="minimal"). Depending on
|
|
16
|
+
the provider and model, thinking may always be active regardless of user settings.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
level: Required[ThinkingLevel]
|
|
20
|
+
"""Level of effort/reasoning to apply to thinking.
|
|
21
|
+
|
|
22
|
+
- none: Disable thinking entirely. Minimizes cost and latency.
|
|
23
|
+
- default: Use the provider's default
|
|
24
|
+
- minimal: Use the provider's lowest setting for reasoning
|
|
25
|
+
- medium: Use a moderate amount of reasoning tokens
|
|
26
|
+
- high: Allow extensive resources for thinking
|
|
27
|
+
- max: Uses as much thinking as allowed by the provider.
|
|
28
|
+
|
|
29
|
+
Mirascope makes a best effort to apply the chosen thinking level, but exact behavior
|
|
30
|
+
varies by provider and model. For example, some models may not support thinking,
|
|
31
|
+
while other models may not allow disabling it.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
include_thoughts: bool
|
|
35
|
+
"""Whether to include Thought content in the model output.
|
|
36
|
+
|
|
37
|
+
Depending on the model and provider, enabling include_thoughts to true may
|
|
38
|
+
request reasoning summaries (which are not the underlying reasoning tokens,
|
|
39
|
+
but a readable summary produced by another model), or it may be the original
|
|
40
|
+
reasoning tokens.
|
|
41
|
+
|
|
42
|
+
When include_thoughts is false, no summaries will be requested, and thoughts
|
|
43
|
+
will not be included in the output even if they were provided by the provider.
|
|
44
|
+
|
|
45
|
+
Defaults to false.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
encode_thoughts_as_text: bool
|
|
49
|
+
"""Re-encode Thought content as text for model consumption.
|
|
50
|
+
|
|
51
|
+
If `True`, when an `AssistantMessage` contains `Thoughts` and is passed back
|
|
52
|
+
to an LLM, those `Thoughts` will be encoded as `Text`, ensuring the assistant
|
|
53
|
+
can read its prior reasoning. This contrasts with provider defaults which may
|
|
54
|
+
ignore prior thoughts, particularly if tool calls are not involved.
|
|
55
|
+
|
|
56
|
+
When `True`, Mirascope will re-encode messages rather than reusing raw provider
|
|
57
|
+
response content, which may disable provider-specific optimizations like cached
|
|
58
|
+
reasoning tokens.
|
|
59
|
+
|
|
60
|
+
Defaults to `False` if unset.
|
|
61
|
+
"""
|
mirascope/llm/prompts/_utils.py
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import inspect
|
|
2
|
-
from collections.abc import Sequence
|
|
3
2
|
from typing_extensions import TypeIs
|
|
4
3
|
|
|
5
4
|
from ..context import DepsT, _utils as _context_utils
|
|
6
|
-
from ..messages import (
|
|
7
|
-
AssistantMessage,
|
|
8
|
-
Message,
|
|
9
|
-
SystemMessage,
|
|
10
|
-
UserContent,
|
|
11
|
-
UserMessage,
|
|
12
|
-
user,
|
|
13
|
-
)
|
|
14
5
|
from ..types import P
|
|
15
6
|
from .protocols import (
|
|
16
7
|
AsyncContextMessageTemplate,
|
|
@@ -20,29 +11,6 @@ from .protocols import (
|
|
|
20
11
|
)
|
|
21
12
|
|
|
22
13
|
|
|
23
|
-
def is_messages(
|
|
24
|
-
messages_or_content: Sequence[Message] | UserContent,
|
|
25
|
-
) -> TypeIs[Sequence[Message]]:
|
|
26
|
-
if isinstance(messages_or_content, list):
|
|
27
|
-
if not messages_or_content:
|
|
28
|
-
raise ValueError("Empty array may not be used as message content")
|
|
29
|
-
return isinstance(
|
|
30
|
-
messages_or_content[0], SystemMessage | UserMessage | AssistantMessage
|
|
31
|
-
)
|
|
32
|
-
return False
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def promote_to_messages(result: Sequence[Message] | UserContent) -> Sequence[Message]:
|
|
36
|
-
"""Promote a prompt result to a list of messages.
|
|
37
|
-
|
|
38
|
-
If the result is already a list of Messages, returns it as-is.
|
|
39
|
-
If the result is UserContent, wraps it in a single user message.
|
|
40
|
-
"""
|
|
41
|
-
if is_messages(result):
|
|
42
|
-
return result
|
|
43
|
-
return [user(result)]
|
|
44
|
-
|
|
45
|
-
|
|
46
14
|
def is_context_promptable(
|
|
47
15
|
fn: ContextMessageTemplate[P, DepsT]
|
|
48
16
|
| AsyncContextMessageTemplate[P, DepsT]
|
|
@@ -4,7 +4,7 @@ from collections.abc import Sequence
|
|
|
4
4
|
from typing import Generic, cast, overload
|
|
5
5
|
|
|
6
6
|
from ..context import DepsT
|
|
7
|
-
from ..formatting import Format, FormattableT
|
|
7
|
+
from ..formatting import Format, FormattableT, OutputParser
|
|
8
8
|
from ..tools import (
|
|
9
9
|
AsyncContextTool,
|
|
10
10
|
AsyncContextToolkit,
|
|
@@ -46,13 +46,18 @@ class PromptDecorator(Generic[ToolT, FormattableT]):
|
|
|
46
46
|
tools: Sequence[ToolT] | None
|
|
47
47
|
"""The tools that are included in the prompt, if any."""
|
|
48
48
|
|
|
49
|
-
format:
|
|
49
|
+
format: (
|
|
50
|
+
type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None
|
|
51
|
+
)
|
|
50
52
|
"""The structured output format off the prompt, if any."""
|
|
51
53
|
|
|
52
54
|
def __init__(
|
|
53
55
|
self,
|
|
54
56
|
tools: Sequence[ToolT] | None = None,
|
|
55
|
-
format: type[FormattableT]
|
|
57
|
+
format: type[FormattableT]
|
|
58
|
+
| Format[FormattableT]
|
|
59
|
+
| OutputParser[FormattableT]
|
|
60
|
+
| None = None,
|
|
56
61
|
) -> None:
|
|
57
62
|
"""Initialize the decorator with optional tools and format."""
|
|
58
63
|
self.tools = tools
|
|
@@ -168,7 +173,10 @@ def prompt(
|
|
|
168
173
|
def prompt(
|
|
169
174
|
*,
|
|
170
175
|
tools: Sequence[ToolT] | None = None,
|
|
171
|
-
format: type[FormattableT]
|
|
176
|
+
format: type[FormattableT]
|
|
177
|
+
| Format[FormattableT]
|
|
178
|
+
| OutputParser[FormattableT]
|
|
179
|
+
| None = None,
|
|
172
180
|
) -> PromptDecorator[ToolT, FormattableT]:
|
|
173
181
|
"""Create a decorator for Prompt functions with tools and format"""
|
|
174
182
|
|
|
@@ -181,7 +189,10 @@ def prompt(
|
|
|
181
189
|
| None = None,
|
|
182
190
|
*,
|
|
183
191
|
tools: Sequence[ToolT] | None = None,
|
|
184
|
-
format: type[FormattableT]
|
|
192
|
+
format: type[FormattableT]
|
|
193
|
+
| Format[FormattableT]
|
|
194
|
+
| OutputParser[FormattableT]
|
|
195
|
+
| None = None,
|
|
185
196
|
) -> (
|
|
186
197
|
AsyncContextPrompt[P, DepsT, FormattableT]
|
|
187
198
|
| ContextPrompt[P, DepsT, FormattableT]
|