mirascope 1.25.6__py3-none-any.whl → 2.0.0__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 +5 -52
- mirascope/_stubs.py +363 -0
- mirascope/api/__init__.py +14 -0
- mirascope/api/_generated/README.md +207 -0
- mirascope/api/_generated/__init__.py +440 -0
- 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 +17 -0
- mirascope/api/_generated/api_keys/client.py +530 -0
- mirascope/api/_generated/api_keys/raw_client.py +1236 -0
- mirascope/api/_generated/api_keys/types/__init__.py +15 -0
- mirascope/api/_generated/api_keys/types/api_keys_create_response.py +28 -0
- mirascope/api/_generated/api_keys/types/api_keys_get_response.py +27 -0
- 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 +27 -0
- mirascope/api/_generated/client.py +211 -0
- mirascope/api/_generated/core/__init__.py +52 -0
- mirascope/api/_generated/core/api_error.py +23 -0
- mirascope/api/_generated/core/client_wrapper.py +46 -0
- mirascope/api/_generated/core/datetime_utils.py +28 -0
- mirascope/api/_generated/core/file.py +67 -0
- mirascope/api/_generated/core/force_multipart.py +16 -0
- mirascope/api/_generated/core/http_client.py +543 -0
- mirascope/api/_generated/core/http_response.py +55 -0
- mirascope/api/_generated/core/jsonable_encoder.py +100 -0
- mirascope/api/_generated/core/pydantic_utilities.py +255 -0
- mirascope/api/_generated/core/query_encoder.py +58 -0
- mirascope/api/_generated/core/remove_none_from_dict.py +11 -0
- mirascope/api/_generated/core/request_options.py +35 -0
- mirascope/api/_generated/core/serialization.py +276 -0
- mirascope/api/_generated/docs/__init__.py +4 -0
- mirascope/api/_generated/docs/client.py +91 -0
- mirascope/api/_generated/docs/raw_client.py +178 -0
- mirascope/api/_generated/environment.py +9 -0
- mirascope/api/_generated/environments/__init__.py +23 -0
- mirascope/api/_generated/environments/client.py +649 -0
- mirascope/api/_generated/environments/raw_client.py +1567 -0
- mirascope/api/_generated/environments/types/__init__.py +25 -0
- mirascope/api/_generated/environments/types/environments_create_response.py +24 -0
- 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 +24 -0
- mirascope/api/_generated/environments/types/environments_list_response_item.py +24 -0
- mirascope/api/_generated/environments/types/environments_update_response.py +24 -0
- mirascope/api/_generated/errors/__init__.py +25 -0
- mirascope/api/_generated/errors/bad_request_error.py +14 -0
- mirascope/api/_generated/errors/conflict_error.py +14 -0
- mirascope/api/_generated/errors/forbidden_error.py +11 -0
- mirascope/api/_generated/errors/internal_server_error.py +10 -0
- mirascope/api/_generated/errors/not_found_error.py +11 -0
- 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/__init__.py +7 -0
- mirascope/api/_generated/health/client.py +92 -0
- mirascope/api/_generated/health/raw_client.py +175 -0
- mirascope/api/_generated/health/types/__init__.py +8 -0
- mirascope/api/_generated/health/types/health_check_response.py +22 -0
- mirascope/api/_generated/health/types/health_check_response_status.py +5 -0
- 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 +51 -0
- mirascope/api/_generated/organizations/client.py +869 -0
- mirascope/api/_generated/organizations/raw_client.py +2593 -0
- mirascope/api/_generated/organizations/types/__init__.py +71 -0
- mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
- mirascope/api/_generated/organizations/types/organizations_create_response.py +26 -0
- mirascope/api/_generated/organizations/types/organizations_create_response_role.py +5 -0
- mirascope/api/_generated/organizations/types/organizations_get_response.py +26 -0
- mirascope/api/_generated/organizations/types/organizations_get_response_role.py +5 -0
- mirascope/api/_generated/organizations/types/organizations_list_response_item.py +26 -0
- mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +5 -0
- 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 +26 -0
- mirascope/api/_generated/organizations/types/organizations_update_response_role.py +5 -0
- 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 +7 -0
- mirascope/api/_generated/projects/client.py +428 -0
- mirascope/api/_generated/projects/raw_client.py +1302 -0
- mirascope/api/_generated/projects/types/__init__.py +10 -0
- mirascope/api/_generated/projects/types/projects_create_response.py +25 -0
- mirascope/api/_generated/projects/types/projects_get_response.py +25 -0
- mirascope/api/_generated/projects/types/projects_list_response_item.py +25 -0
- mirascope/api/_generated/projects/types/projects_update_response.py +25 -0
- mirascope/api/_generated/reference.md +4915 -0
- 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 +97 -0
- mirascope/api/_generated/traces/client.py +1103 -0
- mirascope/api/_generated/traces/raw_client.py +2322 -0
- mirascope/api/_generated/traces/types/__init__.py +155 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +29 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +27 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +23 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +38 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +19 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +22 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +20 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +29 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +31 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +23 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +38 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +19 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +22 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +22 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +48 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +23 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +38 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +19 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +24 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +22 -0
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +20 -0
- mirascope/api/_generated/traces/types/traces_create_response.py +24 -0
- mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +22 -0
- 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 +85 -0
- mirascope/api/_generated/types/already_exists_error.py +22 -0
- mirascope/api/_generated/types/already_exists_error_tag.py +5 -0
- 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 +22 -0
- mirascope/api/_generated/types/database_error_tag.py +5 -0
- mirascope/api/_generated/types/date.py +3 -0
- mirascope/api/_generated/types/http_api_decode_error.py +27 -0
- mirascope/api/_generated/types/http_api_decode_error_tag.py +5 -0
- 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 +38 -0
- mirascope/api/_generated/types/issue_tag.py +10 -0
- mirascope/api/_generated/types/not_found_error_body.py +22 -0
- mirascope/api/_generated/types/not_found_error_tag.py +5 -0
- mirascope/api/_generated/types/number_from_string.py +3 -0
- mirascope/api/_generated/types/permission_denied_error.py +22 -0
- mirascope/api/_generated/types/permission_denied_error_tag.py +5 -0
- 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.py +7 -0
- mirascope/api/_generated/types/property_key_key.py +25 -0
- mirascope/api/_generated/types/property_key_key_tag.py +5 -0
- 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/client.py +255 -0
- mirascope/api/settings.py +99 -0
- mirascope/llm/__init__.py +290 -15
- mirascope/llm/calls/__init__.py +17 -0
- mirascope/llm/calls/calls.py +341 -0
- mirascope/llm/calls/decorator.py +275 -0
- mirascope/llm/content/__init__.py +71 -0
- mirascope/llm/content/audio.py +173 -0
- mirascope/llm/content/document.py +94 -0
- mirascope/llm/content/image.py +206 -0
- mirascope/llm/content/text.py +47 -0
- mirascope/llm/content/thought.py +58 -0
- mirascope/llm/content/tool_call.py +69 -0
- mirascope/llm/content/tool_output.py +43 -0
- mirascope/llm/context/__init__.py +6 -0
- mirascope/llm/context/_utils.py +41 -0
- mirascope/llm/context/context.py +24 -0
- mirascope/llm/exceptions.py +360 -0
- mirascope/llm/formatting/__init__.py +39 -0
- mirascope/llm/formatting/format.py +293 -0
- mirascope/llm/formatting/from_call_args.py +30 -0
- mirascope/llm/formatting/output_parser.py +178 -0
- mirascope/llm/formatting/partial.py +131 -0
- mirascope/llm/formatting/primitives.py +192 -0
- mirascope/llm/formatting/types.py +66 -0
- mirascope/llm/mcp/__init__.py +5 -0
- mirascope/llm/mcp/mcp_client.py +130 -0
- mirascope/llm/messages/__init__.py +35 -0
- mirascope/llm/messages/_utils.py +34 -0
- mirascope/llm/messages/message.py +190 -0
- mirascope/llm/models/__init__.py +21 -0
- mirascope/llm/models/models.py +1419 -0
- mirascope/llm/models/params.py +72 -0
- mirascope/llm/models/thinking_config.py +61 -0
- mirascope/llm/prompts/__init__.py +34 -0
- mirascope/llm/prompts/_utils.py +31 -0
- mirascope/llm/prompts/decorator.py +226 -0
- mirascope/llm/prompts/prompts.py +487 -0
- mirascope/llm/prompts/protocols.py +65 -0
- mirascope/llm/providers/__init__.py +62 -0
- mirascope/llm/providers/anthropic/__init__.py +11 -0
- mirascope/llm/providers/anthropic/_utils/__init__.py +27 -0
- mirascope/llm/providers/anthropic/_utils/beta_decode.py +282 -0
- mirascope/llm/providers/anthropic/_utils/beta_encode.py +266 -0
- mirascope/llm/providers/anthropic/_utils/decode.py +288 -0
- mirascope/llm/providers/anthropic/_utils/encode.py +418 -0
- mirascope/llm/providers/anthropic/_utils/errors.py +46 -0
- mirascope/llm/providers/anthropic/beta_provider.py +374 -0
- mirascope/llm/providers/anthropic/model_id.py +23 -0
- mirascope/llm/providers/anthropic/model_info.py +87 -0
- mirascope/llm/providers/anthropic/provider.py +479 -0
- mirascope/llm/providers/base/__init__.py +14 -0
- mirascope/llm/providers/base/_utils.py +253 -0
- mirascope/llm/providers/base/base_provider.py +1579 -0
- mirascope/llm/providers/base/kwargs.py +12 -0
- mirascope/llm/providers/google/__init__.py +6 -0
- mirascope/llm/providers/google/_utils/__init__.py +17 -0
- mirascope/llm/providers/google/_utils/decode.py +307 -0
- mirascope/llm/providers/google/_utils/encode.py +401 -0
- mirascope/llm/providers/google/_utils/errors.py +50 -0
- mirascope/llm/providers/google/message.py +7 -0
- mirascope/llm/providers/google/model_id.py +22 -0
- mirascope/llm/providers/google/model_info.py +63 -0
- mirascope/llm/providers/google/provider.py +492 -0
- 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 +9 -0
- mirascope/llm/providers/mlx/_utils.py +141 -0
- mirascope/llm/providers/mlx/encoding/__init__.py +8 -0
- mirascope/llm/providers/mlx/encoding/base.py +72 -0
- mirascope/llm/providers/mlx/encoding/transformers.py +150 -0
- mirascope/llm/providers/mlx/mlx.py +254 -0
- mirascope/llm/providers/mlx/model_id.py +17 -0
- mirascope/llm/providers/mlx/provider.py +452 -0
- mirascope/llm/providers/model_id.py +16 -0
- mirascope/llm/providers/ollama/__init__.py +7 -0
- mirascope/llm/providers/ollama/provider.py +71 -0
- mirascope/llm/providers/openai/__init__.py +15 -0
- mirascope/llm/providers/openai/_utils/__init__.py +5 -0
- mirascope/llm/providers/openai/_utils/errors.py +46 -0
- mirascope/llm/providers/openai/completions/__init__.py +7 -0
- mirascope/llm/providers/openai/completions/_utils/__init__.py +15 -0
- mirascope/llm/providers/openai/completions/_utils/decode.py +252 -0
- mirascope/llm/providers/openai/completions/_utils/encode.py +376 -0
- mirascope/llm/providers/openai/completions/base_provider.py +542 -0
- mirascope/llm/providers/openai/completions/provider.py +22 -0
- mirascope/llm/providers/openai/model_id.py +31 -0
- mirascope/llm/providers/openai/model_info.py +303 -0
- mirascope/llm/providers/openai/provider.py +441 -0
- mirascope/llm/providers/openai/responses/__init__.py +5 -0
- mirascope/llm/providers/openai/responses/_utils/__init__.py +15 -0
- mirascope/llm/providers/openai/responses/_utils/decode.py +260 -0
- mirascope/llm/providers/openai/responses/_utils/encode.py +384 -0
- mirascope/llm/providers/openai/responses/provider.py +513 -0
- mirascope/llm/providers/provider_id.py +24 -0
- mirascope/llm/providers/provider_registry.py +299 -0
- mirascope/llm/providers/together/__init__.py +7 -0
- mirascope/llm/providers/together/provider.py +40 -0
- mirascope/llm/responses/__init__.py +65 -0
- mirascope/llm/responses/_utils.py +146 -0
- mirascope/llm/responses/base_response.py +103 -0
- mirascope/llm/responses/base_stream_response.py +820 -0
- mirascope/llm/responses/finish_reason.py +28 -0
- mirascope/llm/responses/response.py +366 -0
- mirascope/llm/responses/root_response.py +248 -0
- mirascope/llm/responses/stream_response.py +581 -0
- mirascope/llm/responses/streams.py +363 -0
- mirascope/llm/responses/usage.py +95 -0
- mirascope/llm/tools/__init__.py +47 -0
- mirascope/llm/tools/_utils.py +34 -0
- mirascope/llm/tools/decorator.py +184 -0
- mirascope/llm/tools/protocols.py +96 -0
- mirascope/llm/tools/tool_schema.py +314 -0
- mirascope/llm/tools/toolkit.py +160 -0
- mirascope/llm/tools/tools.py +263 -0
- mirascope/llm/types/__init__.py +22 -0
- mirascope/llm/types/dataclass.py +9 -0
- mirascope/llm/types/jsonable.py +44 -0
- mirascope/llm/types/type_vars.py +19 -0
- mirascope/ops/__init__.py +111 -0
- mirascope/ops/_internal/__init__.py +5 -0
- mirascope/ops/_internal/closure.py +1169 -0
- mirascope/ops/_internal/configuration.py +177 -0
- mirascope/ops/_internal/context.py +76 -0
- mirascope/ops/_internal/exporters/__init__.py +26 -0
- mirascope/ops/_internal/exporters/exporters.py +395 -0
- mirascope/ops/_internal/exporters/processors.py +104 -0
- mirascope/ops/_internal/exporters/types.py +165 -0
- mirascope/ops/_internal/exporters/utils.py +29 -0
- mirascope/ops/_internal/instrumentation/__init__.py +8 -0
- mirascope/ops/_internal/instrumentation/llm/__init__.py +8 -0
- 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 +238 -0
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/__init__.py +38 -0
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_input_messages.py +31 -0
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_output_messages.py +38 -0
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_system_instructions.py +18 -0
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/shared.py +100 -0
- mirascope/ops/_internal/instrumentation/llm/llm.py +161 -0
- 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/propagation.py +198 -0
- mirascope/ops/_internal/protocols.py +133 -0
- mirascope/ops/_internal/session.py +139 -0
- mirascope/ops/_internal/spans.py +232 -0
- mirascope/ops/_internal/traced_calls.py +375 -0
- mirascope/ops/_internal/traced_functions.py +523 -0
- mirascope/ops/_internal/tracing.py +353 -0
- mirascope/ops/_internal/types.py +13 -0
- mirascope/ops/_internal/utils.py +123 -0
- mirascope/ops/_internal/versioned_calls.py +512 -0
- mirascope/ops/_internal/versioned_functions.py +357 -0
- mirascope/ops/_internal/versioning.py +303 -0
- mirascope/ops/exceptions.py +21 -0
- mirascope-2.0.0.dist-info/METADATA +203 -0
- mirascope-2.0.0.dist-info/RECORD +423 -0
- {mirascope-1.25.6.dist-info → mirascope-2.0.0.dist-info}/WHEEL +1 -1
- {mirascope-1.25.6.dist-info → mirascope-2.0.0.dist-info}/licenses/LICENSE +1 -1
- mirascope/beta/__init__.py +0 -3
- mirascope/beta/openai/__init__.py +0 -17
- mirascope/beta/openai/realtime/__init__.py +0 -13
- mirascope/beta/openai/realtime/_utils/__init__.py +0 -3
- mirascope/beta/openai/realtime/_utils/_audio.py +0 -74
- mirascope/beta/openai/realtime/_utils/_protocols.py +0 -50
- mirascope/beta/openai/realtime/realtime.py +0 -500
- mirascope/beta/openai/realtime/recording.py +0 -98
- mirascope/beta/openai/realtime/tool.py +0 -113
- mirascope/beta/rag/__init__.py +0 -24
- mirascope/beta/rag/base/__init__.py +0 -22
- mirascope/beta/rag/base/chunkers/__init__.py +0 -2
- mirascope/beta/rag/base/chunkers/base_chunker.py +0 -37
- mirascope/beta/rag/base/chunkers/text_chunker.py +0 -33
- mirascope/beta/rag/base/config.py +0 -8
- mirascope/beta/rag/base/document.py +0 -11
- mirascope/beta/rag/base/embedders.py +0 -35
- mirascope/beta/rag/base/embedding_params.py +0 -18
- mirascope/beta/rag/base/embedding_response.py +0 -30
- mirascope/beta/rag/base/query_results.py +0 -7
- mirascope/beta/rag/base/vectorstore_params.py +0 -18
- mirascope/beta/rag/base/vectorstores.py +0 -37
- mirascope/beta/rag/chroma/__init__.py +0 -11
- mirascope/beta/rag/chroma/types.py +0 -62
- mirascope/beta/rag/chroma/vectorstores.py +0 -121
- mirascope/beta/rag/cohere/__init__.py +0 -11
- mirascope/beta/rag/cohere/embedders.py +0 -87
- mirascope/beta/rag/cohere/embedding_params.py +0 -29
- mirascope/beta/rag/cohere/embedding_response.py +0 -29
- mirascope/beta/rag/cohere/py.typed +0 -0
- mirascope/beta/rag/openai/__init__.py +0 -11
- mirascope/beta/rag/openai/embedders.py +0 -144
- mirascope/beta/rag/openai/embedding_params.py +0 -18
- mirascope/beta/rag/openai/embedding_response.py +0 -14
- mirascope/beta/rag/openai/py.typed +0 -0
- mirascope/beta/rag/pinecone/__init__.py +0 -19
- mirascope/beta/rag/pinecone/types.py +0 -143
- mirascope/beta/rag/pinecone/vectorstores.py +0 -148
- mirascope/beta/rag/weaviate/__init__.py +0 -6
- mirascope/beta/rag/weaviate/types.py +0 -92
- mirascope/beta/rag/weaviate/vectorstores.py +0 -103
- mirascope/core/__init__.py +0 -109
- mirascope/core/anthropic/__init__.py +0 -31
- mirascope/core/anthropic/_call.py +0 -67
- mirascope/core/anthropic/_call_kwargs.py +0 -13
- mirascope/core/anthropic/_thinking.py +0 -70
- mirascope/core/anthropic/_utils/__init__.py +0 -16
- mirascope/core/anthropic/_utils/_convert_common_call_params.py +0 -25
- mirascope/core/anthropic/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -21
- mirascope/core/anthropic/_utils/_convert_message_params.py +0 -102
- mirascope/core/anthropic/_utils/_get_json_output.py +0 -31
- mirascope/core/anthropic/_utils/_handle_stream.py +0 -113
- mirascope/core/anthropic/_utils/_message_param_converter.py +0 -142
- mirascope/core/anthropic/_utils/_setup_call.py +0 -146
- mirascope/core/anthropic/call_params.py +0 -44
- mirascope/core/anthropic/call_response.py +0 -226
- mirascope/core/anthropic/call_response_chunk.py +0 -152
- mirascope/core/anthropic/dynamic_config.py +0 -40
- mirascope/core/anthropic/py.typed +0 -0
- mirascope/core/anthropic/stream.py +0 -204
- mirascope/core/anthropic/tool.py +0 -101
- mirascope/core/azure/__init__.py +0 -31
- mirascope/core/azure/_call.py +0 -67
- mirascope/core/azure/_call_kwargs.py +0 -13
- mirascope/core/azure/_utils/__init__.py +0 -14
- mirascope/core/azure/_utils/_convert_common_call_params.py +0 -26
- mirascope/core/azure/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -21
- mirascope/core/azure/_utils/_convert_message_params.py +0 -121
- mirascope/core/azure/_utils/_get_credential.py +0 -33
- mirascope/core/azure/_utils/_get_json_output.py +0 -27
- mirascope/core/azure/_utils/_handle_stream.py +0 -130
- mirascope/core/azure/_utils/_message_param_converter.py +0 -117
- mirascope/core/azure/_utils/_setup_call.py +0 -183
- mirascope/core/azure/call_params.py +0 -59
- mirascope/core/azure/call_response.py +0 -215
- mirascope/core/azure/call_response_chunk.py +0 -105
- mirascope/core/azure/dynamic_config.py +0 -30
- mirascope/core/azure/py.typed +0 -0
- mirascope/core/azure/stream.py +0 -147
- mirascope/core/azure/tool.py +0 -93
- mirascope/core/base/__init__.py +0 -86
- mirascope/core/base/_call_factory.py +0 -256
- mirascope/core/base/_create.py +0 -253
- mirascope/core/base/_extract.py +0 -175
- mirascope/core/base/_extract_with_tools.py +0 -189
- mirascope/core/base/_partial.py +0 -95
- mirascope/core/base/_utils/__init__.py +0 -92
- mirascope/core/base/_utils/_base_message_param_converter.py +0 -22
- mirascope/core/base/_utils/_base_type.py +0 -26
- mirascope/core/base/_utils/_convert_base_model_to_base_tool.py +0 -48
- mirascope/core/base/_utils/_convert_base_type_to_base_tool.py +0 -24
- mirascope/core/base/_utils/_convert_function_to_base_tool.py +0 -139
- mirascope/core/base/_utils/_convert_messages_to_message_params.py +0 -178
- mirascope/core/base/_utils/_convert_provider_finish_reason_to_finish_reason.py +0 -20
- mirascope/core/base/_utils/_default_tool_docstring.py +0 -6
- mirascope/core/base/_utils/_extract_tool_return.py +0 -42
- mirascope/core/base/_utils/_fn_is_async.py +0 -24
- mirascope/core/base/_utils/_format_template.py +0 -32
- mirascope/core/base/_utils/_get_audio_type.py +0 -18
- mirascope/core/base/_utils/_get_common_usage.py +0 -20
- mirascope/core/base/_utils/_get_create_fn_or_async_create_fn.py +0 -137
- mirascope/core/base/_utils/_get_document_type.py +0 -7
- mirascope/core/base/_utils/_get_dynamic_configuration.py +0 -69
- mirascope/core/base/_utils/_get_fields_from_call_args.py +0 -34
- mirascope/core/base/_utils/_get_fn_args.py +0 -23
- mirascope/core/base/_utils/_get_image_dimensions.py +0 -39
- mirascope/core/base/_utils/_get_image_type.py +0 -26
- mirascope/core/base/_utils/_get_metadata.py +0 -17
- mirascope/core/base/_utils/_get_possible_user_message_param.py +0 -21
- mirascope/core/base/_utils/_get_prompt_template.py +0 -28
- mirascope/core/base/_utils/_get_template_values.py +0 -51
- mirascope/core/base/_utils/_get_template_variables.py +0 -38
- mirascope/core/base/_utils/_get_unsupported_tool_config_keys.py +0 -10
- mirascope/core/base/_utils/_is_prompt_template.py +0 -24
- mirascope/core/base/_utils/_json_mode_content.py +0 -17
- mirascope/core/base/_utils/_messages_decorator.py +0 -121
- mirascope/core/base/_utils/_parse_content_template.py +0 -323
- mirascope/core/base/_utils/_parse_prompt_messages.py +0 -63
- mirascope/core/base/_utils/_pil_image_to_bytes.py +0 -13
- mirascope/core/base/_utils/_protocols.py +0 -901
- mirascope/core/base/_utils/_setup_call.py +0 -79
- mirascope/core/base/_utils/_setup_extract_tool.py +0 -30
- mirascope/core/base/call_kwargs.py +0 -13
- mirascope/core/base/call_params.py +0 -36
- mirascope/core/base/call_response.py +0 -338
- mirascope/core/base/call_response_chunk.py +0 -130
- mirascope/core/base/dynamic_config.py +0 -82
- mirascope/core/base/from_call_args.py +0 -30
- mirascope/core/base/merge_decorators.py +0 -59
- mirascope/core/base/message_param.py +0 -175
- mirascope/core/base/messages.py +0 -116
- mirascope/core/base/metadata.py +0 -13
- mirascope/core/base/prompt.py +0 -497
- mirascope/core/base/response_model_config_dict.py +0 -9
- mirascope/core/base/stream.py +0 -479
- mirascope/core/base/stream_config.py +0 -11
- mirascope/core/base/structured_stream.py +0 -296
- mirascope/core/base/tool.py +0 -214
- mirascope/core/base/toolkit.py +0 -176
- mirascope/core/base/types.py +0 -344
- mirascope/core/bedrock/__init__.py +0 -34
- mirascope/core/bedrock/_call.py +0 -68
- mirascope/core/bedrock/_call_kwargs.py +0 -12
- mirascope/core/bedrock/_types.py +0 -104
- mirascope/core/bedrock/_utils/__init__.py +0 -14
- mirascope/core/bedrock/_utils/_convert_common_call_params.py +0 -39
- mirascope/core/bedrock/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -23
- mirascope/core/bedrock/_utils/_convert_message_params.py +0 -111
- mirascope/core/bedrock/_utils/_get_json_output.py +0 -30
- mirascope/core/bedrock/_utils/_handle_stream.py +0 -104
- mirascope/core/bedrock/_utils/_message_param_converter.py +0 -172
- mirascope/core/bedrock/_utils/_setup_call.py +0 -258
- mirascope/core/bedrock/call_params.py +0 -38
- mirascope/core/bedrock/call_response.py +0 -248
- mirascope/core/bedrock/call_response_chunk.py +0 -111
- mirascope/core/bedrock/dynamic_config.py +0 -37
- mirascope/core/bedrock/py.typed +0 -0
- mirascope/core/bedrock/stream.py +0 -154
- mirascope/core/bedrock/tool.py +0 -100
- mirascope/core/cohere/__init__.py +0 -30
- mirascope/core/cohere/_call.py +0 -67
- mirascope/core/cohere/_call_kwargs.py +0 -11
- mirascope/core/cohere/_types.py +0 -20
- mirascope/core/cohere/_utils/__init__.py +0 -14
- mirascope/core/cohere/_utils/_convert_common_call_params.py +0 -26
- mirascope/core/cohere/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -24
- mirascope/core/cohere/_utils/_convert_message_params.py +0 -32
- mirascope/core/cohere/_utils/_get_json_output.py +0 -30
- mirascope/core/cohere/_utils/_handle_stream.py +0 -35
- mirascope/core/cohere/_utils/_message_param_converter.py +0 -54
- mirascope/core/cohere/_utils/_setup_call.py +0 -150
- mirascope/core/cohere/call_params.py +0 -62
- mirascope/core/cohere/call_response.py +0 -205
- mirascope/core/cohere/call_response_chunk.py +0 -125
- mirascope/core/cohere/dynamic_config.py +0 -32
- mirascope/core/cohere/py.typed +0 -0
- mirascope/core/cohere/stream.py +0 -113
- mirascope/core/cohere/tool.py +0 -93
- mirascope/core/costs/__init__.py +0 -5
- mirascope/core/costs/_anthropic_calculate_cost.py +0 -219
- mirascope/core/costs/_azure_calculate_cost.py +0 -11
- mirascope/core/costs/_bedrock_calculate_cost.py +0 -15
- mirascope/core/costs/_cohere_calculate_cost.py +0 -44
- mirascope/core/costs/_gemini_calculate_cost.py +0 -67
- mirascope/core/costs/_google_calculate_cost.py +0 -427
- mirascope/core/costs/_groq_calculate_cost.py +0 -156
- mirascope/core/costs/_litellm_calculate_cost.py +0 -11
- mirascope/core/costs/_mistral_calculate_cost.py +0 -64
- mirascope/core/costs/_openai_calculate_cost.py +0 -416
- mirascope/core/costs/_vertex_calculate_cost.py +0 -67
- mirascope/core/costs/_xai_calculate_cost.py +0 -104
- mirascope/core/costs/calculate_cost.py +0 -86
- mirascope/core/gemini/__init__.py +0 -40
- mirascope/core/gemini/_call.py +0 -67
- mirascope/core/gemini/_call_kwargs.py +0 -12
- mirascope/core/gemini/_utils/__init__.py +0 -14
- mirascope/core/gemini/_utils/_convert_common_call_params.py +0 -39
- mirascope/core/gemini/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -23
- mirascope/core/gemini/_utils/_convert_message_params.py +0 -156
- mirascope/core/gemini/_utils/_get_json_output.py +0 -35
- mirascope/core/gemini/_utils/_handle_stream.py +0 -33
- mirascope/core/gemini/_utils/_message_param_converter.py +0 -209
- mirascope/core/gemini/_utils/_setup_call.py +0 -149
- mirascope/core/gemini/call_params.py +0 -52
- mirascope/core/gemini/call_response.py +0 -216
- mirascope/core/gemini/call_response_chunk.py +0 -100
- mirascope/core/gemini/dynamic_config.py +0 -26
- mirascope/core/gemini/stream.py +0 -120
- mirascope/core/gemini/tool.py +0 -104
- mirascope/core/google/__init__.py +0 -29
- mirascope/core/google/_call.py +0 -67
- mirascope/core/google/_call_kwargs.py +0 -13
- mirascope/core/google/_utils/__init__.py +0 -14
- mirascope/core/google/_utils/_convert_common_call_params.py +0 -38
- mirascope/core/google/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -27
- mirascope/core/google/_utils/_convert_message_params.py +0 -297
- mirascope/core/google/_utils/_get_json_output.py +0 -37
- mirascope/core/google/_utils/_handle_stream.py +0 -58
- mirascope/core/google/_utils/_message_param_converter.py +0 -200
- mirascope/core/google/_utils/_setup_call.py +0 -201
- mirascope/core/google/_utils/_validate_media_type.py +0 -58
- mirascope/core/google/call_params.py +0 -22
- mirascope/core/google/call_response.py +0 -255
- mirascope/core/google/call_response_chunk.py +0 -135
- mirascope/core/google/dynamic_config.py +0 -26
- mirascope/core/google/stream.py +0 -199
- mirascope/core/google/tool.py +0 -146
- mirascope/core/groq/__init__.py +0 -30
- mirascope/core/groq/_call.py +0 -67
- mirascope/core/groq/_call_kwargs.py +0 -13
- mirascope/core/groq/_utils/__init__.py +0 -14
- mirascope/core/groq/_utils/_convert_common_call_params.py +0 -26
- mirascope/core/groq/_utils/_convert_message_params.py +0 -112
- mirascope/core/groq/_utils/_get_json_output.py +0 -27
- mirascope/core/groq/_utils/_handle_stream.py +0 -123
- mirascope/core/groq/_utils/_message_param_converter.py +0 -89
- mirascope/core/groq/_utils/_setup_call.py +0 -132
- mirascope/core/groq/call_params.py +0 -52
- mirascope/core/groq/call_response.py +0 -213
- mirascope/core/groq/call_response_chunk.py +0 -104
- mirascope/core/groq/dynamic_config.py +0 -29
- mirascope/core/groq/py.typed +0 -0
- mirascope/core/groq/stream.py +0 -135
- mirascope/core/groq/tool.py +0 -80
- mirascope/core/litellm/__init__.py +0 -28
- mirascope/core/litellm/_call.py +0 -67
- mirascope/core/litellm/_utils/__init__.py +0 -5
- mirascope/core/litellm/_utils/_setup_call.py +0 -109
- mirascope/core/litellm/call_params.py +0 -10
- mirascope/core/litellm/call_response.py +0 -24
- mirascope/core/litellm/call_response_chunk.py +0 -14
- mirascope/core/litellm/dynamic_config.py +0 -8
- mirascope/core/litellm/py.typed +0 -0
- mirascope/core/litellm/stream.py +0 -86
- mirascope/core/litellm/tool.py +0 -13
- mirascope/core/mistral/__init__.py +0 -36
- mirascope/core/mistral/_call.py +0 -65
- mirascope/core/mistral/_call_kwargs.py +0 -19
- mirascope/core/mistral/_utils/__init__.py +0 -14
- mirascope/core/mistral/_utils/_convert_common_call_params.py +0 -24
- mirascope/core/mistral/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -22
- mirascope/core/mistral/_utils/_convert_message_params.py +0 -122
- mirascope/core/mistral/_utils/_get_json_output.py +0 -34
- mirascope/core/mistral/_utils/_handle_stream.py +0 -139
- mirascope/core/mistral/_utils/_message_param_converter.py +0 -176
- mirascope/core/mistral/_utils/_setup_call.py +0 -164
- mirascope/core/mistral/call_params.py +0 -36
- mirascope/core/mistral/call_response.py +0 -205
- mirascope/core/mistral/call_response_chunk.py +0 -105
- mirascope/core/mistral/dynamic_config.py +0 -33
- mirascope/core/mistral/py.typed +0 -0
- mirascope/core/mistral/stream.py +0 -120
- mirascope/core/mistral/tool.py +0 -81
- mirascope/core/openai/__init__.py +0 -31
- mirascope/core/openai/_call.py +0 -67
- mirascope/core/openai/_call_kwargs.py +0 -13
- mirascope/core/openai/_utils/__init__.py +0 -14
- mirascope/core/openai/_utils/_convert_common_call_params.py +0 -26
- mirascope/core/openai/_utils/_convert_message_params.py +0 -148
- mirascope/core/openai/_utils/_get_json_output.py +0 -31
- mirascope/core/openai/_utils/_handle_stream.py +0 -138
- mirascope/core/openai/_utils/_message_param_converter.py +0 -105
- mirascope/core/openai/_utils/_setup_call.py +0 -155
- mirascope/core/openai/call_params.py +0 -92
- mirascope/core/openai/call_response.py +0 -273
- mirascope/core/openai/call_response_chunk.py +0 -139
- mirascope/core/openai/dynamic_config.py +0 -34
- mirascope/core/openai/py.typed +0 -0
- mirascope/core/openai/stream.py +0 -185
- mirascope/core/openai/tool.py +0 -101
- mirascope/core/py.typed +0 -0
- mirascope/core/vertex/__init__.py +0 -45
- mirascope/core/vertex/_call.py +0 -62
- mirascope/core/vertex/_call_kwargs.py +0 -12
- mirascope/core/vertex/_utils/__init__.py +0 -14
- mirascope/core/vertex/_utils/_convert_common_call_params.py +0 -37
- mirascope/core/vertex/_utils/_convert_finish_reason_to_common_finish_reasons.py +0 -23
- mirascope/core/vertex/_utils/_convert_message_params.py +0 -171
- mirascope/core/vertex/_utils/_get_json_output.py +0 -36
- mirascope/core/vertex/_utils/_handle_stream.py +0 -33
- mirascope/core/vertex/_utils/_message_param_converter.py +0 -133
- mirascope/core/vertex/_utils/_setup_call.py +0 -160
- mirascope/core/vertex/call_params.py +0 -24
- mirascope/core/vertex/call_response.py +0 -206
- mirascope/core/vertex/call_response_chunk.py +0 -99
- mirascope/core/vertex/dynamic_config.py +0 -28
- mirascope/core/vertex/stream.py +0 -119
- mirascope/core/vertex/tool.py +0 -101
- mirascope/core/xai/__init__.py +0 -28
- mirascope/core/xai/_call.py +0 -67
- mirascope/core/xai/_utils/__init__.py +0 -5
- mirascope/core/xai/_utils/_setup_call.py +0 -113
- mirascope/core/xai/call_params.py +0 -10
- mirascope/core/xai/call_response.py +0 -16
- mirascope/core/xai/call_response_chunk.py +0 -14
- mirascope/core/xai/dynamic_config.py +0 -8
- mirascope/core/xai/py.typed +0 -0
- mirascope/core/xai/stream.py +0 -57
- mirascope/core/xai/tool.py +0 -13
- mirascope/experimental/graphs/__init__.py +0 -5
- mirascope/experimental/graphs/finite_state_machine.py +0 -714
- mirascope/integrations/__init__.py +0 -16
- mirascope/integrations/_middleware_factory.py +0 -403
- mirascope/integrations/langfuse/__init__.py +0 -3
- mirascope/integrations/langfuse/_utils.py +0 -114
- mirascope/integrations/langfuse/_with_langfuse.py +0 -70
- mirascope/integrations/logfire/__init__.py +0 -3
- mirascope/integrations/logfire/_utils.py +0 -225
- mirascope/integrations/logfire/_with_logfire.py +0 -63
- mirascope/integrations/otel/__init__.py +0 -10
- mirascope/integrations/otel/_utils.py +0 -270
- mirascope/integrations/otel/_with_hyperdx.py +0 -60
- mirascope/integrations/otel/_with_otel.py +0 -59
- mirascope/integrations/tenacity.py +0 -14
- mirascope/llm/_call.py +0 -401
- mirascope/llm/_context.py +0 -384
- mirascope/llm/_override.py +0 -3639
- mirascope/llm/_protocols.py +0 -500
- mirascope/llm/_response_metaclass.py +0 -31
- mirascope/llm/call_response.py +0 -158
- mirascope/llm/call_response_chunk.py +0 -66
- mirascope/llm/stream.py +0 -162
- mirascope/llm/tool.py +0 -64
- mirascope/mcp/__init__.py +0 -7
- mirascope/mcp/_utils.py +0 -288
- mirascope/mcp/client.py +0 -167
- mirascope/mcp/server.py +0 -356
- mirascope/mcp/tools.py +0 -110
- mirascope/py.typed +0 -0
- mirascope/retries/__init__.py +0 -11
- mirascope/retries/fallback.py +0 -131
- mirascope/retries/tenacity.py +0 -50
- mirascope/tools/__init__.py +0 -37
- mirascope/tools/base.py +0 -98
- mirascope/tools/system/__init__.py +0 -0
- mirascope/tools/system/_docker_operation.py +0 -166
- mirascope/tools/system/_file_system.py +0 -267
- mirascope/tools/web/__init__.py +0 -0
- mirascope/tools/web/_duckduckgo.py +0 -111
- mirascope/tools/web/_httpx.py +0 -125
- mirascope/tools/web/_parse_url_content.py +0 -94
- mirascope/tools/web/_requests.py +0 -54
- mirascope/v0/__init__.py +0 -43
- mirascope/v0/anthropic.py +0 -54
- mirascope/v0/base/__init__.py +0 -12
- mirascope/v0/base/calls.py +0 -118
- mirascope/v0/base/extractors.py +0 -122
- mirascope/v0/base/ops_utils.py +0 -207
- mirascope/v0/base/prompts.py +0 -48
- mirascope/v0/base/types.py +0 -14
- mirascope/v0/base/utils.py +0 -21
- mirascope/v0/openai.py +0 -54
- mirascope-1.25.6.dist-info/METADATA +0 -169
- mirascope-1.25.6.dist-info/RECORD +0 -378
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"""The `extract_with_tools_factory` method."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import Awaitable, Callable
|
|
4
|
-
from functools import wraps
|
|
5
|
-
from typing import ParamSpec, TypeVar, overload
|
|
6
|
-
|
|
7
|
-
from pydantic import BaseModel
|
|
8
|
-
|
|
9
|
-
from ._create import create_factory
|
|
10
|
-
from ._utils import (
|
|
11
|
-
BaseType,
|
|
12
|
-
GetJsonOutput,
|
|
13
|
-
SameSyncAndAsyncClientSetupCall,
|
|
14
|
-
SetupCall,
|
|
15
|
-
extract_tool_return,
|
|
16
|
-
fn_is_async,
|
|
17
|
-
)
|
|
18
|
-
from ._utils._get_fields_from_call_args import get_fields_from_call_args
|
|
19
|
-
from .call_params import BaseCallParams
|
|
20
|
-
from .call_response import BaseCallResponse
|
|
21
|
-
from .dynamic_config import BaseDynamicConfig
|
|
22
|
-
from .tool import BaseTool
|
|
23
|
-
|
|
24
|
-
_BaseCallResponseT = TypeVar("_BaseCallResponseT", bound=BaseCallResponse)
|
|
25
|
-
_SameSyncAndAsyncClientT = TypeVar("_SameSyncAndAsyncClientT", contravariant=True)
|
|
26
|
-
_SyncBaseClientT = TypeVar("_SyncBaseClientT", contravariant=True)
|
|
27
|
-
_AsyncBaseClientT = TypeVar("_AsyncBaseClientT", contravariant=True)
|
|
28
|
-
_BaseDynamicConfigT = TypeVar("_BaseDynamicConfigT", bound=BaseDynamicConfig)
|
|
29
|
-
_AsyncBaseDynamicConfigT = TypeVar("_AsyncBaseDynamicConfigT", bound=BaseDynamicConfig)
|
|
30
|
-
_ParsedOutputT = TypeVar("_ParsedOutputT")
|
|
31
|
-
_BaseCallParamsT = TypeVar("_BaseCallParamsT", bound=BaseCallParams)
|
|
32
|
-
_ResponseT = TypeVar("_ResponseT")
|
|
33
|
-
_ResponseChunkT = TypeVar("_ResponseChunkT")
|
|
34
|
-
_AsyncResponseT = TypeVar("_AsyncResponseT")
|
|
35
|
-
_AsyncResponseChunkT = TypeVar("_AsyncResponseChunkT")
|
|
36
|
-
_BaseToolT = TypeVar("_BaseToolT", bound=BaseTool)
|
|
37
|
-
_ResponseModelT = TypeVar("_ResponseModelT", bound=BaseModel | BaseType)
|
|
38
|
-
_P = ParamSpec("_P")
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def extract_with_tools_factory( # noqa: ANN202
|
|
42
|
-
*,
|
|
43
|
-
TCallResponse: type[_BaseCallResponseT],
|
|
44
|
-
setup_call: SameSyncAndAsyncClientSetupCall[
|
|
45
|
-
_SameSyncAndAsyncClientT,
|
|
46
|
-
_BaseDynamicConfigT,
|
|
47
|
-
_AsyncBaseDynamicConfigT,
|
|
48
|
-
_BaseCallParamsT,
|
|
49
|
-
_ResponseT,
|
|
50
|
-
_ResponseChunkT,
|
|
51
|
-
_AsyncResponseT,
|
|
52
|
-
_AsyncResponseChunkT,
|
|
53
|
-
_BaseToolT,
|
|
54
|
-
]
|
|
55
|
-
| SetupCall[
|
|
56
|
-
_SyncBaseClientT,
|
|
57
|
-
_AsyncBaseClientT,
|
|
58
|
-
_BaseDynamicConfigT,
|
|
59
|
-
_AsyncBaseDynamicConfigT,
|
|
60
|
-
_BaseCallParamsT,
|
|
61
|
-
_ResponseT,
|
|
62
|
-
_ResponseChunkT,
|
|
63
|
-
_AsyncResponseT,
|
|
64
|
-
_AsyncResponseChunkT,
|
|
65
|
-
_BaseToolT,
|
|
66
|
-
],
|
|
67
|
-
get_json_output: GetJsonOutput[_BaseCallResponseT],
|
|
68
|
-
):
|
|
69
|
-
"""Returns the wrapped function with the provider specific interfaces."""
|
|
70
|
-
create_decorator = create_factory(
|
|
71
|
-
TCallResponse=TCallResponse, setup_call=setup_call
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
@overload
|
|
75
|
-
def decorator(
|
|
76
|
-
fn: Callable[_P, _BaseDynamicConfigT],
|
|
77
|
-
model: str,
|
|
78
|
-
tools: list[type[BaseTool] | Callable],
|
|
79
|
-
response_model: type[_ResponseModelT],
|
|
80
|
-
output_parser: Callable[[_ResponseModelT], _ParsedOutputT] | None,
|
|
81
|
-
client: _SameSyncAndAsyncClientT | _SyncBaseClientT | None,
|
|
82
|
-
call_params: _BaseCallParamsT,
|
|
83
|
-
) -> Callable[
|
|
84
|
-
_P,
|
|
85
|
-
(_ResponseModelT | _BaseCallResponseT) | (_ParsedOutputT | _BaseCallResponseT),
|
|
86
|
-
]: ...
|
|
87
|
-
|
|
88
|
-
@overload
|
|
89
|
-
def decorator(
|
|
90
|
-
fn: Callable[_P, Awaitable[_AsyncBaseDynamicConfigT]],
|
|
91
|
-
model: str,
|
|
92
|
-
tools: list[type[BaseTool] | Callable],
|
|
93
|
-
response_model: type[_ResponseModelT],
|
|
94
|
-
output_parser: Callable[[_ResponseModelT], _ParsedOutputT] | None,
|
|
95
|
-
client: _SameSyncAndAsyncClientT | _AsyncBaseClientT | None,
|
|
96
|
-
call_params: _BaseCallParamsT,
|
|
97
|
-
) -> Callable[
|
|
98
|
-
_P,
|
|
99
|
-
Awaitable[
|
|
100
|
-
(_ResponseModelT | _BaseCallResponseT)
|
|
101
|
-
| (_ParsedOutputT | _BaseCallResponseT)
|
|
102
|
-
],
|
|
103
|
-
]: ...
|
|
104
|
-
|
|
105
|
-
def decorator(
|
|
106
|
-
fn: Callable[_P, _BaseDynamicConfigT]
|
|
107
|
-
| Callable[_P, Awaitable[_AsyncBaseDynamicConfigT]],
|
|
108
|
-
model: str,
|
|
109
|
-
tools: list[type[BaseTool] | Callable],
|
|
110
|
-
response_model: type[_ResponseModelT],
|
|
111
|
-
output_parser: Callable[[_ResponseModelT], _ParsedOutputT] | None,
|
|
112
|
-
client: _SameSyncAndAsyncClientT | _SyncBaseClientT | None,
|
|
113
|
-
call_params: _BaseCallParamsT,
|
|
114
|
-
) -> Callable[
|
|
115
|
-
_P,
|
|
116
|
-
(_ResponseModelT | _BaseCallResponseT)
|
|
117
|
-
| (_ParsedOutputT | _BaseCallResponseT)
|
|
118
|
-
| Awaitable[
|
|
119
|
-
(_ResponseModelT | _BaseCallResponseT)
|
|
120
|
-
| (_ParsedOutputT | _BaseCallResponseT)
|
|
121
|
-
],
|
|
122
|
-
]:
|
|
123
|
-
fn._model = model # pyright: ignore [reportFunctionMemberAccess]
|
|
124
|
-
fn.__mirascope_call__ = True # pyright: ignore [reportFunctionMemberAccess]
|
|
125
|
-
create_decorator_kwargs = {
|
|
126
|
-
"model": model,
|
|
127
|
-
"tools": tools,
|
|
128
|
-
"response_model": response_model,
|
|
129
|
-
"output_parser": None,
|
|
130
|
-
"json_mode": True,
|
|
131
|
-
"client": client,
|
|
132
|
-
"call_params": call_params,
|
|
133
|
-
}
|
|
134
|
-
if fn_is_async(fn):
|
|
135
|
-
|
|
136
|
-
@wraps(fn)
|
|
137
|
-
async def inner_async(*args: _P.args, **kwargs: _P.kwargs) -> (
|
|
138
|
-
_ResponseModelT | _BaseCallResponseT
|
|
139
|
-
) | (_ParsedOutputT | _BaseCallResponseT):
|
|
140
|
-
call_response = await create_decorator(
|
|
141
|
-
fn=fn, **create_decorator_kwargs
|
|
142
|
-
)(*args, **kwargs)
|
|
143
|
-
try:
|
|
144
|
-
if call_response.tools:
|
|
145
|
-
return call_response
|
|
146
|
-
fields_from_call_args = get_fields_from_call_args(
|
|
147
|
-
response_model, fn, args, kwargs
|
|
148
|
-
)
|
|
149
|
-
json_output = get_json_output(call_response, True)
|
|
150
|
-
output = extract_tool_return(
|
|
151
|
-
response_model, json_output, False, fields_from_call_args
|
|
152
|
-
)
|
|
153
|
-
except Exception as e:
|
|
154
|
-
e._response = call_response # pyright: ignore [reportAttributeAccessIssue]
|
|
155
|
-
raise e
|
|
156
|
-
if isinstance(output, BaseModel):
|
|
157
|
-
output._response = call_response # pyright: ignore [reportAttributeAccessIssue]
|
|
158
|
-
return output if not output_parser else output_parser(output) # pyright: ignore [reportArgumentType, reportReturnType]
|
|
159
|
-
|
|
160
|
-
return inner_async
|
|
161
|
-
else:
|
|
162
|
-
|
|
163
|
-
@wraps(fn)
|
|
164
|
-
def inner(*args: _P.args, **kwargs: _P.kwargs) -> (
|
|
165
|
-
_ResponseModelT | _BaseCallResponseT
|
|
166
|
-
) | (_ParsedOutputT | _BaseCallResponseT):
|
|
167
|
-
call_response = create_decorator(fn=fn, **create_decorator_kwargs)(
|
|
168
|
-
*args, **kwargs
|
|
169
|
-
)
|
|
170
|
-
try:
|
|
171
|
-
if call_response.tools:
|
|
172
|
-
return call_response
|
|
173
|
-
fields_from_call_args = get_fields_from_call_args(
|
|
174
|
-
response_model, fn, args, kwargs
|
|
175
|
-
)
|
|
176
|
-
json_output = get_json_output(call_response, True)
|
|
177
|
-
output = extract_tool_return(
|
|
178
|
-
response_model, json_output, False, fields_from_call_args
|
|
179
|
-
)
|
|
180
|
-
except Exception as e:
|
|
181
|
-
e._response = call_response # pyright: ignore [reportAttributeAccessIssue]
|
|
182
|
-
raise e
|
|
183
|
-
if isinstance(output, BaseModel):
|
|
184
|
-
output._response = call_response # pyright: ignore [reportAttributeAccessIssue]
|
|
185
|
-
return output if not output_parser else output_parser(output) # pyright: ignore [reportArgumentType, reportReturnType]
|
|
186
|
-
|
|
187
|
-
return inner
|
|
188
|
-
|
|
189
|
-
return decorator
|
mirascope/core/base/_partial.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
--------------------------------------------------------------------------------
|
|
3
|
-
Source: https://github.com/pydantic/pydantic/issues/6381#issuecomment-1831607091
|
|
4
|
-
By: silviumarcu
|
|
5
|
-
|
|
6
|
-
This code is used in accordance with the repository's license, and this reference
|
|
7
|
-
serves as an acknowledgment of the original author's contribution to this project.
|
|
8
|
-
--------------------------------------------------------------------------------
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from copy import deepcopy
|
|
12
|
-
from typing import TypeVar, get_args, get_origin
|
|
13
|
-
|
|
14
|
-
from pydantic import BaseModel, create_model
|
|
15
|
-
from pydantic.fields import FieldInfo
|
|
16
|
-
|
|
17
|
-
Model = TypeVar("Model", bound=BaseModel)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _process_annotation(annotation: type) -> type:
|
|
21
|
-
"""Recursively process type annotations to make them optional."""
|
|
22
|
-
# Get the origin type (e.g., list from list[str])
|
|
23
|
-
origin = get_origin(annotation)
|
|
24
|
-
|
|
25
|
-
if origin is None:
|
|
26
|
-
# If it's a BaseModel, make it partial
|
|
27
|
-
if isinstance(annotation, type) and issubclass(annotation, BaseModel):
|
|
28
|
-
return partial(annotation) | None # pyright: ignore [reportReturnType]
|
|
29
|
-
# For simple types, just make them optional
|
|
30
|
-
return annotation | None # pyright: ignore [reportReturnType]
|
|
31
|
-
|
|
32
|
-
# Get the type arguments (e.g., str from list[str])
|
|
33
|
-
args = get_args(annotation)
|
|
34
|
-
|
|
35
|
-
# Recursively process each type argument
|
|
36
|
-
processed_args = tuple(
|
|
37
|
-
_process_annotation(arg) if isinstance(arg, type) else arg for arg in args
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
# Reconstruct the type with processed arguments
|
|
41
|
-
return (
|
|
42
|
-
origin[processed_args[0] if len(processed_args) == 1 else processed_args] | None
|
|
43
|
-
) # pyright: ignore [reportReturnType]
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def partial(
|
|
47
|
-
wrapped_class: type[Model], preserve_fields: set[str] | None = None
|
|
48
|
-
) -> type[Model]:
|
|
49
|
-
"""Generate a new class with all attributes optionals.
|
|
50
|
-
|
|
51
|
-
This decorator will wrap a class inheriting from BaseModel and will recursively
|
|
52
|
-
convert all its attributes and its children's attributes to optionals, including
|
|
53
|
-
handling generic type hints like list[Model].
|
|
54
|
-
|
|
55
|
-
Example:
|
|
56
|
-
```python
|
|
57
|
-
@partial
|
|
58
|
-
class User(BaseModel):
|
|
59
|
-
name: str
|
|
60
|
-
friends: list[Friend] # Will become list[PartialFriend] | None
|
|
61
|
-
|
|
62
|
-
user = User() # All fields optional
|
|
63
|
-
```
|
|
64
|
-
"""
|
|
65
|
-
if preserve_fields is None:
|
|
66
|
-
preserve_fields = set()
|
|
67
|
-
|
|
68
|
-
def _make_field_optional(
|
|
69
|
-
field: FieldInfo,
|
|
70
|
-
) -> tuple[object, FieldInfo]:
|
|
71
|
-
tmp_field = deepcopy(field)
|
|
72
|
-
|
|
73
|
-
# Process the field's annotation
|
|
74
|
-
tmp_field.annotation = _process_annotation(field.annotation) # pyright: ignore [reportArgumentType]
|
|
75
|
-
|
|
76
|
-
# Set default value
|
|
77
|
-
tmp_field.default = None
|
|
78
|
-
|
|
79
|
-
return tmp_field.annotation, tmp_field
|
|
80
|
-
|
|
81
|
-
return create_model(
|
|
82
|
-
f"Partial{wrapped_class.__name__}",
|
|
83
|
-
__base__=wrapped_class,
|
|
84
|
-
__module__=wrapped_class.__module__,
|
|
85
|
-
__doc__=wrapped_class.__doc__,
|
|
86
|
-
__config__=None,
|
|
87
|
-
__validators__=None,
|
|
88
|
-
__cls_kwargs__=None,
|
|
89
|
-
**{
|
|
90
|
-
field_name: (field_info.annotation, field_info)
|
|
91
|
-
if field_name in preserve_fields
|
|
92
|
-
else _make_field_optional(field_info)
|
|
93
|
-
for field_name, field_info in wrapped_class.model_fields.items()
|
|
94
|
-
},
|
|
95
|
-
)
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"""Internal Utilities."""
|
|
2
|
-
|
|
3
|
-
from ._base_message_param_converter import BaseMessageParamConverter
|
|
4
|
-
from ._base_type import BaseType, is_base_type
|
|
5
|
-
from ._convert_base_model_to_base_tool import convert_base_model_to_base_tool
|
|
6
|
-
from ._convert_base_type_to_base_tool import convert_base_type_to_base_tool
|
|
7
|
-
from ._convert_function_to_base_tool import convert_function_to_base_tool
|
|
8
|
-
from ._default_tool_docstring import DEFAULT_TOOL_DOCSTRING
|
|
9
|
-
from ._extract_tool_return import extract_tool_return
|
|
10
|
-
from ._fn_is_async import fn_is_async
|
|
11
|
-
from ._format_template import format_template
|
|
12
|
-
from ._get_audio_type import get_audio_type
|
|
13
|
-
from ._get_common_usage import get_common_usage
|
|
14
|
-
from ._get_create_fn_or_async_create_fn import get_async_create_fn, get_create_fn
|
|
15
|
-
from ._get_document_type import get_document_type
|
|
16
|
-
from ._get_dynamic_configuration import get_dynamic_configuration
|
|
17
|
-
from ._get_fn_args import get_fn_args
|
|
18
|
-
from ._get_image_dimensions import get_image_dimensions
|
|
19
|
-
from ._get_image_type import get_image_type
|
|
20
|
-
from ._get_metadata import get_metadata
|
|
21
|
-
from ._get_possible_user_message_param import get_possible_user_message_param
|
|
22
|
-
from ._get_prompt_template import get_prompt_template
|
|
23
|
-
from ._get_template_values import get_template_values
|
|
24
|
-
from ._get_template_variables import get_template_variables
|
|
25
|
-
from ._get_unsupported_tool_config_keys import get_unsupported_tool_config_keys
|
|
26
|
-
from ._is_prompt_template import is_prompt_template
|
|
27
|
-
from ._json_mode_content import json_mode_content
|
|
28
|
-
from ._messages_decorator import MessagesDecorator, messages_decorator
|
|
29
|
-
from ._parse_content_template import parse_content_template
|
|
30
|
-
from ._parse_prompt_messages import parse_prompt_messages
|
|
31
|
-
from ._pil_image_to_bytes import pil_image_to_bytes
|
|
32
|
-
from ._protocols import (
|
|
33
|
-
AsyncCreateFn,
|
|
34
|
-
CalculateCost,
|
|
35
|
-
CallDecorator,
|
|
36
|
-
CreateFn,
|
|
37
|
-
GetJsonOutput,
|
|
38
|
-
HandleStream,
|
|
39
|
-
HandleStreamAsync,
|
|
40
|
-
LLMFunctionDecorator,
|
|
41
|
-
SameSyncAndAsyncClientSetupCall,
|
|
42
|
-
SetupCall,
|
|
43
|
-
)
|
|
44
|
-
from ._setup_call import setup_call
|
|
45
|
-
from ._setup_extract_tool import setup_extract_tool
|
|
46
|
-
|
|
47
|
-
__all__ = [
|
|
48
|
-
"DEFAULT_TOOL_DOCSTRING",
|
|
49
|
-
"AsyncCreateFn",
|
|
50
|
-
"BaseMessageParamConverter",
|
|
51
|
-
"BaseType",
|
|
52
|
-
"CalculateCost",
|
|
53
|
-
"CallDecorator",
|
|
54
|
-
"CreateFn",
|
|
55
|
-
"GetJsonOutput",
|
|
56
|
-
"HandleStream",
|
|
57
|
-
"HandleStreamAsync",
|
|
58
|
-
"LLMFunctionDecorator",
|
|
59
|
-
"MessagesDecorator",
|
|
60
|
-
"SameSyncAndAsyncClientSetupCall",
|
|
61
|
-
"SetupCall",
|
|
62
|
-
"convert_base_model_to_base_tool",
|
|
63
|
-
"convert_base_type_to_base_tool",
|
|
64
|
-
"convert_function_to_base_tool",
|
|
65
|
-
"extract_tool_return",
|
|
66
|
-
"fn_is_async",
|
|
67
|
-
"format_template",
|
|
68
|
-
"get_async_create_fn",
|
|
69
|
-
"get_audio_type",
|
|
70
|
-
"get_common_usage",
|
|
71
|
-
"get_create_fn",
|
|
72
|
-
"get_document_type",
|
|
73
|
-
"get_dynamic_configuration",
|
|
74
|
-
"get_fn_args",
|
|
75
|
-
"get_image_dimensions",
|
|
76
|
-
"get_image_type",
|
|
77
|
-
"get_metadata",
|
|
78
|
-
"get_possible_user_message_param",
|
|
79
|
-
"get_prompt_template",
|
|
80
|
-
"get_template_values",
|
|
81
|
-
"get_template_variables",
|
|
82
|
-
"get_unsupported_tool_config_keys",
|
|
83
|
-
"is_base_type",
|
|
84
|
-
"is_prompt_template",
|
|
85
|
-
"json_mode_content",
|
|
86
|
-
"messages_decorator",
|
|
87
|
-
"parse_content_template",
|
|
88
|
-
"parse_prompt_messages",
|
|
89
|
-
"pil_image_to_bytes",
|
|
90
|
-
"setup_call",
|
|
91
|
-
"setup_extract_tool",
|
|
92
|
-
]
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"""Contains the BaseMessageParamConverter class."""
|
|
2
|
-
|
|
3
|
-
from abc import ABC, abstractmethod
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from mirascope.core.base.message_param import BaseMessageParam
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class BaseMessageParamConverter(ABC):
|
|
10
|
-
"""Base class for converting message params to/from provider formats."""
|
|
11
|
-
|
|
12
|
-
@staticmethod
|
|
13
|
-
@abstractmethod
|
|
14
|
-
def to_provider(message_params: list[BaseMessageParam]) -> list[Any]:
|
|
15
|
-
"""Converts base message params -> provider-specific messages."""
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
@staticmethod
|
|
19
|
-
@abstractmethod
|
|
20
|
-
def from_provider(message_params: list[Any]) -> list[BaseMessageParam]:
|
|
21
|
-
"""Converts provider-specific messages -> Base message params."""
|
|
22
|
-
pass
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"""This module contains utility functions for base types."""
|
|
2
|
-
|
|
3
|
-
import inspect
|
|
4
|
-
from enum import Enum
|
|
5
|
-
from typing import (
|
|
6
|
-
Annotated,
|
|
7
|
-
Any,
|
|
8
|
-
Literal,
|
|
9
|
-
TypeAlias,
|
|
10
|
-
Union,
|
|
11
|
-
get_origin,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
from typing_extensions import TypeIs
|
|
15
|
-
|
|
16
|
-
BaseType: TypeAlias = str | int | float | bool | bytes | list | set | tuple | dict
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def is_base_type(type_: Any) -> TypeIs[type[BaseType]]: # noqa: ANN401
|
|
20
|
-
"""Check if a type is a base type."""
|
|
21
|
-
base_types = {str, int, float, bool, bytes, list, set, tuple, dict}
|
|
22
|
-
return (
|
|
23
|
-
(inspect.isclass(type_) and issubclass(type_, Enum))
|
|
24
|
-
or type_ in base_types
|
|
25
|
-
or get_origin(type_) in base_types.union({Literal, Union, Annotated})
|
|
26
|
-
)
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"""Utility for converting a model into a base tool."""
|
|
2
|
-
|
|
3
|
-
import inspect
|
|
4
|
-
from abc import update_abstractmethods
|
|
5
|
-
from typing import Any, TypeVar, cast
|
|
6
|
-
|
|
7
|
-
from pydantic import BaseModel, create_model
|
|
8
|
-
|
|
9
|
-
from ..from_call_args import is_from_call_args
|
|
10
|
-
from ._default_tool_docstring import DEFAULT_TOOL_DOCSTRING
|
|
11
|
-
|
|
12
|
-
BaseToolT = TypeVar("BaseToolT", bound=BaseModel)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def convert_base_model_to_base_tool(
|
|
16
|
-
model: type[BaseModel], base: type[BaseToolT]
|
|
17
|
-
) -> type[BaseToolT]:
|
|
18
|
-
"""Converts a `BaseModel` schema to a `BaseToolT` type.
|
|
19
|
-
|
|
20
|
-
By adding a docstring (if needed) and passing on fields and field information in
|
|
21
|
-
dictionary format, a Pydantic `BaseModel` can be converted into an `BaseTool` for
|
|
22
|
-
performing extraction.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
model: The `BaseModel` schema to convert.
|
|
26
|
-
base: The base type to extend with the `BaseModel` fields.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
The constructed `BaseModelT` type.
|
|
30
|
-
"""
|
|
31
|
-
field_definitions = {
|
|
32
|
-
field_name: (field_info.annotation, field_info)
|
|
33
|
-
for field_name, field_info in model.model_fields.items()
|
|
34
|
-
if not is_from_call_args(field_info)
|
|
35
|
-
}
|
|
36
|
-
tool_type = create_model(
|
|
37
|
-
f"{model.__name__}",
|
|
38
|
-
__base__=base,
|
|
39
|
-
__doc__=model.__doc__ if model.__doc__ else DEFAULT_TOOL_DOCSTRING,
|
|
40
|
-
**cast(dict[str, Any], field_definitions),
|
|
41
|
-
)
|
|
42
|
-
tool_type.model_config = model.model_config | tool_type.model_config
|
|
43
|
-
bases = list(tool_type.__bases__)
|
|
44
|
-
tool_type.__bases__ = tuple(bases) if model in bases else tuple([model] + bases)
|
|
45
|
-
for name, value in inspect.getmembers(model):
|
|
46
|
-
if not hasattr(tool_type, name) or name in ["_name", "_description", "call"]:
|
|
47
|
-
setattr(tool_type, name, value)
|
|
48
|
-
return update_abstractmethods(tool_type)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"""This module contains the `convert_base_type_to_base_tool` function."""
|
|
2
|
-
|
|
3
|
-
from typing import Annotated, TypeVar, get_args, get_origin
|
|
4
|
-
|
|
5
|
-
from pydantic import BaseModel, create_model
|
|
6
|
-
|
|
7
|
-
from ._base_type import BaseType
|
|
8
|
-
from ._default_tool_docstring import DEFAULT_TOOL_DOCSTRING
|
|
9
|
-
|
|
10
|
-
BaseToolT = TypeVar("BaseToolT", bound=BaseModel)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def convert_base_type_to_base_tool(
|
|
14
|
-
schema: type[BaseType], base: type[BaseToolT]
|
|
15
|
-
) -> type[BaseToolT]:
|
|
16
|
-
"""Converts a `BaseType` to a `BaseToolT` type."""
|
|
17
|
-
if get_origin(schema) == Annotated:
|
|
18
|
-
schema.__name__ = get_args(schema)[0].__name__
|
|
19
|
-
return create_model(
|
|
20
|
-
schema.__name__,
|
|
21
|
-
__base__=base,
|
|
22
|
-
__doc__=DEFAULT_TOOL_DOCSTRING,
|
|
23
|
-
value=(schema, ...),
|
|
24
|
-
)
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import inspect
|
|
2
|
-
from abc import update_abstractmethods
|
|
3
|
-
from collections.abc import Callable
|
|
4
|
-
from typing import Any, TypeVar, cast, get_type_hints
|
|
5
|
-
|
|
6
|
-
import jiter
|
|
7
|
-
from docstring_parser import Docstring, DocstringMeta, compose, parse
|
|
8
|
-
from pydantic import BaseModel, create_model
|
|
9
|
-
from pydantic.fields import FieldInfo
|
|
10
|
-
|
|
11
|
-
from ._default_tool_docstring import DEFAULT_TOOL_DOCSTRING
|
|
12
|
-
|
|
13
|
-
BaseToolT = TypeVar("BaseToolT", bound=BaseModel)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def convert_function_to_base_tool(
|
|
17
|
-
fn: Callable,
|
|
18
|
-
base: type[BaseToolT],
|
|
19
|
-
__doc__: str | None = None,
|
|
20
|
-
__namespace__: str | None = None,
|
|
21
|
-
) -> type[BaseToolT]:
|
|
22
|
-
"""Constructs a `BaseToolT` type from the given function.
|
|
23
|
-
|
|
24
|
-
This method expects all function parameters to be properly documented in identical
|
|
25
|
-
order with identical variable names, as well as descriptions of each parameter.
|
|
26
|
-
Errors will be raised if any of these conditions are not met.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
fn: The function to convert.
|
|
30
|
-
base: The `BaseToolT` type to which the function is converted.
|
|
31
|
-
__doc__: The docstring to use for the constructed `BaseToolT` type.
|
|
32
|
-
__namespace__: The namespace to use for the constructed `BaseToolT` type.
|
|
33
|
-
|
|
34
|
-
Returns:
|
|
35
|
-
The constructed `BaseToolT` type.
|
|
36
|
-
|
|
37
|
-
Raises:
|
|
38
|
-
ValueError: if the given function's parameters don't have type annotations.
|
|
39
|
-
ValueError: if a given function's parameter is in the docstring args section but
|
|
40
|
-
the name doesn't match the docstring's parameter name.
|
|
41
|
-
ValueError: if a given function's parameter is in the docstring args section but
|
|
42
|
-
doesn't have a docstring description.
|
|
43
|
-
"""
|
|
44
|
-
docstring, examples = None, []
|
|
45
|
-
func_doc = __doc__ or fn.__doc__
|
|
46
|
-
if func_doc:
|
|
47
|
-
docstring = parse(func_doc)
|
|
48
|
-
for example in docstring.examples or []:
|
|
49
|
-
if example.description:
|
|
50
|
-
examples.append(jiter.from_json(example.description.encode()))
|
|
51
|
-
cleaned_docstring = Docstring(style=docstring.style)
|
|
52
|
-
cleaned_docstring.short_description = docstring.short_description
|
|
53
|
-
cleaned_docstring.blank_after_short_description = (
|
|
54
|
-
docstring.blank_after_short_description
|
|
55
|
-
)
|
|
56
|
-
cleaned_docstring.long_description = docstring.long_description
|
|
57
|
-
cleaned_docstring.blank_after_long_description = (
|
|
58
|
-
docstring.blank_after_long_description
|
|
59
|
-
)
|
|
60
|
-
cleaned_docstring.meta = cast(
|
|
61
|
-
list[DocstringMeta], docstring.many_returns + docstring.raises
|
|
62
|
-
)
|
|
63
|
-
func_doc = compose(cleaned_docstring)
|
|
64
|
-
|
|
65
|
-
field_definitions = {}
|
|
66
|
-
hints = get_type_hints(fn, include_extras=True)
|
|
67
|
-
has_self = False
|
|
68
|
-
for i, parameter in enumerate(inspect.signature(fn).parameters.values()):
|
|
69
|
-
if parameter.name == "self":
|
|
70
|
-
has_self = True
|
|
71
|
-
continue
|
|
72
|
-
if parameter.name == "cls":
|
|
73
|
-
continue
|
|
74
|
-
if parameter.annotation == inspect.Parameter.empty:
|
|
75
|
-
raise ValueError("All parameters must have a type annotation.")
|
|
76
|
-
|
|
77
|
-
docstring_description = None
|
|
78
|
-
if docstring and i < len(docstring.params):
|
|
79
|
-
docstring_param = docstring.params[i]
|
|
80
|
-
if docstring_param.arg_name != parameter.name:
|
|
81
|
-
raise ValueError(
|
|
82
|
-
f"Function parameter name {parameter.name} does not match docstring "
|
|
83
|
-
f"parameter name {docstring_param.arg_name}. Make sure that the "
|
|
84
|
-
"parameter names match exactly."
|
|
85
|
-
)
|
|
86
|
-
if not docstring_param.description:
|
|
87
|
-
raise ValueError("All parameters must have a description.")
|
|
88
|
-
docstring_description = docstring_param.description
|
|
89
|
-
|
|
90
|
-
field_info = FieldInfo(annotation=hints[parameter.name])
|
|
91
|
-
if parameter.default != inspect.Parameter.empty:
|
|
92
|
-
field_info.default = parameter.default
|
|
93
|
-
if docstring_description: # we check falsy here because this comes from docstr
|
|
94
|
-
field_info.description = docstring_description
|
|
95
|
-
|
|
96
|
-
param_name = parameter.name
|
|
97
|
-
if param_name.startswith("model_"): # model_ is a BaseModel reserved namespace
|
|
98
|
-
param_name = "aliased_" + param_name
|
|
99
|
-
field_info.alias = parameter.name
|
|
100
|
-
field_info.validation_alias = parameter.name
|
|
101
|
-
field_info.serialization_alias = parameter.name
|
|
102
|
-
|
|
103
|
-
field_definitions[param_name] = (
|
|
104
|
-
hints[parameter.name],
|
|
105
|
-
field_info,
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
model = create_model(
|
|
109
|
-
f"{__namespace__}_{fn.__name__}" if __namespace__ else fn.__name__,
|
|
110
|
-
__base__=base,
|
|
111
|
-
__doc__=inspect.cleandoc(func_doc) if func_doc else DEFAULT_TOOL_DOCSTRING,
|
|
112
|
-
**cast(dict[str, Any], field_definitions),
|
|
113
|
-
)
|
|
114
|
-
if examples:
|
|
115
|
-
model.model_config["json_schema_extra"] = {"examples": examples}
|
|
116
|
-
|
|
117
|
-
def call(self: base) -> Any: # pyright: ignore [reportInvalidTypeForm] # noqa: ANN401
|
|
118
|
-
return fn(
|
|
119
|
-
**(
|
|
120
|
-
({"self": self} if has_self else {})
|
|
121
|
-
| {
|
|
122
|
-
str(
|
|
123
|
-
self.model_fields[field_name].alias
|
|
124
|
-
if self.model_fields[field_name].alias
|
|
125
|
-
else field_name
|
|
126
|
-
): getattr(self, field_name)
|
|
127
|
-
for field_name in self.model_dump(exclude={"tool_call", "delta"})
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
async def call_async(self: base) -> Callable: # pyright: ignore [reportInvalidTypeForm]
|
|
133
|
-
return await call(self)
|
|
134
|
-
|
|
135
|
-
if inspect.iscoroutinefunction(fn):
|
|
136
|
-
model.call = call_async # pyright: ignore [reportAttributeAccessIssue]
|
|
137
|
-
else:
|
|
138
|
-
model.call = call # pyright: ignore [reportAttributeAccessIssue]
|
|
139
|
-
return update_abstractmethods(model)
|