typizer 0.1.0__tar.gz
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.
- typizer-0.1.0/LICENSE +21 -0
- typizer-0.1.0/PKG-INFO +280 -0
- typizer-0.1.0/README.md +252 -0
- typizer-0.1.0/pyproject.toml +72 -0
- typizer-0.1.0/pyproject.toml.orig +65 -0
- typizer-0.1.0/typizer/__init__.py +8 -0
- typizer-0.1.0/typizer/api/__init__.py +1 -0
- typizer-0.1.0/typizer/api/account/__init__.py +1 -0
- typizer-0.1.0/typizer/api/account/delete_me.py +243 -0
- typizer-0.1.0/typizer/api/account/get_me.py +192 -0
- typizer-0.1.0/typizer/api/account/list_sign_ins.py +194 -0
- typizer-0.1.0/typizer/api/agent/__init__.py +1 -0
- typizer-0.1.0/typizer/api/agent/create_agent_message.py +290 -0
- typizer-0.1.0/typizer/api/agent/create_agent_sample_run.py +304 -0
- typizer-0.1.0/typizer/api/agent/create_agent_thread.py +251 -0
- typizer-0.1.0/typizer/api/agent/get_agent_thread.py +223 -0
- typizer-0.1.0/typizer/api/agent/list_agent_threads.py +243 -0
- typizer-0.1.0/typizer/api/agent/save_agent_thread.py +283 -0
- typizer-0.1.0/typizer/api/agent/update_agent_thread.py +245 -0
- typizer-0.1.0/typizer/api/api_keys/__init__.py +1 -0
- typizer-0.1.0/typizer/api/api_keys/create_api_key.py +235 -0
- typizer-0.1.0/typizer/api/api_keys/delete_api_key.py +217 -0
- typizer-0.1.0/typizer/api/api_keys/list_api_keys.py +196 -0
- typizer-0.1.0/typizer/api/auth/__init__.py +1 -0
- typizer-0.1.0/typizer/api/auth/start_login.py +209 -0
- typizer-0.1.0/typizer/api/batches/__init__.py +1 -0
- typizer-0.1.0/typizer/api/batches/create_batch.py +333 -0
- typizer-0.1.0/typizer/api/batches/export_batch.py +281 -0
- typizer-0.1.0/typizer/api/batches/get_batch.py +213 -0
- typizer-0.1.0/typizer/api/batches/list_batches.py +243 -0
- typizer-0.1.0/typizer/api/billing/__init__.py +1 -0
- typizer-0.1.0/typizer/api/billing/create_checkout.py +243 -0
- typizer-0.1.0/typizer/api/billing/create_contract_request.py +233 -0
- typizer-0.1.0/typizer/api/billing/create_invoice.py +243 -0
- typizer-0.1.0/typizer/api/billing/get_act_pdf.py +225 -0
- typizer-0.1.0/typizer/api/billing/get_balance.py +187 -0
- typizer-0.1.0/typizer/api/billing/get_billing_profile.py +196 -0
- typizer-0.1.0/typizer/api/billing/get_company.py +233 -0
- typizer-0.1.0/typizer/api/billing/get_contract_request_pdf.py +225 -0
- typizer-0.1.0/typizer/api/billing/get_payment.py +213 -0
- typizer-0.1.0/typizer/api/billing/get_usage.py +278 -0
- typizer-0.1.0/typizer/api/billing/list_contract_requests.py +196 -0
- typizer-0.1.0/typizer/api/billing/list_payments.py +233 -0
- typizer-0.1.0/typizer/api/billing/suggest_companies.py +214 -0
- typizer-0.1.0/typizer/api/billing/update_autotopup.py +231 -0
- typizer-0.1.0/typizer/api/billing/update_billing_profile.py +230 -0
- typizer-0.1.0/typizer/api/consents/__init__.py +1 -0
- typizer-0.1.0/typizer/api/consents/create_consent.py +228 -0
- typizer-0.1.0/typizer/api/consents/get_my_consents.py +210 -0
- typizer-0.1.0/typizer/api/demo/__init__.py +1 -0
- typizer-0.1.0/typizer/api/demo/create_demo_run.py +314 -0
- typizer-0.1.0/typizer/api/demo/get_demo_run.py +249 -0
- typizer-0.1.0/typizer/api/demo/list_demo_samples.py +159 -0
- typizer-0.1.0/typizer/api/files/__init__.py +1 -0
- typizer-0.1.0/typizer/api/files/create_file.py +266 -0
- typizer-0.1.0/typizer/api/files/delete_file.py +231 -0
- typizer-0.1.0/typizer/api/files/get_file.py +213 -0
- typizer-0.1.0/typizer/api/files/get_file_content.py +233 -0
- typizer-0.1.0/typizer/api/meta/__init__.py +1 -0
- typizer-0.1.0/typizer/api/meta/get_open_api_document.py +185 -0
- typizer-0.1.0/typizer/api/organization/__init__.py +1 -0
- typizer-0.1.0/typizer/api/organization/delete_organization.py +231 -0
- typizer-0.1.0/typizer/api/organization/get_organization.py +194 -0
- typizer-0.1.0/typizer/api/organization/update_organization.py +212 -0
- typizer-0.1.0/typizer/api/runs/__init__.py +1 -0
- typizer-0.1.0/typizer/api/runs/create_run.py +358 -0
- typizer-0.1.0/typizer/api/runs/extract.py +350 -0
- typizer-0.1.0/typizer/api/runs/get_run.py +225 -0
- typizer-0.1.0/typizer/api/runs/get_run_output.py +286 -0
- typizer-0.1.0/typizer/api/runs/list_runs.py +362 -0
- typizer-0.1.0/typizer/api/runs/retry_run.py +275 -0
- typizer-0.1.0/typizer/api/status/__init__.py +1 -0
- typizer-0.1.0/typizer/api/status/get_status.py +172 -0
- typizer-0.1.0/typizer/api/typizers/__init__.py +1 -0
- typizer-0.1.0/typizer/api/typizers/create_typizer.py +239 -0
- typizer-0.1.0/typizer/api/typizers/delete_typizer.py +229 -0
- typizer-0.1.0/typizer/api/typizers/generate_typizer.py +282 -0
- typizer-0.1.0/typizer/api/typizers/get_typizer.py +213 -0
- typizer-0.1.0/typizer/api/typizers/get_typizer_version.py +231 -0
- typizer-0.1.0/typizer/api/typizers/get_typizer_xsd.py +215 -0
- typizer-0.1.0/typizer/api/typizers/list_typizer_versions.py +256 -0
- typizer-0.1.0/typizer/api/typizers/list_typizers.py +235 -0
- typizer-0.1.0/typizer/api/typizers/update_typizer.py +247 -0
- typizer-0.1.0/typizer/api/webhooks/__init__.py +1 -0
- typizer-0.1.0/typizer/api/webhooks/create_webhook_endpoint.py +259 -0
- typizer-0.1.0/typizer/api/webhooks/delete_webhook_endpoint.py +217 -0
- typizer-0.1.0/typizer/api/webhooks/get_webhook_endpoint.py +217 -0
- typizer-0.1.0/typizer/api/webhooks/list_webhook_deliveries.py +264 -0
- typizer-0.1.0/typizer/api/webhooks/list_webhook_endpoints.py +235 -0
- typizer-0.1.0/typizer/api/webhooks/retry_webhook_delivery.py +254 -0
- typizer-0.1.0/typizer/api/webhooks/test_webhook_endpoint.py +254 -0
- typizer-0.1.0/typizer/api/webhooks/update_webhook_endpoint.py +252 -0
- typizer-0.1.0/typizer/client.py +268 -0
- typizer-0.1.0/typizer/errors.py +16 -0
- typizer-0.1.0/typizer/models/__init__.py +449 -0
- typizer-0.1.0/typizer/models/agent_message.py +103 -0
- typizer-0.1.0/typizer/models/agent_message_content.py +72 -0
- typizer-0.1.0/typizer/models/agent_message_object.py +8 -0
- typizer-0.1.0/typizer/models/agent_message_role.py +10 -0
- typizer-0.1.0/typizer/models/agent_thread.py +166 -0
- typizer-0.1.0/typizer/models/agent_thread_draft_schema_type_0.py +47 -0
- typizer-0.1.0/typizer/models/agent_thread_object.py +8 -0
- typizer-0.1.0/typizer/models/api_key.py +152 -0
- typizer-0.1.0/typizer/models/api_key_created_by.py +87 -0
- typizer-0.1.0/typizer/models/api_key_object.py +8 -0
- typizer-0.1.0/typizer/models/balance.py +103 -0
- typizer-0.1.0/typizer/models/balance_lot.py +97 -0
- typizer-0.1.0/typizer/models/balance_lot_source.py +11 -0
- typizer-0.1.0/typizer/models/balance_object.py +8 -0
- typizer-0.1.0/typizer/models/batch.py +146 -0
- typizer-0.1.0/typizer/models/batch_object.py +8 -0
- typizer-0.1.0/typizer/models/batch_status.py +9 -0
- typizer-0.1.0/typizer/models/billing_profile.py +184 -0
- typizer-0.1.0/typizer/models/billing_profile_autotopup.py +148 -0
- typizer-0.1.0/typizer/models/billing_profile_object.py +8 -0
- typizer-0.1.0/typizer/models/checkout.py +69 -0
- typizer-0.1.0/typizer/models/checkout_request.py +87 -0
- typizer-0.1.0/typizer/models/checkout_request_autotopup.py +81 -0
- typizer-0.1.0/typizer/models/checkout_request_package_code.py +12 -0
- typizer-0.1.0/typizer/models/company.py +139 -0
- typizer-0.1.0/typizer/models/company_list.py +107 -0
- typizer-0.1.0/typizer/models/company_list_object.py +8 -0
- typizer-0.1.0/typizer/models/company_object.py +8 -0
- typizer-0.1.0/typizer/models/company_status.py +12 -0
- typizer-0.1.0/typizer/models/company_type.py +9 -0
- typizer-0.1.0/typizer/models/consent_request.py +61 -0
- typizer-0.1.0/typizer/models/consent_request_kind.py +9 -0
- typizer-0.1.0/typizer/models/contract_request.py +211 -0
- typizer-0.1.0/typizer/models/contract_request_delivery_type_1.py +9 -0
- typizer-0.1.0/typizer/models/contract_request_delivery_type_2_type_1.py +9 -0
- typizer-0.1.0/typizer/models/contract_request_delivery_type_3_type_1.py +9 -0
- typizer-0.1.0/typizer/models/contract_request_edo_type_0.py +112 -0
- typizer-0.1.0/typizer/models/contract_request_list.py +107 -0
- typizer-0.1.0/typizer/models/contract_request_list_object.py +8 -0
- typizer-0.1.0/typizer/models/contract_request_object.py +8 -0
- typizer-0.1.0/typizer/models/contract_request_status.py +12 -0
- typizer-0.1.0/typizer/models/create_agent_message_request.py +54 -0
- typizer-0.1.0/typizer/models/create_agent_thread_request.py +51 -0
- typizer-0.1.0/typizer/models/create_api_key_request.py +85 -0
- typizer-0.1.0/typizer/models/create_batch_files_body.py +149 -0
- typizer-0.1.0/typizer/models/create_batch_files_body_format.py +11 -0
- typizer-0.1.0/typizer/models/create_batch_files_body_mode.py +9 -0
- typizer-0.1.0/typizer/models/create_batch_request.py +108 -0
- typizer-0.1.0/typizer/models/create_batch_request_format.py +11 -0
- typizer-0.1.0/typizer/models/create_batch_request_metadata.py +52 -0
- typizer-0.1.0/typizer/models/create_batch_request_mode.py +9 -0
- typizer-0.1.0/typizer/models/create_demo_run_files_body.py +107 -0
- typizer-0.1.0/typizer/models/create_demo_run_files_body_consent_pd.py +8 -0
- typizer-0.1.0/typizer/models/create_file_body.py +75 -0
- typizer-0.1.0/typizer/models/create_invoice_request.py +63 -0
- typizer-0.1.0/typizer/models/create_invoice_request_package_code.py +12 -0
- typizer-0.1.0/typizer/models/create_run_files_body.py +169 -0
- typizer-0.1.0/typizer/models/create_run_files_body_format.py +11 -0
- typizer-0.1.0/typizer/models/create_run_files_body_mode.py +9 -0
- typizer-0.1.0/typizer/models/create_run_request.py +120 -0
- typizer-0.1.0/typizer/models/create_run_request_format.py +11 -0
- typizer-0.1.0/typizer/models/create_run_request_metadata.py +53 -0
- typizer-0.1.0/typizer/models/create_run_request_mode.py +9 -0
- typizer-0.1.0/typizer/models/create_typizer_request.py +125 -0
- typizer-0.1.0/typizer/models/create_typizer_request_default_format.py +11 -0
- typizer-0.1.0/typizer/models/create_typizer_request_mode.py +9 -0
- typizer-0.1.0/typizer/models/create_typizer_request_schema.py +53 -0
- typizer-0.1.0/typizer/models/create_webhook_endpoint_request.py +62 -0
- typizer-0.1.0/typizer/models/created_api_key.py +163 -0
- typizer-0.1.0/typizer/models/deleted_api_key.py +79 -0
- typizer-0.1.0/typizer/models/deleted_api_key_object.py +8 -0
- typizer-0.1.0/typizer/models/deleted_file.py +79 -0
- typizer-0.1.0/typizer/models/deleted_file_object.py +8 -0
- typizer-0.1.0/typizer/models/deleted_typizer.py +79 -0
- typizer-0.1.0/typizer/models/deleted_typizer_object.py +8 -0
- typizer-0.1.0/typizer/models/deleted_webhook_endpoint.py +79 -0
- typizer-0.1.0/typizer/models/deleted_webhook_endpoint_object.py +8 -0
- typizer-0.1.0/typizer/models/demo_run.py +180 -0
- typizer-0.1.0/typizer/models/demo_run_error_type_0.py +69 -0
- typizer-0.1.0/typizer/models/demo_run_object.py +8 -0
- typizer-0.1.0/typizer/models/demo_run_pages.py +76 -0
- typizer-0.1.0/typizer/models/demo_run_request.py +52 -0
- typizer-0.1.0/typizer/models/demo_run_request_sample.py +10 -0
- typizer-0.1.0/typizer/models/demo_run_status.py +11 -0
- typizer-0.1.0/typizer/models/demo_sample.py +95 -0
- typizer-0.1.0/typizer/models/demo_sample_id.py +10 -0
- typizer-0.1.0/typizer/models/demo_sample_list.py +85 -0
- typizer-0.1.0/typizer/models/demo_sample_list_object.py +8 -0
- typizer-0.1.0/typizer/models/export_batch_format.py +10 -0
- typizer-0.1.0/typizer/models/extract_files_body.py +194 -0
- typizer-0.1.0/typizer/models/extract_files_body_format.py +11 -0
- typizer-0.1.0/typizer/models/extract_files_body_mode.py +9 -0
- typizer-0.1.0/typizer/models/extract_request.py +146 -0
- typizer-0.1.0/typizer/models/extract_request_format.py +11 -0
- typizer-0.1.0/typizer/models/extract_request_metadata.py +53 -0
- typizer-0.1.0/typizer/models/extract_request_mode.py +9 -0
- typizer-0.1.0/typizer/models/extract_request_schema.py +53 -0
- typizer-0.1.0/typizer/models/file.py +153 -0
- typizer-0.1.0/typizer/models/file_object.py +8 -0
- typizer-0.1.0/typizer/models/file_source.py +12 -0
- typizer-0.1.0/typizer/models/generate_typizer_request.py +51 -0
- typizer-0.1.0/typizer/models/get_open_api_document_response_200.py +45 -0
- typizer-0.1.0/typizer/models/get_run_output_format.py +11 -0
- typizer-0.1.0/typizer/models/get_usage_group_by.py +10 -0
- typizer-0.1.0/typizer/models/list_agent_threads_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_agent_threads_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_api_keys_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_api_keys_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_batches_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_batches_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_runs_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_runs_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_runs_source.py +12 -0
- typizer-0.1.0/typizer/models/list_runs_status.py +11 -0
- typizer-0.1.0/typizer/models/list_typizer_versions_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_typizer_versions_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_typizers_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_typizers_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_webhook_deliveries_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_webhook_deliveries_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/list_webhook_endpoints_response_200.py +107 -0
- typizer-0.1.0/typizer/models/list_webhook_endpoints_response_200_object.py +8 -0
- typizer-0.1.0/typizer/models/login_challenge.py +71 -0
- typizer-0.1.0/typizer/models/login_challenge_object.py +8 -0
- typizer-0.1.0/typizer/models/login_start_request.py +94 -0
- typizer-0.1.0/typizer/models/login_start_request_consents.py +74 -0
- typizer-0.1.0/typizer/models/login_start_request_consents_pd_processing.py +61 -0
- typizer-0.1.0/typizer/models/maintenance_event.py +139 -0
- typizer-0.1.0/typizer/models/maintenance_event_components_item.py +13 -0
- typizer-0.1.0/typizer/models/maintenance_event_kind.py +9 -0
- typizer-0.1.0/typizer/models/maintenance_event_object.py +8 -0
- typizer-0.1.0/typizer/models/maintenance_event_status.py +9 -0
- typizer-0.1.0/typizer/models/marketing_consent_state.py +102 -0
- typizer-0.1.0/typizer/models/me.py +226 -0
- typizer-0.1.0/typizer/models/me_api_key_type_0.py +88 -0
- typizer-0.1.0/typizer/models/me_auth.py +9 -0
- typizer-0.1.0/typizer/models/me_features.py +70 -0
- typizer-0.1.0/typizer/models/me_object.py +8 -0
- typizer-0.1.0/typizer/models/me_organization.py +69 -0
- typizer-0.1.0/typizer/models/me_organizations_item.py +79 -0
- typizer-0.1.0/typizer/models/me_organizations_item_role.py +10 -0
- typizer-0.1.0/typizer/models/me_role_type_1.py +10 -0
- typizer-0.1.0/typizer/models/me_role_type_2_type_1.py +10 -0
- typizer-0.1.0/typizer/models/me_role_type_3_type_1.py +10 -0
- typizer-0.1.0/typizer/models/me_user_type_0.py +86 -0
- typizer-0.1.0/typizer/models/my_consents.py +77 -0
- typizer-0.1.0/typizer/models/my_consents_object.py +8 -0
- typizer-0.1.0/typizer/models/organization.py +93 -0
- typizer-0.1.0/typizer/models/organization_object.py +8 -0
- typizer-0.1.0/typizer/models/organization_settings.py +74 -0
- typizer-0.1.0/typizer/models/organization_settings_file_retention.py +11 -0
- typizer-0.1.0/typizer/models/organization_settings_output_retention.py +10 -0
- typizer-0.1.0/typizer/models/payment.py +231 -0
- typizer-0.1.0/typizer/models/payment_act_type_0.py +136 -0
- typizer-0.1.0/typizer/models/payment_act_type_0_edo_type_0.py +112 -0
- typizer-0.1.0/typizer/models/payment_invoice_type_0.py +121 -0
- typizer-0.1.0/typizer/models/payment_invoice_type_0_status.py +11 -0
- typizer-0.1.0/typizer/models/payment_list.py +107 -0
- typizer-0.1.0/typizer/models/payment_list_object.py +8 -0
- typizer-0.1.0/typizer/models/payment_method.py +10 -0
- typizer-0.1.0/typizer/models/payment_object.py +8 -0
- typizer-0.1.0/typizer/models/payment_status.py +15 -0
- typizer-0.1.0/typizer/models/problem.py +158 -0
- typizer-0.1.0/typizer/models/problem_code.py +26 -0
- typizer-0.1.0/typizer/models/run.py +318 -0
- typizer-0.1.0/typizer/models/run_error_type_0.py +69 -0
- typizer-0.1.0/typizer/models/run_fields_type_0.py +45 -0
- typizer-0.1.0/typizer/models/run_file_type_0.py +69 -0
- typizer-0.1.0/typizer/models/run_format.py +11 -0
- typizer-0.1.0/typizer/models/run_metadata.py +45 -0
- typizer-0.1.0/typizer/models/run_mode.py +9 -0
- typizer-0.1.0/typizer/models/run_object.py +8 -0
- typizer-0.1.0/typizer/models/run_pages.py +82 -0
- typizer-0.1.0/typizer/models/run_source.py +12 -0
- typizer-0.1.0/typizer/models/run_status.py +11 -0
- typizer-0.1.0/typizer/models/save_agent_thread_request.py +63 -0
- typizer-0.1.0/typizer/models/save_agent_thread_response_200.py +47 -0
- typizer-0.1.0/typizer/models/save_agent_thread_response_201.py +47 -0
- typizer-0.1.0/typizer/models/scope.py +12 -0
- typizer-0.1.0/typizer/models/sign_in.py +94 -0
- typizer-0.1.0/typizer/models/sign_in_list.py +108 -0
- typizer-0.1.0/typizer/models/sign_in_list_object.py +8 -0
- typizer-0.1.0/typizer/models/sign_in_object.py +8 -0
- typizer-0.1.0/typizer/models/status.py +85 -0
- typizer-0.1.0/typizer/models/status_object.py +8 -0
- typizer-0.1.0/typizer/models/typizer.py +158 -0
- typizer-0.1.0/typizer/models/typizer_default_format.py +11 -0
- typizer-0.1.0/typizer/models/typizer_draft.py +97 -0
- typizer-0.1.0/typizer/models/typizer_draft_object.py +8 -0
- typizer-0.1.0/typizer/models/typizer_draft_schema.py +53 -0
- typizer-0.1.0/typizer/models/typizer_mode.py +9 -0
- typizer-0.1.0/typizer/models/typizer_object.py +8 -0
- typizer-0.1.0/typizer/models/typizer_schema.py +47 -0
- typizer-0.1.0/typizer/models/typizer_version.py +118 -0
- typizer-0.1.0/typizer/models/typizer_version_object.py +8 -0
- typizer-0.1.0/typizer/models/typizer_version_schema.py +45 -0
- typizer-0.1.0/typizer/models/update_agent_thread_request.py +80 -0
- typizer-0.1.0/typizer/models/update_agent_thread_request_draft_schema.py +53 -0
- typizer-0.1.0/typizer/models/update_autotopup_request.py +111 -0
- typizer-0.1.0/typizer/models/update_autotopup_request_consent.py +62 -0
- typizer-0.1.0/typizer/models/update_autotopup_request_package_code.py +12 -0
- typizer-0.1.0/typizer/models/update_billing_profile_request.py +127 -0
- typizer-0.1.0/typizer/models/update_organization_request.py +69 -0
- typizer-0.1.0/typizer/models/update_organization_request_file_retention.py +11 -0
- typizer-0.1.0/typizer/models/update_organization_request_output_retention.py +10 -0
- typizer-0.1.0/typizer/models/update_typizer_request.py +131 -0
- typizer-0.1.0/typizer/models/update_typizer_request_default_format.py +11 -0
- typizer-0.1.0/typizer/models/update_typizer_request_mode.py +9 -0
- typizer-0.1.0/typizer/models/update_typizer_request_schema.py +53 -0
- typizer-0.1.0/typizer/models/update_webhook_endpoint_request.py +83 -0
- typizer-0.1.0/typizer/models/update_webhook_endpoint_request_status.py +9 -0
- typizer-0.1.0/typizer/models/usage.py +119 -0
- typizer-0.1.0/typizer/models/usage_group_by.py +10 -0
- typizer-0.1.0/typizer/models/usage_object.py +8 -0
- typizer-0.1.0/typizer/models/usage_row.py +102 -0
- typizer-0.1.0/typizer/models/webhook_delivery.py +154 -0
- typizer-0.1.0/typizer/models/webhook_delivery_object.py +8 -0
- typizer-0.1.0/typizer/models/webhook_delivery_status.py +10 -0
- typizer-0.1.0/typizer/models/webhook_endpoint.py +156 -0
- typizer-0.1.0/typizer/models/webhook_endpoint_object.py +8 -0
- typizer-0.1.0/typizer/models/webhook_endpoint_status.py +9 -0
- typizer-0.1.0/typizer/models/webhook_event_type.py +11 -0
- typizer-0.1.0/typizer/py.typed +1 -0
- typizer-0.1.0/typizer/types.py +54 -0
typizer-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Typizer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
typizer-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: typizer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Официальный Python SDK для Typizer API — извлечение данных из документов в JSON по вашей схеме
|
|
5
|
+
Keywords: typizer,sdk,api,document extraction,document parsing,ocr,invoice,json schema,извлечение данных,распознавание документов,счета,УПД
|
|
6
|
+
Author: Typizer
|
|
7
|
+
Author-email: Typizer <support@typizer.ru>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: Russian
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Office/Business
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Dist: httpx>=0.23.1,<0.29.0
|
|
23
|
+
Requires-Dist: attrs>=22.2.0
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Project-URL: Homepage, https://typizer.ru
|
|
26
|
+
Project-URL: Documentation, https://docs.typizer.ru
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# typizer — Python SDK для Typizer API
|
|
30
|
+
|
|
31
|
+
Официальный Python SDK для [Typizer](https://typizer.ru) — сервиса, который извлекает данные из
|
|
32
|
+
документов (счета, УПД, накладные, договоры, сканы и фото) в JSON по вашей схеме.
|
|
33
|
+
|
|
34
|
+
SDK сгенерирован из OpenAPI-описания Typizer API: одна функция на каждую операцию REST API, с теми
|
|
35
|
+
же именами полей и кодами ошибок. Полная документация — [docs.typizer.ru](https://docs.typizer.ru).
|
|
36
|
+
|
|
37
|
+
## Установка
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install typizer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Нужен Python 3.11 или новее. Зависимости — только `httpx` и `attrs`.
|
|
44
|
+
|
|
45
|
+
## Ключ API
|
|
46
|
+
|
|
47
|
+
1. Зарегистрируйтесь в кабинете [my.typizer.ru](https://my.typizer.ru).
|
|
48
|
+
2. Откройте раздел «Ключи API» и создайте ключ со скоупом `runs:write` (для запуска прогонов) —
|
|
49
|
+
подробнее о скоупах в [«Ключах API»](https://docs.typizer.ru/how-to/api-keys/).
|
|
50
|
+
3. Ключ (`tz_live_…`) показывается один раз. Сохраните его, например в переменную окружения:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
export TYPIZER_API_KEY="tz_live_…"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Быстрый старт
|
|
57
|
+
|
|
58
|
+
Извлечь данные из документа по разовой схеме (`POST /v1/extract`). `wait=60` держит запрос до
|
|
59
|
+
завершения прогона, но не дольше 60 секунд:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import os
|
|
63
|
+
import uuid
|
|
64
|
+
|
|
65
|
+
import httpx
|
|
66
|
+
|
|
67
|
+
from typizer import AuthenticatedClient
|
|
68
|
+
from typizer.api.runs import extract
|
|
69
|
+
from typizer.models import ExtractRequest, ExtractRequestSchema, Problem, Run
|
|
70
|
+
|
|
71
|
+
client = AuthenticatedClient(
|
|
72
|
+
base_url="https://api.typizer.ru",
|
|
73
|
+
token=os.environ["TYPIZER_API_KEY"], # сам ключ, без слова Bearer
|
|
74
|
+
timeout=httpx.Timeout(70.0), # чуть больше, чем wait
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
schema = ExtractRequestSchema.from_dict(
|
|
78
|
+
{
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"invoice_number": {"type": "string"},
|
|
82
|
+
"total": {"type": "number"},
|
|
83
|
+
"inn": {"type": "string", "x-typizer-check": "inn"},
|
|
84
|
+
},
|
|
85
|
+
"required": ["invoice_number", "total"],
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
with client as client:
|
|
90
|
+
run = extract.sync(
|
|
91
|
+
client=client,
|
|
92
|
+
body=ExtractRequest(schema=schema, url="https://typizer.ru/samples/invoice.pdf"),
|
|
93
|
+
wait=60,
|
|
94
|
+
idempotency_key=str(uuid.uuid4()), # новый ключ на каждую операцию
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if isinstance(run, Problem):
|
|
98
|
+
raise RuntimeError(f"{run.code}: {run.detail} ({run.doc_url})")
|
|
99
|
+
assert isinstance(run, Run)
|
|
100
|
+
|
|
101
|
+
print(run.status) # succeeded | failed | queued | processing
|
|
102
|
+
print(run.output) # результат в формате JSON по вашей схеме
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Если прогон не успел завершиться за `wait`, придёт `Run` со статусом `queued` или `processing` —
|
|
106
|
+
дождитесь его через `typizer.api.runs.get_run` или вебхук (см. ниже и
|
|
107
|
+
[«Получить результат»](https://docs.typizer.ru/how-to/get-results/)).
|
|
108
|
+
|
|
109
|
+
## Типизатор: схема, сохранённая один раз
|
|
110
|
+
|
|
111
|
+
Схему удобно сохранить как типизатор (`POST /v1/typizers`) и запускать его по `id`:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import os
|
|
115
|
+
import uuid
|
|
116
|
+
|
|
117
|
+
from typizer import AuthenticatedClient
|
|
118
|
+
from typizer.api.runs import create_run
|
|
119
|
+
from typizer.api.typizers import create_typizer
|
|
120
|
+
from typizer.models import CreateRunRequest, CreateTypizerRequest, CreateTypizerRequestSchema, Typizer
|
|
121
|
+
|
|
122
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
123
|
+
|
|
124
|
+
with client as client:
|
|
125
|
+
typizer = create_typizer.sync(
|
|
126
|
+
client=client,
|
|
127
|
+
body=CreateTypizerRequest(
|
|
128
|
+
name="Счета поставщиков",
|
|
129
|
+
schema=CreateTypizerRequestSchema.from_dict(
|
|
130
|
+
{
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"invoice_number": {"type": "string"},
|
|
134
|
+
"total": {"type": "number"},
|
|
135
|
+
},
|
|
136
|
+
"required": ["invoice_number", "total"],
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
)
|
|
141
|
+
assert isinstance(typizer, Typizer)
|
|
142
|
+
|
|
143
|
+
run = create_run.sync(
|
|
144
|
+
typizer.id,
|
|
145
|
+
client=client,
|
|
146
|
+
body=CreateRunRequest(url="https://typizer.ru/samples/invoice.pdf"),
|
|
147
|
+
wait=60,
|
|
148
|
+
idempotency_key=str(uuid.uuid4()),
|
|
149
|
+
)
|
|
150
|
+
print(run)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Файл с диска передаётся через multipart: `CreateRunFilesBody(file=File(payload=f, file_name="invoice.pdf"))`
|
|
154
|
+
(`File` — из `typizer.types`), для `extract` — `ExtractFilesBody`.
|
|
155
|
+
|
|
156
|
+
## Синхронные и асинхронные вызовы
|
|
157
|
+
|
|
158
|
+
Каждая операция — отдельный модуль `typizer.api.<тег>.<операция>` (например,
|
|
159
|
+
`typizer.api.runs.extract`) с четырьмя функциями:
|
|
160
|
+
|
|
161
|
+
| Функция | Что возвращает |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `sync(...)` | разобранную модель (`Run`, `Typizer`, …), объект ошибки `Problem` или `None` |
|
|
164
|
+
| `sync_detailed(...)` | `Response`: `status_code`, `headers`, `content` и `parsed` |
|
|
165
|
+
| `asyncio(...)` | то же, что `sync`, но `async` |
|
|
166
|
+
| `asyncio_detailed(...)` | то же, что `sync_detailed`, но `async` |
|
|
167
|
+
|
|
168
|
+
Асинхронный вариант того же запроса:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
import asyncio
|
|
172
|
+
import os
|
|
173
|
+
|
|
174
|
+
from typizer import AuthenticatedClient
|
|
175
|
+
from typizer.api.runs import get_run
|
|
176
|
+
from typizer.models import Run
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
async def main() -> None:
|
|
180
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
181
|
+
async with client as client:
|
|
182
|
+
run = await get_run.asyncio("run_…", client=client)
|
|
183
|
+
if isinstance(run, Run):
|
|
184
|
+
print(run.status)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
asyncio.run(main())
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Обработка ошибок
|
|
191
|
+
|
|
192
|
+
Любая ошибка API приходит в формате `application/problem+json` (RFC 9457). SDK не бросает
|
|
193
|
+
исключение на документированный код ошибки — `sync`/`asyncio` возвращают объект `Problem`:
|
|
194
|
+
|
|
195
|
+
- `code` — машиночитаемый код (`ProblemCode`: `invalid_request`, `unauthorized`,
|
|
196
|
+
`insufficient_balance`, `rate_limited`, …);
|
|
197
|
+
- `detail` — описание конкретного случая, `param` — поле запроса, если виновато оно;
|
|
198
|
+
- `doc_url` — страница этого кода: `https://docs.typizer.ru/errors/<code>/`;
|
|
199
|
+
- `request_id` — приложите его к обращению в поддержку (support@typizer.ru).
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
import os
|
|
203
|
+
import uuid
|
|
204
|
+
|
|
205
|
+
from typizer import AuthenticatedClient
|
|
206
|
+
from typizer.api.runs import create_run
|
|
207
|
+
from typizer.models import CreateRunRequest, Problem, ProblemCode
|
|
208
|
+
|
|
209
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
210
|
+
|
|
211
|
+
response = create_run.sync_detailed(
|
|
212
|
+
"tz_…",
|
|
213
|
+
client=client,
|
|
214
|
+
body=CreateRunRequest(url="https://typizer.ru/samples/invoice.pdf"),
|
|
215
|
+
idempotency_key=str(uuid.uuid4()),
|
|
216
|
+
)
|
|
217
|
+
problem = response.parsed
|
|
218
|
+
if isinstance(problem, Problem):
|
|
219
|
+
if problem.code == ProblemCode.RATE_LIMITED:
|
|
220
|
+
print("повторить через", response.headers.get("Retry-After"), "с")
|
|
221
|
+
elif problem.code == ProblemCode.INSUFFICIENT_BALANCE:
|
|
222
|
+
print("пополните баланс в кабинете")
|
|
223
|
+
else:
|
|
224
|
+
print(problem.code, problem.detail, problem.doc_url, problem.request_id)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Повторять имеет смысл `rate_limited` (после `Retry-After`), `upstream_unavailable` и
|
|
228
|
+
`internal_error`; при сетевой ошибке повторяйте запрос с тем же `Idempotency-Key` — второй раз
|
|
229
|
+
ничего не создастся и не спишется. Остальные коды не исчезнут от повтора: сначала исправьте причину.
|
|
230
|
+
Все коды со статусами HTTP — [«Коды ошибок»](https://docs.typizer.ru/reference/errors/), правила
|
|
231
|
+
повторов — [«Обработка ошибок и повторов»](https://docs.typizer.ru/how-to/errors/).
|
|
232
|
+
|
|
233
|
+
Кроме `Problem`, возможны исключения транспортного уровня: `httpx.TimeoutException` (истёк
|
|
234
|
+
`timeout` клиента) и `typizer.errors.UnexpectedStatus` — только если клиент создан с
|
|
235
|
+
`raise_on_unexpected_status=True` и сервер вернул код, которого нет в описании API.
|
|
236
|
+
|
|
237
|
+
## Вебхуки
|
|
238
|
+
|
|
239
|
+
Вместо ожидания результат можно получать вебхуком: укажите `webhook_url` в запросе на прогон или
|
|
240
|
+
создайте конечную точку через `typizer.api.webhooks.create_webhook_endpoint`:
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
import os
|
|
244
|
+
|
|
245
|
+
from typizer import AuthenticatedClient
|
|
246
|
+
from typizer.api.webhooks import create_webhook_endpoint, test_webhook_endpoint
|
|
247
|
+
from typizer.models import CreateWebhookEndpointRequest, WebhookEndpoint, WebhookEventType
|
|
248
|
+
|
|
249
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
250
|
+
|
|
251
|
+
endpoint = create_webhook_endpoint.sync(
|
|
252
|
+
client=client,
|
|
253
|
+
body=CreateWebhookEndpointRequest(
|
|
254
|
+
url="https://your-server.example/typizer/webhook",
|
|
255
|
+
events=[WebhookEventType.RUN_SUCCEEDED, WebhookEventType.RUN_FAILED],
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
assert isinstance(endpoint, WebhookEndpoint)
|
|
259
|
+
print(endpoint.secret) # whsec_… — ключ для проверки подписи, храните как секрет
|
|
260
|
+
|
|
261
|
+
test_webhook_endpoint.sync(endpoint.id, client=client) # пришлёт тестовый run.succeeded
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Вебхуки подписываются по спецификации [Standard Webhooks](https://www.standardwebhooks.com)
|
|
265
|
+
(HMAC-SHA256). Функции проверки подписи в SDK нет: готовая реализация на `hmac`/`hashlib` без
|
|
266
|
+
сторонних пакетов и тестовый вектор — в [«Приёме вебхуков»](https://docs.typizer.ru/how-to/webhooks/).
|
|
267
|
+
Никогда не обрабатывайте тело вебхука, не проверив подпись.
|
|
268
|
+
|
|
269
|
+
## Документация
|
|
270
|
+
|
|
271
|
+
- [Документация Typizer](https://docs.typizer.ru)
|
|
272
|
+
- [SDK для TypeScript и Python](https://docs.typizer.ru/reference/sdks/)
|
|
273
|
+
- [Справочник API](https://docs.typizer.ru/reference/api/) — REST-операция за каждой функцией SDK
|
|
274
|
+
- [Первый вызов API](https://docs.typizer.ru/tutorials/first-api-call/)
|
|
275
|
+
|
|
276
|
+
Вопросы и проблемы — support@typizer.ru.
|
|
277
|
+
|
|
278
|
+
## Лицензия
|
|
279
|
+
|
|
280
|
+
MIT — см. файл [LICENSE](LICENSE).
|
typizer-0.1.0/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# typizer — Python SDK для Typizer API
|
|
2
|
+
|
|
3
|
+
Официальный Python SDK для [Typizer](https://typizer.ru) — сервиса, который извлекает данные из
|
|
4
|
+
документов (счета, УПД, накладные, договоры, сканы и фото) в JSON по вашей схеме.
|
|
5
|
+
|
|
6
|
+
SDK сгенерирован из OpenAPI-описания Typizer API: одна функция на каждую операцию REST API, с теми
|
|
7
|
+
же именами полей и кодами ошибок. Полная документация — [docs.typizer.ru](https://docs.typizer.ru).
|
|
8
|
+
|
|
9
|
+
## Установка
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install typizer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Нужен Python 3.11 или новее. Зависимости — только `httpx` и `attrs`.
|
|
16
|
+
|
|
17
|
+
## Ключ API
|
|
18
|
+
|
|
19
|
+
1. Зарегистрируйтесь в кабинете [my.typizer.ru](https://my.typizer.ru).
|
|
20
|
+
2. Откройте раздел «Ключи API» и создайте ключ со скоупом `runs:write` (для запуска прогонов) —
|
|
21
|
+
подробнее о скоупах в [«Ключах API»](https://docs.typizer.ru/how-to/api-keys/).
|
|
22
|
+
3. Ключ (`tz_live_…`) показывается один раз. Сохраните его, например в переменную окружения:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
export TYPIZER_API_KEY="tz_live_…"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Быстрый старт
|
|
29
|
+
|
|
30
|
+
Извлечь данные из документа по разовой схеме (`POST /v1/extract`). `wait=60` держит запрос до
|
|
31
|
+
завершения прогона, но не дольше 60 секунд:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import os
|
|
35
|
+
import uuid
|
|
36
|
+
|
|
37
|
+
import httpx
|
|
38
|
+
|
|
39
|
+
from typizer import AuthenticatedClient
|
|
40
|
+
from typizer.api.runs import extract
|
|
41
|
+
from typizer.models import ExtractRequest, ExtractRequestSchema, Problem, Run
|
|
42
|
+
|
|
43
|
+
client = AuthenticatedClient(
|
|
44
|
+
base_url="https://api.typizer.ru",
|
|
45
|
+
token=os.environ["TYPIZER_API_KEY"], # сам ключ, без слова Bearer
|
|
46
|
+
timeout=httpx.Timeout(70.0), # чуть больше, чем wait
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
schema = ExtractRequestSchema.from_dict(
|
|
50
|
+
{
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"invoice_number": {"type": "string"},
|
|
54
|
+
"total": {"type": "number"},
|
|
55
|
+
"inn": {"type": "string", "x-typizer-check": "inn"},
|
|
56
|
+
},
|
|
57
|
+
"required": ["invoice_number", "total"],
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
with client as client:
|
|
62
|
+
run = extract.sync(
|
|
63
|
+
client=client,
|
|
64
|
+
body=ExtractRequest(schema=schema, url="https://typizer.ru/samples/invoice.pdf"),
|
|
65
|
+
wait=60,
|
|
66
|
+
idempotency_key=str(uuid.uuid4()), # новый ключ на каждую операцию
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if isinstance(run, Problem):
|
|
70
|
+
raise RuntimeError(f"{run.code}: {run.detail} ({run.doc_url})")
|
|
71
|
+
assert isinstance(run, Run)
|
|
72
|
+
|
|
73
|
+
print(run.status) # succeeded | failed | queued | processing
|
|
74
|
+
print(run.output) # результат в формате JSON по вашей схеме
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Если прогон не успел завершиться за `wait`, придёт `Run` со статусом `queued` или `processing` —
|
|
78
|
+
дождитесь его через `typizer.api.runs.get_run` или вебхук (см. ниже и
|
|
79
|
+
[«Получить результат»](https://docs.typizer.ru/how-to/get-results/)).
|
|
80
|
+
|
|
81
|
+
## Типизатор: схема, сохранённая один раз
|
|
82
|
+
|
|
83
|
+
Схему удобно сохранить как типизатор (`POST /v1/typizers`) и запускать его по `id`:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import os
|
|
87
|
+
import uuid
|
|
88
|
+
|
|
89
|
+
from typizer import AuthenticatedClient
|
|
90
|
+
from typizer.api.runs import create_run
|
|
91
|
+
from typizer.api.typizers import create_typizer
|
|
92
|
+
from typizer.models import CreateRunRequest, CreateTypizerRequest, CreateTypizerRequestSchema, Typizer
|
|
93
|
+
|
|
94
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
95
|
+
|
|
96
|
+
with client as client:
|
|
97
|
+
typizer = create_typizer.sync(
|
|
98
|
+
client=client,
|
|
99
|
+
body=CreateTypizerRequest(
|
|
100
|
+
name="Счета поставщиков",
|
|
101
|
+
schema=CreateTypizerRequestSchema.from_dict(
|
|
102
|
+
{
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"invoice_number": {"type": "string"},
|
|
106
|
+
"total": {"type": "number"},
|
|
107
|
+
},
|
|
108
|
+
"required": ["invoice_number", "total"],
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
assert isinstance(typizer, Typizer)
|
|
114
|
+
|
|
115
|
+
run = create_run.sync(
|
|
116
|
+
typizer.id,
|
|
117
|
+
client=client,
|
|
118
|
+
body=CreateRunRequest(url="https://typizer.ru/samples/invoice.pdf"),
|
|
119
|
+
wait=60,
|
|
120
|
+
idempotency_key=str(uuid.uuid4()),
|
|
121
|
+
)
|
|
122
|
+
print(run)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Файл с диска передаётся через multipart: `CreateRunFilesBody(file=File(payload=f, file_name="invoice.pdf"))`
|
|
126
|
+
(`File` — из `typizer.types`), для `extract` — `ExtractFilesBody`.
|
|
127
|
+
|
|
128
|
+
## Синхронные и асинхронные вызовы
|
|
129
|
+
|
|
130
|
+
Каждая операция — отдельный модуль `typizer.api.<тег>.<операция>` (например,
|
|
131
|
+
`typizer.api.runs.extract`) с четырьмя функциями:
|
|
132
|
+
|
|
133
|
+
| Функция | Что возвращает |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `sync(...)` | разобранную модель (`Run`, `Typizer`, …), объект ошибки `Problem` или `None` |
|
|
136
|
+
| `sync_detailed(...)` | `Response`: `status_code`, `headers`, `content` и `parsed` |
|
|
137
|
+
| `asyncio(...)` | то же, что `sync`, но `async` |
|
|
138
|
+
| `asyncio_detailed(...)` | то же, что `sync_detailed`, но `async` |
|
|
139
|
+
|
|
140
|
+
Асинхронный вариант того же запроса:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
import asyncio
|
|
144
|
+
import os
|
|
145
|
+
|
|
146
|
+
from typizer import AuthenticatedClient
|
|
147
|
+
from typizer.api.runs import get_run
|
|
148
|
+
from typizer.models import Run
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
async def main() -> None:
|
|
152
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
153
|
+
async with client as client:
|
|
154
|
+
run = await get_run.asyncio("run_…", client=client)
|
|
155
|
+
if isinstance(run, Run):
|
|
156
|
+
print(run.status)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
asyncio.run(main())
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Обработка ошибок
|
|
163
|
+
|
|
164
|
+
Любая ошибка API приходит в формате `application/problem+json` (RFC 9457). SDK не бросает
|
|
165
|
+
исключение на документированный код ошибки — `sync`/`asyncio` возвращают объект `Problem`:
|
|
166
|
+
|
|
167
|
+
- `code` — машиночитаемый код (`ProblemCode`: `invalid_request`, `unauthorized`,
|
|
168
|
+
`insufficient_balance`, `rate_limited`, …);
|
|
169
|
+
- `detail` — описание конкретного случая, `param` — поле запроса, если виновато оно;
|
|
170
|
+
- `doc_url` — страница этого кода: `https://docs.typizer.ru/errors/<code>/`;
|
|
171
|
+
- `request_id` — приложите его к обращению в поддержку (support@typizer.ru).
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
import os
|
|
175
|
+
import uuid
|
|
176
|
+
|
|
177
|
+
from typizer import AuthenticatedClient
|
|
178
|
+
from typizer.api.runs import create_run
|
|
179
|
+
from typizer.models import CreateRunRequest, Problem, ProblemCode
|
|
180
|
+
|
|
181
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
182
|
+
|
|
183
|
+
response = create_run.sync_detailed(
|
|
184
|
+
"tz_…",
|
|
185
|
+
client=client,
|
|
186
|
+
body=CreateRunRequest(url="https://typizer.ru/samples/invoice.pdf"),
|
|
187
|
+
idempotency_key=str(uuid.uuid4()),
|
|
188
|
+
)
|
|
189
|
+
problem = response.parsed
|
|
190
|
+
if isinstance(problem, Problem):
|
|
191
|
+
if problem.code == ProblemCode.RATE_LIMITED:
|
|
192
|
+
print("повторить через", response.headers.get("Retry-After"), "с")
|
|
193
|
+
elif problem.code == ProblemCode.INSUFFICIENT_BALANCE:
|
|
194
|
+
print("пополните баланс в кабинете")
|
|
195
|
+
else:
|
|
196
|
+
print(problem.code, problem.detail, problem.doc_url, problem.request_id)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Повторять имеет смысл `rate_limited` (после `Retry-After`), `upstream_unavailable` и
|
|
200
|
+
`internal_error`; при сетевой ошибке повторяйте запрос с тем же `Idempotency-Key` — второй раз
|
|
201
|
+
ничего не создастся и не спишется. Остальные коды не исчезнут от повтора: сначала исправьте причину.
|
|
202
|
+
Все коды со статусами HTTP — [«Коды ошибок»](https://docs.typizer.ru/reference/errors/), правила
|
|
203
|
+
повторов — [«Обработка ошибок и повторов»](https://docs.typizer.ru/how-to/errors/).
|
|
204
|
+
|
|
205
|
+
Кроме `Problem`, возможны исключения транспортного уровня: `httpx.TimeoutException` (истёк
|
|
206
|
+
`timeout` клиента) и `typizer.errors.UnexpectedStatus` — только если клиент создан с
|
|
207
|
+
`raise_on_unexpected_status=True` и сервер вернул код, которого нет в описании API.
|
|
208
|
+
|
|
209
|
+
## Вебхуки
|
|
210
|
+
|
|
211
|
+
Вместо ожидания результат можно получать вебхуком: укажите `webhook_url` в запросе на прогон или
|
|
212
|
+
создайте конечную точку через `typizer.api.webhooks.create_webhook_endpoint`:
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
import os
|
|
216
|
+
|
|
217
|
+
from typizer import AuthenticatedClient
|
|
218
|
+
from typizer.api.webhooks import create_webhook_endpoint, test_webhook_endpoint
|
|
219
|
+
from typizer.models import CreateWebhookEndpointRequest, WebhookEndpoint, WebhookEventType
|
|
220
|
+
|
|
221
|
+
client = AuthenticatedClient(base_url="https://api.typizer.ru", token=os.environ["TYPIZER_API_KEY"])
|
|
222
|
+
|
|
223
|
+
endpoint = create_webhook_endpoint.sync(
|
|
224
|
+
client=client,
|
|
225
|
+
body=CreateWebhookEndpointRequest(
|
|
226
|
+
url="https://your-server.example/typizer/webhook",
|
|
227
|
+
events=[WebhookEventType.RUN_SUCCEEDED, WebhookEventType.RUN_FAILED],
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
assert isinstance(endpoint, WebhookEndpoint)
|
|
231
|
+
print(endpoint.secret) # whsec_… — ключ для проверки подписи, храните как секрет
|
|
232
|
+
|
|
233
|
+
test_webhook_endpoint.sync(endpoint.id, client=client) # пришлёт тестовый run.succeeded
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Вебхуки подписываются по спецификации [Standard Webhooks](https://www.standardwebhooks.com)
|
|
237
|
+
(HMAC-SHA256). Функции проверки подписи в SDK нет: готовая реализация на `hmac`/`hashlib` без
|
|
238
|
+
сторонних пакетов и тестовый вектор — в [«Приёме вебхуков»](https://docs.typizer.ru/how-to/webhooks/).
|
|
239
|
+
Никогда не обрабатывайте тело вебхука, не проверив подпись.
|
|
240
|
+
|
|
241
|
+
## Документация
|
|
242
|
+
|
|
243
|
+
- [Документация Typizer](https://docs.typizer.ru)
|
|
244
|
+
- [SDK для TypeScript и Python](https://docs.typizer.ru/reference/sdks/)
|
|
245
|
+
- [Справочник API](https://docs.typizer.ru/reference/api/) — REST-операция за каждой функцией SDK
|
|
246
|
+
- [Первый вызов API](https://docs.typizer.ru/tutorials/first-api-call/)
|
|
247
|
+
|
|
248
|
+
Вопросы и проблемы — support@typizer.ru.
|
|
249
|
+
|
|
250
|
+
## Лицензия
|
|
251
|
+
|
|
252
|
+
MIT — см. файл [LICENSE](LICENSE).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "typizer"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Официальный Python SDK для Typizer API — извлечение данных из документов в JSON по вашей схеме"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
license-files = ["LICENSE"]
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
keywords = [
|
|
10
|
+
"typizer",
|
|
11
|
+
"sdk",
|
|
12
|
+
"api",
|
|
13
|
+
"document extraction",
|
|
14
|
+
"document parsing",
|
|
15
|
+
"ocr",
|
|
16
|
+
"invoice",
|
|
17
|
+
"json schema",
|
|
18
|
+
"извлечение данных",
|
|
19
|
+
"распознавание документов",
|
|
20
|
+
"счета",
|
|
21
|
+
"УПД",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Natural Language :: Russian",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Topic :: Office/Business",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
"Typing :: Typed",
|
|
36
|
+
]
|
|
37
|
+
dependencies = [
|
|
38
|
+
"httpx>=0.23.1,<0.29.0",
|
|
39
|
+
"attrs>=22.2.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[[project.authors]]
|
|
43
|
+
name = "Typizer"
|
|
44
|
+
email = "support@typizer.ru"
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://typizer.ru"
|
|
48
|
+
Documentation = "https://docs.typizer.ru"
|
|
49
|
+
|
|
50
|
+
[tool.uv.build-backend]
|
|
51
|
+
module-name = "typizer"
|
|
52
|
+
module-root = ""
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
line-length = 120
|
|
56
|
+
|
|
57
|
+
[tool.ruff.lint]
|
|
58
|
+
select = [
|
|
59
|
+
"F",
|
|
60
|
+
"I",
|
|
61
|
+
"UP",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
testpaths = ["tests"]
|
|
66
|
+
|
|
67
|
+
[build-system]
|
|
68
|
+
requires = ["uv_build>=0.12.0,<0.13.0"]
|
|
69
|
+
build-backend = "uv_build"
|
|
70
|
+
|
|
71
|
+
[dependency-groups]
|
|
72
|
+
dev = ["pytest>=8.4"]
|