mirascope 2.0.0__py3-none-any.whl → 2.0.0a0__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 +2 -11
- mirascope/graphs/__init__.py +22 -0
- mirascope/graphs/finite_state_machine.py +625 -0
- mirascope/llm/__init__.py +16 -101
- mirascope/llm/agents/__init__.py +15 -0
- mirascope/llm/agents/agent.py +97 -0
- mirascope/llm/agents/agent_template.py +45 -0
- mirascope/llm/agents/decorator.py +176 -0
- mirascope/llm/calls/__init__.py +1 -2
- mirascope/llm/calls/base_call.py +33 -0
- mirascope/llm/calls/calls.py +58 -84
- mirascope/llm/calls/decorator.py +120 -140
- mirascope/llm/clients/__init__.py +34 -0
- mirascope/llm/clients/anthropic/__init__.py +11 -0
- mirascope/llm/{providers/openai/completions → clients/anthropic}/_utils/__init__.py +0 -2
- mirascope/llm/{providers → clients}/anthropic/_utils/decode.py +22 -66
- mirascope/llm/clients/anthropic/_utils/encode.py +243 -0
- mirascope/llm/clients/anthropic/clients.py +819 -0
- mirascope/llm/clients/anthropic/model_ids.py +8 -0
- mirascope/llm/{providers → clients}/base/__init__.py +5 -4
- mirascope/llm/{providers → clients}/base/_utils.py +17 -78
- mirascope/llm/{providers/base/base_provider.py → clients/base/client.py} +145 -468
- mirascope/llm/{models → clients/base}/params.py +37 -16
- mirascope/llm/clients/google/__init__.py +6 -0
- mirascope/llm/{providers/openai/responses → clients/google}/_utils/__init__.py +0 -2
- mirascope/llm/{providers → clients}/google/_utils/decode.py +22 -98
- mirascope/llm/{providers → clients}/google/_utils/encode.py +46 -168
- mirascope/llm/clients/google/clients.py +853 -0
- mirascope/llm/clients/google/model_ids.py +15 -0
- mirascope/llm/clients/openai/__init__.py +25 -0
- mirascope/llm/clients/openai/completions/__init__.py +9 -0
- mirascope/llm/{providers/google → clients/openai/completions}/_utils/__init__.py +0 -4
- mirascope/llm/{providers → clients}/openai/completions/_utils/decode.py +9 -74
- mirascope/llm/{providers → clients}/openai/completions/_utils/encode.py +52 -70
- mirascope/llm/clients/openai/completions/_utils/model_features.py +81 -0
- mirascope/llm/clients/openai/completions/clients.py +833 -0
- mirascope/llm/clients/openai/completions/model_ids.py +8 -0
- mirascope/llm/clients/openai/responses/__init__.py +9 -0
- mirascope/llm/clients/openai/responses/_utils/__init__.py +13 -0
- mirascope/llm/{providers → clients}/openai/responses/_utils/decode.py +14 -80
- mirascope/llm/{providers → clients}/openai/responses/_utils/encode.py +41 -92
- mirascope/llm/clients/openai/responses/_utils/model_features.py +87 -0
- mirascope/llm/clients/openai/responses/clients.py +832 -0
- mirascope/llm/clients/openai/responses/model_ids.py +8 -0
- mirascope/llm/clients/openai/shared/__init__.py +7 -0
- mirascope/llm/clients/openai/shared/_utils.py +55 -0
- mirascope/llm/clients/providers.py +175 -0
- mirascope/llm/content/__init__.py +2 -3
- mirascope/llm/content/tool_call.py +0 -6
- mirascope/llm/content/tool_output.py +5 -22
- mirascope/llm/context/_utils.py +6 -19
- mirascope/llm/exceptions.py +43 -298
- mirascope/llm/formatting/__init__.py +2 -19
- mirascope/llm/formatting/_utils.py +74 -0
- mirascope/llm/formatting/format.py +30 -219
- mirascope/llm/formatting/from_call_args.py +2 -2
- mirascope/llm/formatting/partial.py +7 -80
- mirascope/llm/formatting/types.py +64 -21
- mirascope/llm/mcp/__init__.py +2 -2
- mirascope/llm/mcp/client.py +118 -0
- mirascope/llm/messages/__init__.py +0 -3
- mirascope/llm/messages/message.py +5 -13
- mirascope/llm/models/__init__.py +2 -7
- mirascope/llm/models/models.py +139 -315
- mirascope/llm/prompts/__init__.py +12 -13
- mirascope/llm/prompts/_utils.py +43 -14
- mirascope/llm/prompts/decorator.py +204 -144
- mirascope/llm/prompts/protocols.py +59 -25
- mirascope/llm/responses/__init__.py +1 -9
- mirascope/llm/responses/_utils.py +12 -102
- mirascope/llm/responses/base_response.py +6 -18
- mirascope/llm/responses/base_stream_response.py +50 -173
- mirascope/llm/responses/finish_reason.py +0 -1
- mirascope/llm/responses/response.py +13 -34
- mirascope/llm/responses/root_response.py +29 -100
- mirascope/llm/responses/stream_response.py +31 -40
- mirascope/llm/tools/__init__.py +2 -9
- mirascope/llm/tools/_utils.py +3 -12
- mirascope/llm/tools/decorator.py +16 -25
- mirascope/llm/tools/protocols.py +4 -4
- mirascope/llm/tools/tool_schema.py +19 -87
- mirascope/llm/tools/toolkit.py +27 -35
- mirascope/llm/tools/tools.py +41 -135
- {mirascope-2.0.0.dist-info → mirascope-2.0.0a0.dist-info}/METADATA +9 -95
- mirascope-2.0.0a0.dist-info/RECORD +101 -0
- {mirascope-2.0.0.dist-info → mirascope-2.0.0a0.dist-info}/WHEEL +1 -1
- {mirascope-2.0.0.dist-info → mirascope-2.0.0a0.dist-info}/licenses/LICENSE +1 -1
- mirascope/_stubs.py +0 -363
- mirascope/api/__init__.py +0 -14
- mirascope/api/_generated/README.md +0 -207
- mirascope/api/_generated/__init__.py +0 -440
- mirascope/api/_generated/annotations/__init__.py +0 -33
- mirascope/api/_generated/annotations/client.py +0 -506
- mirascope/api/_generated/annotations/raw_client.py +0 -1414
- mirascope/api/_generated/annotations/types/__init__.py +0 -31
- mirascope/api/_generated/annotations/types/annotations_create_request_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_create_response.py +0 -48
- mirascope/api/_generated/annotations/types/annotations_create_response_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_get_response.py +0 -48
- mirascope/api/_generated/annotations/types/annotations_get_response_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_list_request_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_list_response.py +0 -21
- mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +0 -50
- mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_update_request_label.py +0 -5
- mirascope/api/_generated/annotations/types/annotations_update_response.py +0 -48
- mirascope/api/_generated/annotations/types/annotations_update_response_label.py +0 -5
- mirascope/api/_generated/api_keys/__init__.py +0 -17
- mirascope/api/_generated/api_keys/client.py +0 -530
- mirascope/api/_generated/api_keys/raw_client.py +0 -1236
- mirascope/api/_generated/api_keys/types/__init__.py +0 -15
- mirascope/api/_generated/api_keys/types/api_keys_create_response.py +0 -28
- mirascope/api/_generated/api_keys/types/api_keys_get_response.py +0 -27
- mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +0 -40
- mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +0 -27
- mirascope/api/_generated/client.py +0 -211
- mirascope/api/_generated/core/__init__.py +0 -52
- mirascope/api/_generated/core/api_error.py +0 -23
- mirascope/api/_generated/core/client_wrapper.py +0 -46
- mirascope/api/_generated/core/datetime_utils.py +0 -28
- mirascope/api/_generated/core/file.py +0 -67
- mirascope/api/_generated/core/force_multipart.py +0 -16
- mirascope/api/_generated/core/http_client.py +0 -543
- mirascope/api/_generated/core/http_response.py +0 -55
- mirascope/api/_generated/core/jsonable_encoder.py +0 -100
- mirascope/api/_generated/core/pydantic_utilities.py +0 -255
- mirascope/api/_generated/core/query_encoder.py +0 -58
- mirascope/api/_generated/core/remove_none_from_dict.py +0 -11
- mirascope/api/_generated/core/request_options.py +0 -35
- mirascope/api/_generated/core/serialization.py +0 -276
- mirascope/api/_generated/docs/__init__.py +0 -4
- mirascope/api/_generated/docs/client.py +0 -91
- mirascope/api/_generated/docs/raw_client.py +0 -178
- mirascope/api/_generated/environment.py +0 -9
- mirascope/api/_generated/environments/__init__.py +0 -23
- mirascope/api/_generated/environments/client.py +0 -649
- mirascope/api/_generated/environments/raw_client.py +0 -1567
- mirascope/api/_generated/environments/types/__init__.py +0 -25
- mirascope/api/_generated/environments/types/environments_create_response.py +0 -24
- mirascope/api/_generated/environments/types/environments_get_analytics_response.py +0 -60
- mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +0 -24
- mirascope/api/_generated/environments/types/environments_get_analytics_response_top_models_item.py +0 -22
- mirascope/api/_generated/environments/types/environments_get_response.py +0 -24
- mirascope/api/_generated/environments/types/environments_list_response_item.py +0 -24
- mirascope/api/_generated/environments/types/environments_update_response.py +0 -24
- mirascope/api/_generated/errors/__init__.py +0 -25
- mirascope/api/_generated/errors/bad_request_error.py +0 -14
- mirascope/api/_generated/errors/conflict_error.py +0 -14
- mirascope/api/_generated/errors/forbidden_error.py +0 -11
- mirascope/api/_generated/errors/internal_server_error.py +0 -10
- mirascope/api/_generated/errors/not_found_error.py +0 -11
- mirascope/api/_generated/errors/payment_required_error.py +0 -15
- mirascope/api/_generated/errors/service_unavailable_error.py +0 -14
- mirascope/api/_generated/errors/too_many_requests_error.py +0 -15
- mirascope/api/_generated/errors/unauthorized_error.py +0 -11
- mirascope/api/_generated/functions/__init__.py +0 -39
- mirascope/api/_generated/functions/client.py +0 -647
- mirascope/api/_generated/functions/raw_client.py +0 -1890
- mirascope/api/_generated/functions/types/__init__.py +0 -53
- mirascope/api/_generated/functions/types/functions_create_request_dependencies_value.py +0 -20
- mirascope/api/_generated/functions/types/functions_create_response.py +0 -37
- mirascope/api/_generated/functions/types/functions_create_response_dependencies_value.py +0 -20
- mirascope/api/_generated/functions/types/functions_find_by_hash_response.py +0 -39
- mirascope/api/_generated/functions/types/functions_find_by_hash_response_dependencies_value.py +0 -20
- mirascope/api/_generated/functions/types/functions_get_by_env_response.py +0 -53
- mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +0 -22
- mirascope/api/_generated/functions/types/functions_get_response.py +0 -37
- mirascope/api/_generated/functions/types/functions_get_response_dependencies_value.py +0 -20
- mirascope/api/_generated/functions/types/functions_list_by_env_response.py +0 -25
- mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +0 -56
- mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +0 -22
- mirascope/api/_generated/functions/types/functions_list_response.py +0 -21
- mirascope/api/_generated/functions/types/functions_list_response_functions_item.py +0 -41
- mirascope/api/_generated/functions/types/functions_list_response_functions_item_dependencies_value.py +0 -20
- mirascope/api/_generated/health/__init__.py +0 -7
- mirascope/api/_generated/health/client.py +0 -92
- mirascope/api/_generated/health/raw_client.py +0 -175
- mirascope/api/_generated/health/types/__init__.py +0 -8
- mirascope/api/_generated/health/types/health_check_response.py +0 -22
- mirascope/api/_generated/health/types/health_check_response_status.py +0 -5
- mirascope/api/_generated/organization_invitations/__init__.py +0 -33
- mirascope/api/_generated/organization_invitations/client.py +0 -546
- mirascope/api/_generated/organization_invitations/raw_client.py +0 -1519
- mirascope/api/_generated/organization_invitations/types/__init__.py +0 -53
- mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +0 -34
- mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +0 -48
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +0 -48
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +0 -48
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +0 -7
- mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +0 -7
- mirascope/api/_generated/organization_memberships/__init__.py +0 -19
- mirascope/api/_generated/organization_memberships/client.py +0 -302
- mirascope/api/_generated/organization_memberships/raw_client.py +0 -736
- mirascope/api/_generated/organization_memberships/types/__init__.py +0 -27
- mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +0 -33
- mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +0 -7
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +0 -7
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +0 -31
- mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +0 -7
- mirascope/api/_generated/organizations/__init__.py +0 -51
- mirascope/api/_generated/organizations/client.py +0 -869
- mirascope/api/_generated/organizations/raw_client.py +0 -2593
- mirascope/api/_generated/organizations/types/__init__.py +0 -71
- mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +0 -24
- mirascope/api/_generated/organizations/types/organizations_create_response.py +0 -26
- mirascope/api/_generated/organizations/types/organizations_create_response_role.py +0 -5
- mirascope/api/_generated/organizations/types/organizations_get_response.py +0 -26
- mirascope/api/_generated/organizations/types/organizations_get_response_role.py +0 -5
- mirascope/api/_generated/organizations/types/organizations_list_response_item.py +0 -26
- mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +0 -5
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +0 -7
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +0 -47
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +0 -33
- mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +0 -7
- mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +0 -24
- mirascope/api/_generated/organizations/types/organizations_subscription_response.py +0 -53
- mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +0 -7
- mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +0 -26
- mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +0 -34
- mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +0 -7
- mirascope/api/_generated/organizations/types/organizations_update_response.py +0 -26
- mirascope/api/_generated/organizations/types/organizations_update_response_role.py +0 -5
- mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +0 -7
- mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +0 -35
- mirascope/api/_generated/project_memberships/__init__.py +0 -25
- mirascope/api/_generated/project_memberships/client.py +0 -437
- mirascope/api/_generated/project_memberships/raw_client.py +0 -1039
- mirascope/api/_generated/project_memberships/types/__init__.py +0 -29
- mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +0 -7
- mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +0 -35
- mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +0 -7
- mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +0 -33
- mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +0 -7
- mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +0 -7
- mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +0 -35
- mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +0 -7
- mirascope/api/_generated/projects/__init__.py +0 -7
- mirascope/api/_generated/projects/client.py +0 -428
- mirascope/api/_generated/projects/raw_client.py +0 -1302
- mirascope/api/_generated/projects/types/__init__.py +0 -10
- mirascope/api/_generated/projects/types/projects_create_response.py +0 -25
- mirascope/api/_generated/projects/types/projects_get_response.py +0 -25
- mirascope/api/_generated/projects/types/projects_list_response_item.py +0 -25
- mirascope/api/_generated/projects/types/projects_update_response.py +0 -25
- mirascope/api/_generated/reference.md +0 -4915
- mirascope/api/_generated/tags/__init__.py +0 -19
- mirascope/api/_generated/tags/client.py +0 -504
- mirascope/api/_generated/tags/raw_client.py +0 -1288
- mirascope/api/_generated/tags/types/__init__.py +0 -17
- mirascope/api/_generated/tags/types/tags_create_response.py +0 -41
- mirascope/api/_generated/tags/types/tags_get_response.py +0 -41
- mirascope/api/_generated/tags/types/tags_list_response.py +0 -23
- mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +0 -41
- mirascope/api/_generated/tags/types/tags_update_response.py +0 -41
- mirascope/api/_generated/token_cost/__init__.py +0 -7
- mirascope/api/_generated/token_cost/client.py +0 -160
- mirascope/api/_generated/token_cost/raw_client.py +0 -264
- mirascope/api/_generated/token_cost/types/__init__.py +0 -8
- mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +0 -54
- mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +0 -52
- mirascope/api/_generated/traces/__init__.py +0 -97
- mirascope/api/_generated/traces/client.py +0 -1103
- mirascope/api/_generated/traces/raw_client.py +0 -2322
- mirascope/api/_generated/traces/types/__init__.py +0 -155
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +0 -29
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +0 -27
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +0 -23
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +0 -38
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +0 -19
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +0 -22
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +0 -20
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +0 -29
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +0 -31
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +0 -23
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +0 -38
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +0 -19
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +0 -22
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +0 -22
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +0 -48
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +0 -23
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +0 -38
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +0 -19
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +0 -24
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +0 -22
- mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +0 -20
- mirascope/api/_generated/traces/types/traces_create_response.py +0 -24
- mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +0 -22
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +0 -60
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_functions_item.py +0 -24
- mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_models_item.py +0 -22
- mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +0 -33
- mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +0 -88
- mirascope/api/_generated/traces/types/traces_get_trace_detail_response.py +0 -33
- mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +0 -88
- mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +0 -25
- mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +0 -44
- mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +0 -26
- mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +0 -7
- mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +0 -7
- mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +0 -7
- mirascope/api/_generated/traces/types/traces_search_by_env_response.py +0 -26
- mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +0 -50
- mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item.py +0 -26
- mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item_operator.py +0 -7
- mirascope/api/_generated/traces/types/traces_search_request_sort_by.py +0 -7
- mirascope/api/_generated/traces/types/traces_search_request_sort_order.py +0 -5
- mirascope/api/_generated/traces/types/traces_search_response.py +0 -26
- mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +0 -50
- mirascope/api/_generated/types/__init__.py +0 -85
- mirascope/api/_generated/types/already_exists_error.py +0 -22
- mirascope/api/_generated/types/already_exists_error_tag.py +0 -5
- mirascope/api/_generated/types/bad_request_error_body.py +0 -50
- mirascope/api/_generated/types/click_house_error.py +0 -22
- mirascope/api/_generated/types/database_error.py +0 -22
- mirascope/api/_generated/types/database_error_tag.py +0 -5
- mirascope/api/_generated/types/date.py +0 -3
- mirascope/api/_generated/types/http_api_decode_error.py +0 -27
- mirascope/api/_generated/types/http_api_decode_error_tag.py +0 -5
- mirascope/api/_generated/types/immutable_resource_error.py +0 -22
- mirascope/api/_generated/types/internal_server_error_body.py +0 -49
- mirascope/api/_generated/types/issue.py +0 -38
- mirascope/api/_generated/types/issue_tag.py +0 -10
- mirascope/api/_generated/types/not_found_error_body.py +0 -22
- mirascope/api/_generated/types/not_found_error_tag.py +0 -5
- mirascope/api/_generated/types/number_from_string.py +0 -3
- mirascope/api/_generated/types/permission_denied_error.py +0 -22
- mirascope/api/_generated/types/permission_denied_error_tag.py +0 -5
- mirascope/api/_generated/types/plan_limit_exceeded_error.py +0 -32
- mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +0 -7
- mirascope/api/_generated/types/pricing_unavailable_error.py +0 -23
- mirascope/api/_generated/types/property_key.py +0 -7
- mirascope/api/_generated/types/property_key_key.py +0 -25
- mirascope/api/_generated/types/property_key_key_tag.py +0 -5
- mirascope/api/_generated/types/rate_limit_error.py +0 -31
- mirascope/api/_generated/types/rate_limit_error_tag.py +0 -5
- mirascope/api/_generated/types/service_unavailable_error_body.py +0 -24
- mirascope/api/_generated/types/service_unavailable_error_tag.py +0 -7
- mirascope/api/_generated/types/stripe_error.py +0 -20
- mirascope/api/_generated/types/subscription_past_due_error.py +0 -31
- mirascope/api/_generated/types/subscription_past_due_error_tag.py +0 -7
- mirascope/api/_generated/types/unauthorized_error_body.py +0 -21
- mirascope/api/_generated/types/unauthorized_error_tag.py +0 -5
- mirascope/api/client.py +0 -255
- mirascope/api/settings.py +0 -99
- mirascope/llm/formatting/output_parser.py +0 -178
- mirascope/llm/formatting/primitives.py +0 -192
- mirascope/llm/mcp/mcp_client.py +0 -130
- mirascope/llm/messages/_utils.py +0 -34
- mirascope/llm/models/thinking_config.py +0 -61
- mirascope/llm/prompts/prompts.py +0 -487
- mirascope/llm/providers/__init__.py +0 -62
- mirascope/llm/providers/anthropic/__init__.py +0 -11
- mirascope/llm/providers/anthropic/_utils/__init__.py +0 -27
- mirascope/llm/providers/anthropic/_utils/beta_decode.py +0 -282
- mirascope/llm/providers/anthropic/_utils/beta_encode.py +0 -266
- mirascope/llm/providers/anthropic/_utils/encode.py +0 -418
- mirascope/llm/providers/anthropic/_utils/errors.py +0 -46
- mirascope/llm/providers/anthropic/beta_provider.py +0 -374
- mirascope/llm/providers/anthropic/model_id.py +0 -23
- mirascope/llm/providers/anthropic/model_info.py +0 -87
- mirascope/llm/providers/anthropic/provider.py +0 -479
- mirascope/llm/providers/google/__init__.py +0 -6
- mirascope/llm/providers/google/_utils/errors.py +0 -50
- mirascope/llm/providers/google/model_id.py +0 -22
- mirascope/llm/providers/google/model_info.py +0 -63
- mirascope/llm/providers/google/provider.py +0 -492
- mirascope/llm/providers/mirascope/__init__.py +0 -5
- mirascope/llm/providers/mirascope/_utils.py +0 -73
- mirascope/llm/providers/mirascope/provider.py +0 -349
- mirascope/llm/providers/mlx/__init__.py +0 -9
- mirascope/llm/providers/mlx/_utils.py +0 -141
- mirascope/llm/providers/mlx/encoding/__init__.py +0 -8
- mirascope/llm/providers/mlx/encoding/base.py +0 -72
- mirascope/llm/providers/mlx/encoding/transformers.py +0 -150
- mirascope/llm/providers/mlx/mlx.py +0 -254
- mirascope/llm/providers/mlx/model_id.py +0 -17
- mirascope/llm/providers/mlx/provider.py +0 -452
- mirascope/llm/providers/model_id.py +0 -16
- mirascope/llm/providers/ollama/__init__.py +0 -7
- mirascope/llm/providers/ollama/provider.py +0 -71
- mirascope/llm/providers/openai/__init__.py +0 -15
- mirascope/llm/providers/openai/_utils/__init__.py +0 -5
- mirascope/llm/providers/openai/_utils/errors.py +0 -46
- mirascope/llm/providers/openai/completions/__init__.py +0 -7
- mirascope/llm/providers/openai/completions/base_provider.py +0 -542
- mirascope/llm/providers/openai/completions/provider.py +0 -22
- mirascope/llm/providers/openai/model_id.py +0 -31
- mirascope/llm/providers/openai/model_info.py +0 -303
- mirascope/llm/providers/openai/provider.py +0 -441
- mirascope/llm/providers/openai/responses/__init__.py +0 -5
- mirascope/llm/providers/openai/responses/provider.py +0 -513
- mirascope/llm/providers/provider_id.py +0 -24
- mirascope/llm/providers/provider_registry.py +0 -299
- mirascope/llm/providers/together/__init__.py +0 -7
- mirascope/llm/providers/together/provider.py +0 -40
- mirascope/llm/responses/usage.py +0 -95
- mirascope/ops/__init__.py +0 -111
- mirascope/ops/_internal/__init__.py +0 -5
- mirascope/ops/_internal/closure.py +0 -1169
- mirascope/ops/_internal/configuration.py +0 -177
- mirascope/ops/_internal/context.py +0 -76
- mirascope/ops/_internal/exporters/__init__.py +0 -26
- mirascope/ops/_internal/exporters/exporters.py +0 -395
- mirascope/ops/_internal/exporters/processors.py +0 -104
- mirascope/ops/_internal/exporters/types.py +0 -165
- mirascope/ops/_internal/exporters/utils.py +0 -29
- mirascope/ops/_internal/instrumentation/__init__.py +0 -8
- mirascope/ops/_internal/instrumentation/llm/__init__.py +0 -8
- mirascope/ops/_internal/instrumentation/llm/common.py +0 -530
- mirascope/ops/_internal/instrumentation/llm/cost.py +0 -190
- mirascope/ops/_internal/instrumentation/llm/encode.py +0 -238
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/__init__.py +0 -38
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_input_messages.py +0 -31
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_output_messages.py +0 -38
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_system_instructions.py +0 -18
- mirascope/ops/_internal/instrumentation/llm/gen_ai_types/shared.py +0 -100
- mirascope/ops/_internal/instrumentation/llm/llm.py +0 -161
- mirascope/ops/_internal/instrumentation/llm/model.py +0 -1798
- mirascope/ops/_internal/instrumentation/llm/response.py +0 -521
- mirascope/ops/_internal/instrumentation/llm/serialize.py +0 -300
- mirascope/ops/_internal/propagation.py +0 -198
- mirascope/ops/_internal/protocols.py +0 -133
- mirascope/ops/_internal/session.py +0 -139
- mirascope/ops/_internal/spans.py +0 -232
- mirascope/ops/_internal/traced_calls.py +0 -375
- mirascope/ops/_internal/traced_functions.py +0 -523
- mirascope/ops/_internal/tracing.py +0 -353
- mirascope/ops/_internal/types.py +0 -13
- mirascope/ops/_internal/utils.py +0 -123
- mirascope/ops/_internal/versioned_calls.py +0 -512
- mirascope/ops/_internal/versioned_functions.py +0 -357
- mirascope/ops/_internal/versioning.py +0 -303
- mirascope/ops/exceptions.py +0 -21
- mirascope-2.0.0.dist-info/RECORD +0 -423
- /mirascope/llm/{providers → clients}/base/kwargs.py +0 -0
- /mirascope/llm/{providers → clients}/google/message.py +0 -0
|
@@ -29,10 +29,8 @@ from .....responses import (
|
|
|
29
29
|
FinishReasonChunk,
|
|
30
30
|
RawMessageChunk,
|
|
31
31
|
RawStreamEventChunk,
|
|
32
|
-
Usage,
|
|
33
|
-
UsageDeltaChunk,
|
|
34
32
|
)
|
|
35
|
-
from
|
|
33
|
+
from ..model_ids import OpenAIResponsesModelId
|
|
36
34
|
|
|
37
35
|
INCOMPLETE_DETAILS_TO_FINISH_REASON = {
|
|
38
36
|
"max_output_tokens": FinishReason.MAX_TOKENS,
|
|
@@ -40,33 +38,6 @@ INCOMPLETE_DETAILS_TO_FINISH_REASON = {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
|
|
43
|
-
def _decode_usage(
|
|
44
|
-
usage: openai_types.ResponseUsage | None,
|
|
45
|
-
) -> Usage | None:
|
|
46
|
-
"""Convert OpenAI ResponseUsage to Mirascope Usage."""
|
|
47
|
-
if usage is None: # pragma: no cover
|
|
48
|
-
return None
|
|
49
|
-
|
|
50
|
-
return Usage(
|
|
51
|
-
input_tokens=usage.input_tokens,
|
|
52
|
-
output_tokens=usage.output_tokens,
|
|
53
|
-
cache_read_tokens=(
|
|
54
|
-
usage.input_tokens_details.cached_tokens
|
|
55
|
-
if usage.input_tokens_details
|
|
56
|
-
else None
|
|
57
|
-
)
|
|
58
|
-
or 0,
|
|
59
|
-
cache_write_tokens=0,
|
|
60
|
-
reasoning_tokens=(
|
|
61
|
-
usage.output_tokens_details.reasoning_tokens
|
|
62
|
-
if usage.output_tokens_details
|
|
63
|
-
else None
|
|
64
|
-
)
|
|
65
|
-
or 0,
|
|
66
|
-
raw=usage,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
41
|
def _serialize_output_item(
|
|
71
42
|
item: openai_types.ResponseOutputItem,
|
|
72
43
|
) -> dict[str, Any]:
|
|
@@ -76,12 +47,9 @@ def _serialize_output_item(
|
|
|
76
47
|
|
|
77
48
|
def decode_response(
|
|
78
49
|
response: openai_types.Response,
|
|
79
|
-
model_id:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
include_thoughts: bool,
|
|
83
|
-
) -> tuple[AssistantMessage, FinishReason | None, Usage | None]:
|
|
84
|
-
"""Convert OpenAI Responses Response to mirascope AssistantMessage and usage."""
|
|
50
|
+
model_id: OpenAIResponsesModelId,
|
|
51
|
+
) -> tuple[AssistantMessage, FinishReason | None]:
|
|
52
|
+
"""Convert OpenAI Responses Response to mirascope AssistantMessage."""
|
|
85
53
|
parts: list[AssistantContentPart] = []
|
|
86
54
|
finish_reason: FinishReason | None = None
|
|
87
55
|
refused = False
|
|
@@ -116,9 +84,6 @@ def decode_response(
|
|
|
116
84
|
else:
|
|
117
85
|
raise NotImplementedError(f"Unsupported output item: {output_item.type}")
|
|
118
86
|
|
|
119
|
-
if not include_thoughts:
|
|
120
|
-
parts = [part for part in parts if part.type != "thought"]
|
|
121
|
-
|
|
122
87
|
if refused:
|
|
123
88
|
finish_reason = FinishReason.REFUSAL
|
|
124
89
|
elif details := response.incomplete_details:
|
|
@@ -126,25 +91,22 @@ def decode_response(
|
|
|
126
91
|
|
|
127
92
|
assistant_message = AssistantMessage(
|
|
128
93
|
content=parts,
|
|
129
|
-
|
|
94
|
+
provider="openai:responses",
|
|
130
95
|
model_id=model_id,
|
|
131
|
-
provider_model_name=model_name(model_id, "responses"),
|
|
132
96
|
raw_message=[
|
|
133
97
|
_serialize_output_item(output_item) for output_item in response.output
|
|
134
98
|
],
|
|
135
99
|
)
|
|
136
100
|
|
|
137
|
-
|
|
138
|
-
return assistant_message, finish_reason, usage
|
|
101
|
+
return assistant_message, finish_reason
|
|
139
102
|
|
|
140
103
|
|
|
141
104
|
class _OpenAIResponsesChunkProcessor:
|
|
142
105
|
"""Processes OpenAI Responses streaming events and maintains state across chunks."""
|
|
143
106
|
|
|
144
|
-
def __init__(self
|
|
107
|
+
def __init__(self) -> None:
|
|
145
108
|
self.current_content_type: Literal["text", "tool_call", "thought"] | None = None
|
|
146
109
|
self.refusal_encountered = False
|
|
147
|
-
self.include_thoughts = include_thoughts
|
|
148
110
|
|
|
149
111
|
def process_chunk(self, event: ResponseStreamEvent) -> ChunkIterator:
|
|
150
112
|
"""Process a single OpenAI Responses stream event and yield the appropriate content chunks."""
|
|
@@ -179,26 +141,23 @@ class _OpenAIResponsesChunkProcessor:
|
|
|
179
141
|
)
|
|
180
142
|
self.current_content_type = "tool_call"
|
|
181
143
|
elif event.type == "response.function_call_arguments.delta":
|
|
182
|
-
yield ToolCallChunk(
|
|
144
|
+
yield ToolCallChunk(delta=event.delta)
|
|
183
145
|
elif event.type == "response.function_call_arguments.done":
|
|
184
|
-
yield ToolCallEndChunk(
|
|
146
|
+
yield ToolCallEndChunk()
|
|
185
147
|
self.current_content_type = None
|
|
186
148
|
elif (
|
|
187
149
|
event.type == "response.reasoning_text.delta"
|
|
188
150
|
or event.type == "response.reasoning_summary_text.delta"
|
|
189
151
|
):
|
|
190
152
|
if not self.current_content_type:
|
|
191
|
-
|
|
192
|
-
yield ThoughtStartChunk()
|
|
153
|
+
yield ThoughtStartChunk()
|
|
193
154
|
self.current_content_type = "thought"
|
|
194
|
-
|
|
195
|
-
yield ThoughtChunk(delta=event.delta)
|
|
155
|
+
yield ThoughtChunk(delta=event.delta)
|
|
196
156
|
elif (
|
|
197
157
|
event.type == "response.reasoning_summary_text.done"
|
|
198
158
|
or event.type == "response.reasoning_text.done"
|
|
199
159
|
):
|
|
200
|
-
|
|
201
|
-
yield ThoughtEndChunk()
|
|
160
|
+
yield ThoughtEndChunk()
|
|
202
161
|
self.current_content_type = None
|
|
203
162
|
elif event.type == "response.incomplete":
|
|
204
163
|
details = event.response.incomplete_details
|
|
@@ -215,46 +174,21 @@ class _OpenAIResponsesChunkProcessor:
|
|
|
215
174
|
if self.refusal_encountered:
|
|
216
175
|
yield FinishReasonChunk(finish_reason=FinishReason.REFUSAL)
|
|
217
176
|
|
|
218
|
-
# Emit usage delta if present
|
|
219
|
-
if event.response.usage:
|
|
220
|
-
usage = event.response.usage
|
|
221
|
-
yield UsageDeltaChunk(
|
|
222
|
-
input_tokens=usage.input_tokens,
|
|
223
|
-
output_tokens=usage.output_tokens,
|
|
224
|
-
cache_read_tokens=(
|
|
225
|
-
usage.input_tokens_details.cached_tokens
|
|
226
|
-
if usage.input_tokens_details
|
|
227
|
-
else None
|
|
228
|
-
)
|
|
229
|
-
or 0,
|
|
230
|
-
cache_write_tokens=0,
|
|
231
|
-
reasoning_tokens=(
|
|
232
|
-
usage.output_tokens_details.reasoning_tokens
|
|
233
|
-
if usage.output_tokens_details
|
|
234
|
-
else None
|
|
235
|
-
)
|
|
236
|
-
or 0,
|
|
237
|
-
)
|
|
238
|
-
|
|
239
177
|
|
|
240
178
|
def decode_stream(
|
|
241
179
|
openai_stream: Stream[ResponseStreamEvent],
|
|
242
|
-
*,
|
|
243
|
-
include_thoughts: bool,
|
|
244
180
|
) -> ChunkIterator:
|
|
245
181
|
"""Returns a ChunkIterator converted from an OpenAI Stream[ResponseStreamEvent]"""
|
|
246
|
-
processor = _OpenAIResponsesChunkProcessor(
|
|
182
|
+
processor = _OpenAIResponsesChunkProcessor()
|
|
247
183
|
for event in openai_stream:
|
|
248
184
|
yield from processor.process_chunk(event)
|
|
249
185
|
|
|
250
186
|
|
|
251
187
|
async def decode_async_stream(
|
|
252
188
|
openai_stream: AsyncStream[ResponseStreamEvent],
|
|
253
|
-
*,
|
|
254
|
-
include_thoughts: bool,
|
|
255
189
|
) -> AsyncChunkIterator:
|
|
256
190
|
"""Returns an AsyncChunkIterator converted from an OpenAI AsyncStream[ResponseStreamEvent]"""
|
|
257
|
-
processor = _OpenAIResponsesChunkProcessor(
|
|
191
|
+
processor = _OpenAIResponsesChunkProcessor()
|
|
258
192
|
async for event in openai_stream:
|
|
259
193
|
for item in processor.process_chunk(event):
|
|
260
194
|
yield item
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"""OpenAI Responses message encoding and request preparation."""
|
|
2
2
|
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
3
|
from collections.abc import Sequence
|
|
6
|
-
from typing import
|
|
4
|
+
from typing import TypedDict, cast
|
|
7
5
|
|
|
8
6
|
from openai import Omit
|
|
9
7
|
from openai.types.responses import (
|
|
@@ -25,7 +23,7 @@ from openai.types.responses.response_input_param import (
|
|
|
25
23
|
FunctionCallOutput,
|
|
26
24
|
Message as ResponseInputMessageParam,
|
|
27
25
|
)
|
|
28
|
-
from openai.types.shared_params import Reasoning
|
|
26
|
+
from openai.types.shared_params import Reasoning
|
|
29
27
|
from openai.types.shared_params.response_format_json_object import (
|
|
30
28
|
ResponseFormatJSONObject,
|
|
31
29
|
)
|
|
@@ -35,32 +33,15 @@ from .....exceptions import FeatureNotSupportedError
|
|
|
35
33
|
from .....formatting import (
|
|
36
34
|
Format,
|
|
37
35
|
FormattableT,
|
|
38
|
-
|
|
36
|
+
_utils as _formatting_utils,
|
|
39
37
|
resolve_format,
|
|
40
38
|
)
|
|
41
39
|
from .....messages import AssistantMessage, Message, UserMessage
|
|
42
|
-
from .....tools import FORMAT_TOOL_NAME,
|
|
43
|
-
from ....base import _utils as _base_utils
|
|
44
|
-
from ...
|
|
45
|
-
from
|
|
46
|
-
|
|
47
|
-
MODELS_WITHOUT_JSON_SCHEMA_SUPPORT,
|
|
48
|
-
NON_REASONING_MODELS,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if TYPE_CHECKING:
|
|
52
|
-
from .....models import Params, ThinkingLevel
|
|
53
|
-
|
|
54
|
-
# Thinking level to a float multiplier % of max tokens
|
|
55
|
-
THINKING_LEVEL_TO_EFFORT: dict[ThinkingLevel, ReasoningEffort] = {
|
|
56
|
-
"default": "medium",
|
|
57
|
-
"none": "none",
|
|
58
|
-
"minimal": "minimal",
|
|
59
|
-
"low": "low",
|
|
60
|
-
"medium": "medium",
|
|
61
|
-
"high": "high",
|
|
62
|
-
"max": "xhigh",
|
|
63
|
-
}
|
|
40
|
+
from .....tools import FORMAT_TOOL_NAME, BaseToolkit, ToolSchema
|
|
41
|
+
from ....base import Params, _utils as _base_utils
|
|
42
|
+
from ...shared import _utils as _shared_utils
|
|
43
|
+
from ..model_ids import OpenAIResponsesModelId
|
|
44
|
+
from .model_features import NON_REASONING_MODELS
|
|
64
45
|
|
|
65
46
|
|
|
66
47
|
class ResponseCreateKwargs(TypedDict, total=False):
|
|
@@ -119,15 +100,15 @@ def _encode_user_message(
|
|
|
119
100
|
result.append(
|
|
120
101
|
FunctionCallOutput(
|
|
121
102
|
call_id=part.id,
|
|
122
|
-
output=str(part.
|
|
103
|
+
output=str(part.value),
|
|
123
104
|
type="function_call_output",
|
|
124
105
|
)
|
|
125
106
|
)
|
|
126
107
|
elif part.type == "audio":
|
|
127
108
|
raise FeatureNotSupportedError(
|
|
128
109
|
"audio input",
|
|
129
|
-
"openai",
|
|
130
|
-
message='provider "openai" does not support audio inputs
|
|
110
|
+
"openai:responses",
|
|
111
|
+
message='provider "openai:responses" does not support audio inputs. Try using "openai:completions" instead',
|
|
131
112
|
)
|
|
132
113
|
else:
|
|
133
114
|
raise NotImplementedError(
|
|
@@ -182,7 +163,7 @@ def _encode_assistant_message(
|
|
|
182
163
|
|
|
183
164
|
|
|
184
165
|
def _encode_message(
|
|
185
|
-
message: Message, model_id:
|
|
166
|
+
message: Message, model_id: OpenAIResponsesModelId, encode_thoughts: bool
|
|
186
167
|
) -> ResponseInputParam:
|
|
187
168
|
"""Convert a Mirascope Message to OpenAI Responses input items.
|
|
188
169
|
|
|
@@ -198,9 +179,8 @@ def _encode_message(
|
|
|
198
179
|
|
|
199
180
|
if (
|
|
200
181
|
message.role == "assistant"
|
|
201
|
-
and message.
|
|
202
|
-
and message.
|
|
203
|
-
== model_name(model_id=model_id, api_mode="responses")
|
|
182
|
+
and message.provider == "openai:responses"
|
|
183
|
+
and message.model_id == model_id
|
|
204
184
|
and message.raw_message
|
|
205
185
|
and not encode_thoughts
|
|
206
186
|
):
|
|
@@ -212,21 +192,18 @@ def _encode_message(
|
|
|
212
192
|
return _encode_user_message(message)
|
|
213
193
|
|
|
214
194
|
|
|
215
|
-
def _convert_tool_to_function_tool_param(tool:
|
|
195
|
+
def _convert_tool_to_function_tool_param(tool: ToolSchema) -> FunctionToolParam:
|
|
216
196
|
"""Convert a Mirascope ToolSchema to OpenAI Responses FunctionToolParam."""
|
|
217
197
|
schema_dict = tool.parameters.model_dump(by_alias=True, exclude_none=True)
|
|
218
198
|
schema_dict["type"] = "object"
|
|
219
|
-
|
|
220
|
-
strict = True if tool.strict is None else tool.strict
|
|
221
|
-
if strict:
|
|
222
|
-
_base_utils.ensure_all_properties_required(schema_dict)
|
|
199
|
+
_shared_utils._ensure_additional_properties_false(schema_dict)
|
|
223
200
|
|
|
224
201
|
return FunctionToolParam(
|
|
225
202
|
type="function",
|
|
226
203
|
name=tool.name,
|
|
227
204
|
description=tool.description,
|
|
228
205
|
parameters=schema_dict,
|
|
229
|
-
strict=strict,
|
|
206
|
+
strict=tool.strict,
|
|
230
207
|
)
|
|
231
208
|
|
|
232
209
|
|
|
@@ -242,7 +219,7 @@ def _create_strict_response_format(
|
|
|
242
219
|
ResponseFormatTextJSONSchemaConfigParam for strict structured outputs
|
|
243
220
|
"""
|
|
244
221
|
schema = format.schema.copy()
|
|
245
|
-
|
|
222
|
+
_shared_utils._ensure_additional_properties_false(schema)
|
|
246
223
|
|
|
247
224
|
response_format: ResponseFormatTextJSONSchemaConfigParam = {
|
|
248
225
|
"type": "json_schema",
|
|
@@ -256,59 +233,33 @@ def _create_strict_response_format(
|
|
|
256
233
|
return response_format
|
|
257
234
|
|
|
258
235
|
|
|
259
|
-
def _compute_reasoning(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
Args:
|
|
266
|
-
level: The thinking level
|
|
267
|
-
include_thoughts: Whether to include summary (True/False for auto)
|
|
268
|
-
|
|
269
|
-
Returns:
|
|
270
|
-
OpenAI Reasoning configuration
|
|
271
|
-
"""
|
|
272
|
-
reasoning: Reasoning = {"effort": THINKING_LEVEL_TO_EFFORT.get(level) or "medium"}
|
|
273
|
-
|
|
274
|
-
if include_thoughts:
|
|
275
|
-
reasoning["summary"] = "auto"
|
|
276
|
-
|
|
277
|
-
return reasoning
|
|
236
|
+
def _compute_reasoning(thinking: bool) -> Reasoning:
|
|
237
|
+
"""Compute the OpenAI `Reasoning` config based on thinking settings."""
|
|
238
|
+
if thinking:
|
|
239
|
+
return {"effort": "medium", "summary": "auto"}
|
|
240
|
+
else:
|
|
241
|
+
return {"effort": "minimal"}
|
|
278
242
|
|
|
279
243
|
|
|
280
244
|
def encode_request(
|
|
281
245
|
*,
|
|
282
|
-
model_id:
|
|
246
|
+
model_id: OpenAIResponsesModelId,
|
|
283
247
|
messages: Sequence[Message],
|
|
284
|
-
tools: Sequence[
|
|
285
|
-
format: type[FormattableT]
|
|
286
|
-
| Format[FormattableT]
|
|
287
|
-
| OutputParser[FormattableT]
|
|
288
|
-
| None,
|
|
248
|
+
tools: Sequence[ToolSchema] | BaseToolkit | None,
|
|
249
|
+
format: type[FormattableT] | Format[FormattableT] | None,
|
|
289
250
|
params: Params,
|
|
290
251
|
) -> tuple[Sequence[Message], Format[FormattableT] | None, ResponseCreateKwargs]:
|
|
291
252
|
"""Prepares a request for the `OpenAI.responses.create` method."""
|
|
292
|
-
if model_id.endswith(":completions"):
|
|
293
|
-
raise FeatureNotSupportedError(
|
|
294
|
-
feature="completions API",
|
|
295
|
-
provider_id="openai:responses",
|
|
296
|
-
model_id=model_id,
|
|
297
|
-
message=f"Cannot use completions model with responses client: {model_id}",
|
|
298
|
-
)
|
|
299
|
-
|
|
300
|
-
base_model_name = model_name(model_id, None)
|
|
301
|
-
|
|
302
253
|
kwargs: ResponseCreateKwargs = ResponseCreateKwargs(
|
|
303
254
|
{
|
|
304
|
-
"model":
|
|
255
|
+
"model": model_id,
|
|
305
256
|
}
|
|
306
257
|
)
|
|
307
258
|
encode_thoughts = False
|
|
308
259
|
|
|
309
260
|
with _base_utils.ensure_all_params_accessed(
|
|
310
261
|
params=params,
|
|
311
|
-
|
|
262
|
+
provider="openai:responses",
|
|
312
263
|
unsupported_params=["top_k", "seed", "stop_sequences"],
|
|
313
264
|
) as param_accessor:
|
|
314
265
|
if param_accessor.temperature is not None:
|
|
@@ -318,26 +269,23 @@ def encode_request(
|
|
|
318
269
|
if param_accessor.top_p is not None:
|
|
319
270
|
kwargs["top_p"] = param_accessor.top_p
|
|
320
271
|
if param_accessor.thinking is not None:
|
|
321
|
-
|
|
322
|
-
if base_model_name in NON_REASONING_MODELS:
|
|
272
|
+
if model_id in NON_REASONING_MODELS:
|
|
323
273
|
param_accessor.emit_warning_for_unused_param(
|
|
324
|
-
"thinking",
|
|
274
|
+
"thinking", param_accessor.thinking, "openai:responses", model_id
|
|
325
275
|
)
|
|
326
276
|
else:
|
|
327
277
|
# Assume model supports reasoning unless explicitly listed as non-reasoning
|
|
328
278
|
# This ensures new reasoning models work immediately without code updates
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
# Handle encode_thoughts_as_text from ThinkingConfig
|
|
334
|
-
if thinking_config.get("encode_thoughts_as_text"):
|
|
335
|
-
encode_thoughts = True
|
|
279
|
+
kwargs["reasoning"] = _compute_reasoning(param_accessor.thinking)
|
|
280
|
+
if param_accessor.encode_thoughts_as_text:
|
|
281
|
+
encode_thoughts = True
|
|
336
282
|
|
|
337
283
|
tools = tools.tools if isinstance(tools, BaseToolkit) else tools or []
|
|
338
284
|
openai_tools = [_convert_tool_to_function_tool_param(tool) for tool in tools]
|
|
339
285
|
|
|
340
|
-
model_supports_strict =
|
|
286
|
+
model_supports_strict = (
|
|
287
|
+
model_id not in _shared_utils.MODELS_WITHOUT_JSON_SCHEMA_SUPPORT
|
|
288
|
+
)
|
|
341
289
|
default_mode = "strict" if model_supports_strict else "tool"
|
|
342
290
|
|
|
343
291
|
format = resolve_format(format, default_mode=default_mode)
|
|
@@ -345,9 +293,9 @@ def encode_request(
|
|
|
345
293
|
if format.mode == "strict":
|
|
346
294
|
kwargs["text"] = {"format": _create_strict_response_format(format)}
|
|
347
295
|
elif format.mode == "tool":
|
|
348
|
-
|
|
296
|
+
format_tool_shared_utils = _formatting_utils.create_tool_schema(format)
|
|
349
297
|
openai_tools.append(
|
|
350
|
-
_convert_tool_to_function_tool_param(
|
|
298
|
+
_convert_tool_to_function_tool_param(format_tool_shared_utils)
|
|
351
299
|
)
|
|
352
300
|
if tools:
|
|
353
301
|
kwargs["tool_choice"] = ToolChoiceAllowedParam(
|
|
@@ -364,7 +312,8 @@ def encode_request(
|
|
|
364
312
|
name=FORMAT_TOOL_NAME,
|
|
365
313
|
)
|
|
366
314
|
elif (
|
|
367
|
-
format.mode == "json"
|
|
315
|
+
format.mode == "json"
|
|
316
|
+
and model_id not in _shared_utils.MODELS_WITHOUT_JSON_OBJECT_SUPPORT
|
|
368
317
|
):
|
|
369
318
|
kwargs["text"] = {"format": ResponseFormatJSONObject(type="json_object")}
|
|
370
319
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""OpenAI Responses models categorized by reasoning support.
|
|
2
|
+
|
|
3
|
+
This file is auto-generated by scripts/update_openai_responses_model_features.py
|
|
4
|
+
Run that script to update these sets when OpenAI releases new models.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
REASONING_MODELS: set[str] = {
|
|
8
|
+
"codex-mini-latest",
|
|
9
|
+
"gpt-5",
|
|
10
|
+
"gpt-5-2025-08-07",
|
|
11
|
+
"gpt-5-mini",
|
|
12
|
+
"gpt-5-mini-2025-08-07",
|
|
13
|
+
"gpt-5-nano",
|
|
14
|
+
"gpt-5-nano-2025-08-07",
|
|
15
|
+
"o1",
|
|
16
|
+
"o1-2024-12-17",
|
|
17
|
+
"o1-pro",
|
|
18
|
+
"o1-pro-2025-03-19",
|
|
19
|
+
"o3",
|
|
20
|
+
"o3-2025-04-16",
|
|
21
|
+
"o3-mini",
|
|
22
|
+
"o3-mini-2025-01-31",
|
|
23
|
+
"o3-pro",
|
|
24
|
+
"o3-pro-2025-06-10",
|
|
25
|
+
"o4-mini",
|
|
26
|
+
"o4-mini-2025-04-16",
|
|
27
|
+
}
|
|
28
|
+
"""Models that have been tested and confirmed to support the reasoning parameter."""
|
|
29
|
+
|
|
30
|
+
NON_REASONING_MODELS: set[str] = {
|
|
31
|
+
"chatgpt-4o-latest",
|
|
32
|
+
"gpt-3.5-turbo",
|
|
33
|
+
"gpt-3.5-turbo-0125",
|
|
34
|
+
"gpt-3.5-turbo-1106",
|
|
35
|
+
"gpt-4",
|
|
36
|
+
"gpt-4-0125-preview",
|
|
37
|
+
"gpt-4-0314",
|
|
38
|
+
"gpt-4-0613",
|
|
39
|
+
"gpt-4-1106-preview",
|
|
40
|
+
"gpt-4-turbo",
|
|
41
|
+
"gpt-4-turbo-2024-04-09",
|
|
42
|
+
"gpt-4-turbo-preview",
|
|
43
|
+
"gpt-4.1",
|
|
44
|
+
"gpt-4.1-2025-04-14",
|
|
45
|
+
"gpt-4.1-mini",
|
|
46
|
+
"gpt-4.1-mini-2025-04-14",
|
|
47
|
+
"gpt-4.1-nano",
|
|
48
|
+
"gpt-4.1-nano-2025-04-14",
|
|
49
|
+
"gpt-4o",
|
|
50
|
+
"gpt-4o-2024-05-13",
|
|
51
|
+
"gpt-4o-2024-08-06",
|
|
52
|
+
"gpt-4o-2024-11-20",
|
|
53
|
+
"gpt-4o-mini",
|
|
54
|
+
"gpt-4o-mini-2024-07-18",
|
|
55
|
+
"gpt-5-chat-latest",
|
|
56
|
+
}
|
|
57
|
+
"""Models that have been tested and confirmed to NOT support the reasoning parameter."""
|
|
58
|
+
|
|
59
|
+
NON_EXISTENT_MODELS: set[str] = {
|
|
60
|
+
"gpt-3.5-turbo-0301",
|
|
61
|
+
"gpt-3.5-turbo-0613",
|
|
62
|
+
"gpt-3.5-turbo-16k",
|
|
63
|
+
"gpt-3.5-turbo-16k-0613",
|
|
64
|
+
"gpt-4-32k",
|
|
65
|
+
"gpt-4-32k-0314",
|
|
66
|
+
"gpt-4-32k-0613",
|
|
67
|
+
"gpt-4-vision-preview",
|
|
68
|
+
}
|
|
69
|
+
"""Models that are listed in OpenAI's types but no longer exist in their API."""
|
|
70
|
+
|
|
71
|
+
NO_RESPONSES_API_SUPPORT_MODELS: set[str] = {
|
|
72
|
+
"gpt-4o-audio-preview",
|
|
73
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
74
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
75
|
+
"gpt-4o-audio-preview-2025-06-03",
|
|
76
|
+
"gpt-4o-mini-audio-preview",
|
|
77
|
+
"gpt-4o-mini-audio-preview-2024-12-17",
|
|
78
|
+
"gpt-4o-mini-search-preview",
|
|
79
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
80
|
+
"gpt-4o-search-preview",
|
|
81
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
82
|
+
"o1-mini",
|
|
83
|
+
"o1-mini-2024-09-12",
|
|
84
|
+
"o1-preview",
|
|
85
|
+
"o1-preview-2024-09-12",
|
|
86
|
+
}
|
|
87
|
+
"""Models that do not support the Responses API."""
|