arkruntime 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arkruntime/__init__.py +11 -0
- arkruntime/_base_client.py +1373 -0
- arkruntime/_client.py +585 -0
- arkruntime/_compat.py +265 -0
- arkruntime/_constants.py +55 -0
- arkruntime/_exceptions.py +188 -0
- arkruntime/_files.py +122 -0
- arkruntime/_legacy_response.py +438 -0
- arkruntime/_managed_agents_serialize.py +55 -0
- arkruntime/_models.py +733 -0
- arkruntime/_qs.py +164 -0
- arkruntime/_request_options.py +118 -0
- arkruntime/_resource.py +41 -0
- arkruntime/_response.py +599 -0
- arkruntime/_streaming.py +460 -0
- arkruntime/_types.py +207 -0
- arkruntime/_utils/__init__.py +144 -0
- arkruntime/_utils/_key_agreement.py +217 -0
- arkruntime/_utils/_logs.py +28 -0
- arkruntime/_utils/_model_breaker.py +87 -0
- arkruntime/_utils/_streams.py +17 -0
- arkruntime/_utils/_transform.py +463 -0
- arkruntime/_utils/_typing.py +157 -0
- arkruntime/_utils/_utils.py +473 -0
- arkruntime/common/__init__.py +6 -0
- arkruntime/common/_parsing/__init__.py +31 -0
- arkruntime/common/_parsing/_completions.py +272 -0
- arkruntime/common/_parsing/_responses.py +174 -0
- arkruntime/common/_pydantic.py +166 -0
- arkruntime/common/_tools.py +85 -0
- arkruntime/common/streaming/__init__.py +4 -0
- arkruntime/common/streaming/_deltas.py +68 -0
- arkruntime/common/streaming/chat/__init__.py +49 -0
- arkruntime/common/streaming/chat/_completions.py +732 -0
- arkruntime/common/streaming/chat/_events.py +96 -0
- arkruntime/common/streaming/chat/_types.py +28 -0
- arkruntime/pagination.py +128 -0
- arkruntime/resources/__init__.py +75 -0
- arkruntime/resources/agents/__init__.py +3 -0
- arkruntime/resources/agents/agents.py +372 -0
- arkruntime/resources/batch/__init__.py +6 -0
- arkruntime/resources/batch/_utils.py +156 -0
- arkruntime/resources/batch/batch.py +40 -0
- arkruntime/resources/batch/chat/__init__.py +6 -0
- arkruntime/resources/batch/chat/chat.py +22 -0
- arkruntime/resources/batch/chat/completions.py +217 -0
- arkruntime/resources/batch/embeddings.py +150 -0
- arkruntime/resources/batch/multimodal_embeddings.py +160 -0
- arkruntime/resources/beta/__init__.py +4 -0
- arkruntime/resources/beta/beta.py +73 -0
- arkruntime/resources/beta/chat/__init__.py +13 -0
- arkruntime/resources/beta/chat/chat.py +23 -0
- arkruntime/resources/beta/chat/completions.py +356 -0
- arkruntime/resources/chat/__init__.py +7 -0
- arkruntime/resources/chat/chat.py +23 -0
- arkruntime/resources/chat/completions.py +242 -0
- arkruntime/resources/content_generation/__init__.py +7 -0
- arkruntime/resources/content_generation/content_generation.py +21 -0
- arkruntime/resources/content_generation/tasks.py +331 -0
- arkruntime/resources/embeddings/__init__.py +6 -0
- arkruntime/resources/embeddings/embeddings.py +140 -0
- arkruntime/resources/encryption.py +187 -0
- arkruntime/resources/environments/__init__.py +3 -0
- arkruntime/resources/environments/environments.py +216 -0
- arkruntime/resources/files/__init__.py +6 -0
- arkruntime/resources/files/files.py +401 -0
- arkruntime/resources/images/__init__.py +10 -0
- arkruntime/resources/images/images.py +152 -0
- arkruntime/resources/memory_stores/__init__.py +7 -0
- arkruntime/resources/memory_stores/memories.py +262 -0
- arkruntime/resources/memory_stores/memory_stores.py +223 -0
- arkruntime/resources/multimodal_embeddings/__init__.py +9 -0
- arkruntime/resources/multimodal_embeddings/multimodal_embeddings.py +150 -0
- arkruntime/resources/responses/__init__.py +8 -0
- arkruntime/resources/responses/input_items.py +241 -0
- arkruntime/resources/responses/responses.py +467 -0
- arkruntime/resources/sessions/__init__.py +24 -0
- arkruntime/resources/sessions/session_events.py +336 -0
- arkruntime/resources/sessions/session_resources.py +89 -0
- arkruntime/resources/sessions/session_threads.py +275 -0
- arkruntime/resources/sessions/sessions.py +331 -0
- arkruntime/resources/skills/__init__.py +3 -0
- arkruntime/resources/skills/skills.py +112 -0
- arkruntime/resources/tokenization/__init__.py +9 -0
- arkruntime/resources/tokenization/tokenization.py +131 -0
- arkruntime/resources/vaults/__init__.py +4 -0
- arkruntime/resources/vaults/credentials.py +253 -0
- arkruntime/resources/vaults/vaults.py +197 -0
- arkruntime/types/__init__.py +7 -0
- arkruntime/types/agent/__init__.py +56 -0
- arkruntime/types/agent/_init_extras_shim.py +12 -0
- arkruntime/types/agent/agent.py +86 -0
- arkruntime/types/agent/agent_ref.py +32 -0
- arkruntime/types/agent/agent_ref_type.py +18 -0
- arkruntime/types/agent/agent_skill_ref.py +32 -0
- arkruntime/types/agent/create_agent_request.py +65 -0
- arkruntime/types/agent/delete_agent_response.py +20 -0
- arkruntime/types/agent/list_agents_response.py +32 -0
- arkruntime/types/agent/mcp_server.py +30 -0
- arkruntime/types/agent/mcp_server_type.py +16 -0
- arkruntime/types/agent/model_config.py +28 -0
- arkruntime/types/agent/model_speed.py +18 -0
- arkruntime/types/agent/multiagent_config.py +29 -0
- arkruntime/types/agent/multiagent_type.py +16 -0
- arkruntime/types/agent/permission_policy.py +22 -0
- arkruntime/types/agent/permission_policy_type.py +18 -0
- arkruntime/types/agent/skill_ref_type.py +19 -0
- arkruntime/types/agent/tag.py +26 -0
- arkruntime/types/agent/tool_config.py +32 -0
- arkruntime/types/agent/tool_default_config.py +28 -0
- arkruntime/types/agent/tool_item.py +57 -0
- arkruntime/types/agent/update_agent_request.py +70 -0
- arkruntime/types/chat/__init__.py +212 -0
- arkruntime/types/chat/_init_extras_shim.py +73 -0
- arkruntime/types/chat/chat_completion_choice_logprobs.py +20 -0
- arkruntime/types/chat/chat_completion_content_part.py +32 -0
- arkruntime/types/chat/chat_completion_content_part_audio.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_audio_input_audio.py +30 -0
- arkruntime/types/chat/chat_completion_content_part_audio_input_audio_param.py +25 -0
- arkruntime/types/chat/chat_completion_content_part_audio_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_file.py +21 -0
- arkruntime/types/chat/chat_completion_content_part_file_file.py +30 -0
- arkruntime/types/chat/chat_completion_content_part_file_file_param.py +25 -0
- arkruntime/types/chat/chat_completion_content_part_file_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_image.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_image_image_url.py +33 -0
- arkruntime/types/chat/chat_completion_content_part_image_image_url_param.py +28 -0
- arkruntime/types/chat/chat_completion_content_part_image_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_param.py +29 -0
- arkruntime/types/chat/chat_completion_content_part_text.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_text_param.py +19 -0
- arkruntime/types/chat/chat_completion_content_part_video.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_video_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_video_video_url.py +36 -0
- arkruntime/types/chat/chat_completion_content_part_video_video_url_param.py +30 -0
- arkruntime/types/chat/chat_completion_message_content.py +17 -0
- arkruntime/types/chat/chat_completion_message_content_param.py +15 -0
- arkruntime/types/chat/chat_completion_message_tool_call.py +29 -0
- arkruntime/types/chat/chat_completion_message_tool_call_chunk.py +31 -0
- arkruntime/types/chat/chat_completion_message_tool_call_chunk_function.py +16 -0
- arkruntime/types/chat/chat_completion_message_tool_call_function.py +23 -0
- arkruntime/types/chat/chat_completion_message_tool_call_function_param.py +22 -0
- arkruntime/types/chat/chat_completion_message_tool_call_param.py +26 -0
- arkruntime/types/chat/chat_completion_named_tool_choice.py +21 -0
- arkruntime/types/chat/chat_completion_named_tool_choice_param.py +22 -0
- arkruntime/types/chat/chat_completion_request.py +129 -0
- arkruntime/types/chat/chat_completion_request_assistant_message.py +39 -0
- arkruntime/types/chat/chat_completion_request_assistant_message_param.py +36 -0
- arkruntime/types/chat/chat_completion_request_message.py +32 -0
- arkruntime/types/chat/chat_completion_request_message_param.py +29 -0
- arkruntime/types/chat/chat_completion_request_param.py +122 -0
- arkruntime/types/chat/chat_completion_request_system_message.py +25 -0
- arkruntime/types/chat/chat_completion_request_system_message_param.py +23 -0
- arkruntime/types/chat/chat_completion_request_tool_message.py +29 -0
- arkruntime/types/chat/chat_completion_request_tool_message_param.py +26 -0
- arkruntime/types/chat/chat_completion_request_user_message.py +29 -0
- arkruntime/types/chat/chat_completion_request_user_message_param.py +27 -0
- arkruntime/types/chat/chat_completion_response.py +52 -0
- arkruntime/types/chat/chat_completion_response_choice.py +36 -0
- arkruntime/types/chat/chat_completion_response_format.py +28 -0
- arkruntime/types/chat/chat_completion_response_format_json_schema.py +33 -0
- arkruntime/types/chat/chat_completion_response_format_json_schema_param.py +31 -0
- arkruntime/types/chat/chat_completion_response_format_param.py +27 -0
- arkruntime/types/chat/chat_completion_response_message.py +37 -0
- arkruntime/types/chat/chat_completion_role.py +16 -0
- arkruntime/types/chat/chat_completion_service_status.py +17 -0
- arkruntime/types/chat/chat_completion_stop.py +13 -0
- arkruntime/types/chat/chat_completion_stop_param.py +11 -0
- arkruntime/types/chat/chat_completion_stream_choice_logprobs.py +17 -0
- arkruntime/types/chat/chat_completion_stream_options.py +22 -0
- arkruntime/types/chat/chat_completion_stream_options_param.py +19 -0
- arkruntime/types/chat/chat_completion_stream_response.py +34 -0
- arkruntime/types/chat/chat_completion_stream_response_choice.py +27 -0
- arkruntime/types/chat/chat_completion_stream_response_delta.py +36 -0
- arkruntime/types/chat/chat_completion_token_logprob.py +26 -0
- arkruntime/types/chat/chat_completion_token_logprob_top_logprob.py +17 -0
- arkruntime/types/chat/chat_completion_tool.py +20 -0
- arkruntime/types/chat/chat_completion_tool_choice.py +18 -0
- arkruntime/types/chat/chat_completion_tool_choice_function.py +13 -0
- arkruntime/types/chat/chat_completion_tool_choice_function_param.py +13 -0
- arkruntime/types/chat/chat_completion_tool_choice_param.py +16 -0
- arkruntime/types/chat/chat_completion_tool_param.py +20 -0
- arkruntime/types/chat/completion_tokens_details.py +16 -0
- arkruntime/types/chat/completion_usage.py +35 -0
- arkruntime/types/chat/error.py +28 -0
- arkruntime/types/chat/error_response.py +15 -0
- arkruntime/types/chat/finish_reason.py +16 -0
- arkruntime/types/chat/function_object.py +35 -0
- arkruntime/types/chat/function_object_param.py +38 -0
- arkruntime/types/chat/image_detail.py +16 -0
- arkruntime/types/chat/image_pixel_limit.py +16 -0
- arkruntime/types/chat/image_pixel_limit_param.py +17 -0
- arkruntime/types/chat/model_fallback_status.py +20 -0
- arkruntime/types/chat/moderation_hit_type.py +14 -0
- arkruntime/types/chat/parsed_chat_completion_shim.py +52 -0
- arkruntime/types/chat/parsed_function_tool_call_shim.py +29 -0
- arkruntime/types/chat/prompt_tokens_details.py +34 -0
- arkruntime/types/chat/reasoning_effort.py +19 -0
- arkruntime/types/chat/request_service_tier.py +15 -0
- arkruntime/types/chat/response_format_type.py +15 -0
- arkruntime/types/chat/response_service_tier.py +15 -0
- arkruntime/types/chat/thinking.py +17 -0
- arkruntime/types/chat/thinking_mode.py +15 -0
- arkruntime/types/chat/thinking_param.py +17 -0
- arkruntime/types/chat/tool_choice_mode.py +15 -0
- arkruntime/types/chat/tool_type.py +13 -0
- arkruntime/types/chat/tool_type_param.py +11 -0
- arkruntime/types/chat/video_image_pixel_limit.py +16 -0
- arkruntime/types/chat/video_image_pixel_limit_param.py +17 -0
- arkruntime/types/completion_usage.py +43 -0
- arkruntime/types/content_generation/__init__.py +66 -0
- arkruntime/types/content_generation/_init_extras_shim.py +12 -0
- arkruntime/types/content_generation/audio_role.py +16 -0
- arkruntime/types/content_generation/audio_url.py +16 -0
- arkruntime/types/content_generation/audio_url_param.py +14 -0
- arkruntime/types/content_generation/content_generation_task.py +125 -0
- arkruntime/types/content_generation/content_item.py +54 -0
- arkruntime/types/content_generation/content_item_param.py +46 -0
- arkruntime/types/content_generation/content_type.py +21 -0
- arkruntime/types/content_generation/create_content_generation_task_request.py +106 -0
- arkruntime/types/content_generation/create_content_generation_task_request_param.py +83 -0
- arkruntime/types/content_generation/create_content_generation_task_response.py +16 -0
- arkruntime/types/content_generation/draft_task.py +16 -0
- arkruntime/types/content_generation/draft_task_param.py +14 -0
- arkruntime/types/content_generation/image_role.py +20 -0
- arkruntime/types/content_generation/image_url.py +16 -0
- arkruntime/types/content_generation/image_url_param.py +14 -0
- arkruntime/types/content_generation/list_content_generation_tasks_response.py +24 -0
- arkruntime/types/content_generation/reasoning_effort.py +16 -0
- arkruntime/types/content_generation/task_content.py +30 -0
- arkruntime/types/content_generation/task_error.py +20 -0
- arkruntime/types/content_generation/task_status.py +21 -0
- arkruntime/types/content_generation/task_usage.py +28 -0
- arkruntime/types/content_generation/tool.py +18 -0
- arkruntime/types/content_generation/tool_param.py +17 -0
- arkruntime/types/content_generation/tool_type.py +13 -0
- arkruntime/types/content_generation/tool_type_param.py +11 -0
- arkruntime/types/content_generation/tool_usage.py +18 -0
- arkruntime/types/content_generation/video_role.py +16 -0
- arkruntime/types/content_generation/video_url.py +16 -0
- arkruntime/types/content_generation/video_url_param.py +14 -0
- arkruntime/types/embedding/__init__.py +30 -0
- arkruntime/types/embedding/_init_extras_shim.py +12 -0
- arkruntime/types/embedding/embedding.py +18 -0
- arkruntime/types/embedding/embedding_input.py +18 -0
- arkruntime/types/embedding/embedding_input_param.py +16 -0
- arkruntime/types/embedding/embedding_item.py +32 -0
- arkruntime/types/embedding/embedding_request.py +39 -0
- arkruntime/types/embedding/embedding_request_param.py +37 -0
- arkruntime/types/embedding/embedding_response.py +41 -0
- arkruntime/types/embedding/embedding_usage.py +24 -0
- arkruntime/types/embedding/encoding_format.py +14 -0
- arkruntime/types/environment/__init__.py +36 -0
- arkruntime/types/environment/_init_extras_shim.py +12 -0
- arkruntime/types/environment/create_environment_request.py +41 -0
- arkruntime/types/environment/delete_environment_response.py +24 -0
- arkruntime/types/environment/env_config.py +38 -0
- arkruntime/types/environment/env_config_type.py +18 -0
- arkruntime/types/environment/environment.py +57 -0
- arkruntime/types/environment/environment_scope.py +18 -0
- arkruntime/types/environment/list_environments_response.py +30 -0
- arkruntime/types/environment/networking_config.py +37 -0
- arkruntime/types/environment/networking_type.py +18 -0
- arkruntime/types/environment/packages_config.py +47 -0
- arkruntime/types/environment/update_environment_request.py +45 -0
- arkruntime/types/file/__init__.py +40 -0
- arkruntime/types/file/_init_extras_shim.py +12 -0
- arkruntime/types/file/file_create_request.py +41 -0
- arkruntime/types/file/file_create_request_param.py +41 -0
- arkruntime/types/file/file_deleted.py +30 -0
- arkruntime/types/file/file_error.py +32 -0
- arkruntime/types/file/file_list_response.py +42 -0
- arkruntime/types/file/file_object.py +71 -0
- arkruntime/types/file/order.py +18 -0
- arkruntime/types/file/preprocess_configs.py +24 -0
- arkruntime/types/file/preprocess_configs_param.py +22 -0
- arkruntime/types/file/purpose.py +18 -0
- arkruntime/types/file/status.py +19 -0
- arkruntime/types/file/tos_storage.py +28 -0
- arkruntime/types/file/tos_storage_param.py +25 -0
- arkruntime/types/file/video.py +26 -0
- arkruntime/types/file/video_param.py +23 -0
- arkruntime/types/images/__init__.py +55 -0
- arkruntime/types/images/_init_extras_shim.py +12 -0
- arkruntime/types/images/bounding_box.py +27 -0
- arkruntime/types/images/create_image_generation_request.py +88 -0
- arkruntime/types/images/create_image_generation_request_param.py +73 -0
- arkruntime/types/images/image_data_item.py +58 -0
- arkruntime/types/images/image_error.py +20 -0
- arkruntime/types/images/image_generation_response.py +43 -0
- arkruntime/types/images/image_generation_stream_event.py +74 -0
- arkruntime/types/images/image_generation_stream_event_type.py +19 -0
- arkruntime/types/images/optimize_prompt_mode.py +18 -0
- arkruntime/types/images/optimize_prompt_options.py +20 -0
- arkruntime/types/images/optimize_prompt_options_param.py +18 -0
- arkruntime/types/images/output_format.py +18 -0
- arkruntime/types/images/response_format.py +18 -0
- arkruntime/types/images/sequential_image_generation_mode.py +18 -0
- arkruntime/types/images/sequential_image_generation_options.py +18 -0
- arkruntime/types/images/sequential_image_generation_options_param.py +16 -0
- arkruntime/types/images/tool.py +18 -0
- arkruntime/types/images/tool_param.py +17 -0
- arkruntime/types/images/tool_type.py +13 -0
- arkruntime/types/images/tool_type_param.py +11 -0
- arkruntime/types/images/tool_usage.py +18 -0
- arkruntime/types/images/usage.py +36 -0
- arkruntime/types/memory/__init__.py +44 -0
- arkruntime/types/memory/_init_extras_shim.py +12 -0
- arkruntime/types/memory/actor.py +26 -0
- arkruntime/types/memory/actor_type.py +16 -0
- arkruntime/types/memory/create_memory_request.py +24 -0
- arkruntime/types/memory/create_memory_store_request.py +30 -0
- arkruntime/types/memory/delete_memory_response.py +26 -0
- arkruntime/types/memory/delete_memory_store_response.py +26 -0
- arkruntime/types/memory/list_memories_order_by.py +18 -0
- arkruntime/types/memory/list_memories_response.py +32 -0
- arkruntime/types/memory/list_memory_stores_response.py +28 -0
- arkruntime/types/memory/memory.py +64 -0
- arkruntime/types/memory/memory_list_item.py +58 -0
- arkruntime/types/memory/memory_list_item_type.py +20 -0
- arkruntime/types/memory/memory_store.py +64 -0
- arkruntime/types/memory/update_memory_request.py +27 -0
- arkruntime/types/memory/update_memory_store_request.py +31 -0
- arkruntime/types/multimodal_embedding/__init__.py +54 -0
- arkruntime/types/multimodal_embedding/_init_extras_shim.py +12 -0
- arkruntime/types/multimodal_embedding/embedding.py +13 -0
- arkruntime/types/multimodal_embedding/embedding_data_item.py +33 -0
- arkruntime/types/multimodal_embedding/embedding_input.py +34 -0
- arkruntime/types/multimodal_embedding/embedding_input_param.py +29 -0
- arkruntime/types/multimodal_embedding/embedding_input_type.py +15 -0
- arkruntime/types/multimodal_embedding/embedding_object.py +14 -0
- arkruntime/types/multimodal_embedding/embedding_usage.py +26 -0
- arkruntime/types/multimodal_embedding/encoding_format.py +14 -0
- arkruntime/types/multimodal_embedding/image_url.py +16 -0
- arkruntime/types/multimodal_embedding/image_url_param.py +14 -0
- arkruntime/types/multimodal_embedding/multi_embedding_config.py +18 -0
- arkruntime/types/multimodal_embedding/multi_embedding_config_param.py +17 -0
- arkruntime/types/multimodal_embedding/multi_embedding_mode.py +14 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_request.py +47 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_request_param.py +39 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_response.py +41 -0
- arkruntime/types/multimodal_embedding/prompt_tokens_details.py +20 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_config.py +20 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_config_param.py +18 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_mode.py +14 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_value.py +20 -0
- arkruntime/types/multimodal_embedding/video_url.py +22 -0
- arkruntime/types/multimodal_embedding/video_url_param.py +19 -0
- arkruntime/types/responses/__init__.py +528 -0
- arkruntime/types/responses/_init_extras_shim.py +47 -0
- arkruntime/types/responses/annotation.py +20 -0
- arkruntime/types/responses/annotation_param.py +14 -0
- arkruntime/types/responses/applied_edit.py +22 -0
- arkruntime/types/responses/audio_chunk.py +15 -0
- arkruntime/types/responses/audio_chunking_strategy.py +18 -0
- arkruntime/types/responses/audio_chunking_strategy_param.py +21 -0
- arkruntime/types/responses/cache_mode.py +14 -0
- arkruntime/types/responses/clear_thinking.py +18 -0
- arkruntime/types/responses/clear_thinking_keep.py +18 -0
- arkruntime/types/responses/clear_thinking_keep_param.py +19 -0
- arkruntime/types/responses/clear_thinking_param.py +19 -0
- arkruntime/types/responses/clear_thinking_response.py +16 -0
- arkruntime/types/responses/clear_tool_uses.py +23 -0
- arkruntime/types/responses/clear_tool_uses_inputs.py +18 -0
- arkruntime/types/responses/clear_tool_uses_inputs_param.py +19 -0
- arkruntime/types/responses/clear_tool_uses_param.py +27 -0
- arkruntime/types/responses/clear_tool_uses_response.py +16 -0
- arkruntime/types/responses/content_filter.py +14 -0
- arkruntime/types/responses/content_item.py +36 -0
- arkruntime/types/responses/content_item_audio.py +20 -0
- arkruntime/types/responses/content_item_audio_param.py +23 -0
- arkruntime/types/responses/content_item_file.py +19 -0
- arkruntime/types/responses/content_item_file_param.py +23 -0
- arkruntime/types/responses/content_item_image.py +22 -0
- arkruntime/types/responses/content_item_image_param.py +26 -0
- arkruntime/types/responses/content_item_param.py +29 -0
- arkruntime/types/responses/content_item_text.py +22 -0
- arkruntime/types/responses/content_item_text_param.py +19 -0
- arkruntime/types/responses/content_item_video.py +27 -0
- arkruntime/types/responses/content_item_video_param.py +24 -0
- arkruntime/types/responses/context_management.py +17 -0
- arkruntime/types/responses/context_management_param.py +17 -0
- arkruntime/types/responses/context_management_response.py +17 -0
- arkruntime/types/responses/cover_image.py +26 -0
- arkruntime/types/responses/cover_image_param.py +22 -0
- arkruntime/types/responses/delete_response_response.py +17 -0
- arkruntime/types/responses/doc_citation.py +19 -0
- arkruntime/types/responses/doc_citation_param.py +23 -0
- arkruntime/types/responses/doubao_app_call_block.py +30 -0
- arkruntime/types/responses/doubao_app_call_block_output_text.py +21 -0
- arkruntime/types/responses/doubao_app_call_block_reasoning_search.py +24 -0
- arkruntime/types/responses/doubao_app_call_block_reasoning_text.py +21 -0
- arkruntime/types/responses/doubao_app_call_block_search.py +24 -0
- arkruntime/types/responses/doubao_app_feature.py +20 -0
- arkruntime/types/responses/doubao_app_feature_item.py +18 -0
- arkruntime/types/responses/doubao_app_feature_item_param.py +19 -0
- arkruntime/types/responses/doubao_app_feature_mode.py +14 -0
- arkruntime/types/responses/doubao_app_feature_param.py +23 -0
- arkruntime/types/responses/doubao_app_search_result.py +15 -0
- arkruntime/types/responses/doubao_app_search_text_item.py +15 -0
- arkruntime/types/responses/doubao_app_tool.py +20 -0
- arkruntime/types/responses/doubao_app_tool_param.py +22 -0
- arkruntime/types/responses/edit.py +19 -0
- arkruntime/types/responses/edit_param.py +14 -0
- arkruntime/types/responses/function_tool.py +32 -0
- arkruntime/types/responses/function_tool_param.py +29 -0
- arkruntime/types/responses/image_detail.py +16 -0
- arkruntime/types/responses/image_pixel_limit.py +16 -0
- arkruntime/types/responses/image_pixel_limit_param.py +17 -0
- arkruntime/types/responses/image_process_options.py +15 -0
- arkruntime/types/responses/image_process_options_param.py +15 -0
- arkruntime/types/responses/image_process_tool.py +21 -0
- arkruntime/types/responses/image_process_tool_param.py +25 -0
- arkruntime/types/responses/incomplete_details.py +24 -0
- arkruntime/types/responses/input_item.py +38 -0
- arkruntime/types/responses/input_item_list_params_shim.py +39 -0
- arkruntime/types/responses/input_item_param.py +33 -0
- arkruntime/types/responses/input_tokens_details.py +17 -0
- arkruntime/types/responses/item_agent_tool_call.py +20 -0
- arkruntime/types/responses/item_doubao_app_call.py +22 -0
- arkruntime/types/responses/item_easy_message.py +22 -0
- arkruntime/types/responses/item_easy_message_param.py +26 -0
- arkruntime/types/responses/item_function_image_process.py +24 -0
- arkruntime/types/responses/item_function_knowledge_search.py +21 -0
- arkruntime/types/responses/item_function_mcp_approval_request.py +34 -0
- arkruntime/types/responses/item_function_mcp_approval_request_param.py +28 -0
- arkruntime/types/responses/item_function_mcp_approval_response.py +34 -0
- arkruntime/types/responses/item_function_mcp_approval_response_param.py +28 -0
- arkruntime/types/responses/item_function_mcp_call.py +44 -0
- arkruntime/types/responses/item_function_mcp_call_param.py +38 -0
- arkruntime/types/responses/item_function_mcp_list_tools.py +36 -0
- arkruntime/types/responses/item_function_mcp_list_tools_param.py +30 -0
- arkruntime/types/responses/item_function_tool_call.py +37 -0
- arkruntime/types/responses/item_function_tool_call_output.py +22 -0
- arkruntime/types/responses/item_function_tool_call_output_param.py +26 -0
- arkruntime/types/responses/item_function_tool_call_param.py +32 -0
- arkruntime/types/responses/item_function_web_search.py +21 -0
- arkruntime/types/responses/item_input_message.py +24 -0
- arkruntime/types/responses/item_output_message.py +23 -0
- arkruntime/types/responses/item_reasoning.py +24 -0
- arkruntime/types/responses/item_reasoning_param.py +29 -0
- arkruntime/types/responses/item_reference.py +16 -0
- arkruntime/types/responses/item_status.py +17 -0
- arkruntime/types/responses/item_transcription.py +21 -0
- arkruntime/types/responses/knowledge_search_tool.py +46 -0
- arkruntime/types/responses/knowledge_search_tool_param.py +37 -0
- arkruntime/types/responses/list_input_items_response.py +21 -0
- arkruntime/types/responses/mcp_allowed_tools.py +17 -0
- arkruntime/types/responses/mcp_allowed_tools_filter.py +15 -0
- arkruntime/types/responses/mcp_allowed_tools_filter_param.py +15 -0
- arkruntime/types/responses/mcp_allowed_tools_param.py +13 -0
- arkruntime/types/responses/mcp_approval_mode.py +14 -0
- arkruntime/types/responses/mcp_list_tools_tool.py +30 -0
- arkruntime/types/responses/mcp_list_tools_tool_param.py +25 -0
- arkruntime/types/responses/mcp_require_approval.py +18 -0
- arkruntime/types/responses/mcp_require_approval_param.py +14 -0
- arkruntime/types/responses/mcp_tool.py +24 -0
- arkruntime/types/responses/mcp_tool_approval_filter.py +19 -0
- arkruntime/types/responses/mcp_tool_approval_filter_always.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_always_param.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_never.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_never_param.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_param.py +20 -0
- arkruntime/types/responses/mcp_tool_param.py +30 -0
- arkruntime/types/responses/message_content.py +15 -0
- arkruntime/types/responses/message_content_param.py +13 -0
- arkruntime/types/responses/message_role.py +16 -0
- arkruntime/types/responses/order.py +18 -0
- arkruntime/types/responses/output_content_item.py +23 -0
- arkruntime/types/responses/output_content_item_param.py +18 -0
- arkruntime/types/responses/output_content_item_reasoning_text.py +19 -0
- arkruntime/types/responses/output_content_item_reasoning_text_param.py +21 -0
- arkruntime/types/responses/output_content_item_text.py +19 -0
- arkruntime/types/responses/output_content_item_text_param.py +21 -0
- arkruntime/types/responses/output_item.py +46 -0
- arkruntime/types/responses/output_tokens_details.py +13 -0
- arkruntime/types/responses/parsed_response_shim.py +106 -0
- arkruntime/types/responses/reasoning.py +17 -0
- arkruntime/types/responses/reasoning_effort.py +19 -0
- arkruntime/types/responses/reasoning_param.py +17 -0
- arkruntime/types/responses/reasoning_summary_part.py +16 -0
- arkruntime/types/responses/reasoning_summary_part_param.py +17 -0
- arkruntime/types/responses/response.py +58 -0
- arkruntime/types/responses/response_agent_tool_call_completed_event.py +19 -0
- arkruntime/types/responses/response_agent_tool_call_in_progress_event.py +19 -0
- arkruntime/types/responses/response_caching.py +18 -0
- arkruntime/types/responses/response_caching_param.py +19 -0
- arkruntime/types/responses/response_completed_event.py +28 -0
- arkruntime/types/responses/response_content_part_added_event.py +22 -0
- arkruntime/types/responses/response_content_part_done_event.py +22 -0
- arkruntime/types/responses/response_created_event.py +28 -0
- arkruntime/types/responses/response_doubao_app_call_block_added_event.py +21 -0
- arkruntime/types/responses/response_doubao_app_call_block_done_event.py +21 -0
- arkruntime/types/responses/response_doubao_app_call_completed_event.py +22 -0
- arkruntime/types/responses/response_doubao_app_call_failed_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_output_text_delta_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_output_text_done_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_completed_event.py +24 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_searching_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_text_delta_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_text_done_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_search_completed_event.py +24 -0
- arkruntime/types/responses/response_doubao_app_call_search_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_search_searching_event.py +20 -0
- arkruntime/types/responses/response_error.py +20 -0
- arkruntime/types/responses/response_error_event.py +34 -0
- arkruntime/types/responses/response_failed_event.py +28 -0
- arkruntime/types/responses/response_function_call_arguments_delta_event.py +34 -0
- arkruntime/types/responses/response_function_call_arguments_done_event.py +31 -0
- arkruntime/types/responses/response_image_process_action.py +16 -0
- arkruntime/types/responses/response_image_process_call_completed_event.py +22 -0
- arkruntime/types/responses/response_image_process_call_in_progress_event.py +21 -0
- arkruntime/types/responses/response_image_process_call_processing_event.py +22 -0
- arkruntime/types/responses/response_image_process_error.py +13 -0
- arkruntime/types/responses/response_in_progress_event.py +28 -0
- arkruntime/types/responses/response_includable.py +15 -0
- arkruntime/types/responses/response_incomplete_event.py +28 -0
- arkruntime/types/responses/response_knowledge_search_call_completed_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_failed_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_in_progress_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_searching_event.py +21 -0
- arkruntime/types/responses/response_mcp_approval_request_event.py +20 -0
- arkruntime/types/responses/response_mcp_call_arguments_delta_event.py +35 -0
- arkruntime/types/responses/response_mcp_call_arguments_done_event.py +34 -0
- arkruntime/types/responses/response_mcp_call_completed_event.py +30 -0
- arkruntime/types/responses/response_mcp_call_failed_event.py +30 -0
- arkruntime/types/responses/response_mcp_call_in_progress_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_completed_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_failed_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_in_progress_event.py +30 -0
- arkruntime/types/responses/response_output_item_added_event.py +20 -0
- arkruntime/types/responses/response_output_item_done_event.py +20 -0
- arkruntime/types/responses/response_output_text_annotation_added_event.py +46 -0
- arkruntime/types/responses/response_reasoning_raw_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_raw_text_done_event.py +38 -0
- arkruntime/types/responses/response_reasoning_summary_part_added_event.py +22 -0
- arkruntime/types/responses/response_reasoning_summary_part_done_event.py +22 -0
- arkruntime/types/responses/response_reasoning_summary_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_summary_text_done_event.py +38 -0
- arkruntime/types/responses/response_reasoning_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_text_done_event.py +38 -0
- arkruntime/types/responses/response_status.py +16 -0
- arkruntime/types/responses/response_stream_event.py +216 -0
- arkruntime/types/responses/response_text_config.py +15 -0
- arkruntime/types/responses/response_text_config_param.py +16 -0
- arkruntime/types/responses/response_text_delta_event.py +38 -0
- arkruntime/types/responses/response_text_done_event.py +38 -0
- arkruntime/types/responses/response_transcription_part_added_event.py +22 -0
- arkruntime/types/responses/response_transcription_part_done_event.py +22 -0
- arkruntime/types/responses/response_transcription_text_delta_event.py +46 -0
- arkruntime/types/responses/response_transcription_text_done_event.py +52 -0
- arkruntime/types/responses/response_usage.py +47 -0
- arkruntime/types/responses/response_web_search_call_completed_event.py +30 -0
- arkruntime/types/responses/response_web_search_call_in_progress_event.py +30 -0
- arkruntime/types/responses/response_web_search_call_searching_event.py +30 -0
- arkruntime/types/responses/responses_input.py +15 -0
- arkruntime/types/responses/responses_input_param.py +13 -0
- arkruntime/types/responses/responses_request.py +50 -0
- arkruntime/types/responses/responses_request_param.py +73 -0
- arkruntime/types/responses/service_tier.py +14 -0
- arkruntime/types/responses/session.py +13 -0
- arkruntime/types/responses/session_param.py +13 -0
- arkruntime/types/responses/text_format.py +22 -0
- arkruntime/types/responses/text_format_param.py +25 -0
- arkruntime/types/responses/text_format_type.py +15 -0
- arkruntime/types/responses/text_translation_options.py +14 -0
- arkruntime/types/responses/thinking.py +17 -0
- arkruntime/types/responses/thinking_mode.py +15 -0
- arkruntime/types/responses/thinking_param.py +17 -0
- arkruntime/types/responses/thinking_turns_param.py +16 -0
- arkruntime/types/responses/thinking_turns_param_param.py +17 -0
- arkruntime/types/responses/tool.py +34 -0
- arkruntime/types/responses/tool_choice.py +16 -0
- arkruntime/types/responses/tool_choice_function.py +22 -0
- arkruntime/types/responses/tool_choice_function_param.py +19 -0
- arkruntime/types/responses/tool_choice_knowledge_search.py +15 -0
- arkruntime/types/responses/tool_choice_knowledge_search_param.py +15 -0
- arkruntime/types/responses/tool_choice_mcp.py +26 -0
- arkruntime/types/responses/tool_choice_mcp_param.py +22 -0
- arkruntime/types/responses/tool_choice_options.py +15 -0
- arkruntime/types/responses/tool_choice_param.py +14 -0
- arkruntime/types/responses/tool_choice_web_search.py +15 -0
- arkruntime/types/responses/tool_choice_web_search_param.py +15 -0
- arkruntime/types/responses/tool_name_list.py +15 -0
- arkruntime/types/responses/tool_name_list_param.py +15 -0
- arkruntime/types/responses/tool_param.py +25 -0
- arkruntime/types/responses/tool_usage.py +27 -0
- arkruntime/types/responses/tool_usage_details.py +30 -0
- arkruntime/types/responses/tool_uses_keep.py +16 -0
- arkruntime/types/responses/tool_uses_keep_param.py +17 -0
- arkruntime/types/responses/tool_uses_trigger.py +16 -0
- arkruntime/types/responses/tool_uses_trigger_param.py +17 -0
- arkruntime/types/responses/transcription_part.py +19 -0
- arkruntime/types/responses/truncation_mode.py +14 -0
- arkruntime/types/responses/typed_tool_choice.py +30 -0
- arkruntime/types/responses/typed_tool_choice_param.py +21 -0
- arkruntime/types/responses/url_citation.py +26 -0
- arkruntime/types/responses/url_citation_param.py +35 -0
- arkruntime/types/responses/user_location.py +34 -0
- arkruntime/types/responses/user_location_param.py +28 -0
- arkruntime/types/responses/web_search_action.py +16 -0
- arkruntime/types/responses/web_search_source.py +16 -0
- arkruntime/types/responses/web_search_tool.py +22 -0
- arkruntime/types/responses/web_search_tool_param.py +26 -0
- arkruntime/types/session/__init__.py +154 -0
- arkruntime/types/session/_init_extras_shim.py +88 -0
- arkruntime/types/session/agent_identifier.py +19 -0
- arkruntime/types/session/agent_ref.py +31 -0
- arkruntime/types/session/base64_document_source.py +27 -0
- arkruntime/types/session/base64_image_source.py +27 -0
- arkruntime/types/session/cache_creation.py +26 -0
- arkruntime/types/session/create_session_request.py +50 -0
- arkruntime/types/session/create_session_resource_request.py +29 -0
- arkruntime/types/session/delete_session_response.py +24 -0
- arkruntime/types/session/document_source.py +34 -0
- arkruntime/types/session/file_document_source.py +23 -0
- arkruntime/types/session/file_image_source.py +23 -0
- arkruntime/types/session/image_source.py +28 -0
- arkruntime/types/session/list_session_events_response_wire.py +31 -0
- arkruntime/types/session/list_session_resources_response.py +24 -0
- arkruntime/types/session/list_session_threads_response.py +28 -0
- arkruntime/types/session/list_sessions_order.py +18 -0
- arkruntime/types/session/list_sessions_response.py +28 -0
- arkruntime/types/session/managed_agents_agent_message_preview.py +27 -0
- arkruntime/types/session/managed_agents_agent_thinking_preview.py +27 -0
- arkruntime/types/session/managed_agents_delta_content.py +34 -0
- arkruntime/types/session/managed_agents_delta_event.py +34 -0
- arkruntime/types/session/managed_agents_delta_text_block.py +27 -0
- arkruntime/types/session/managed_agents_document_block.py +33 -0
- arkruntime/types/session/managed_agents_event_params.py +57 -0
- arkruntime/types/session/managed_agents_file_rubric_params.py +23 -0
- arkruntime/types/session/managed_agents_image_block.py +25 -0
- arkruntime/types/session/managed_agents_message_content_block.py +30 -0
- arkruntime/types/session/managed_agents_rubric.py +26 -0
- arkruntime/types/session/managed_agents_search_result_block.py +38 -0
- arkruntime/types/session/managed_agents_session_event.py +34 -0
- arkruntime/types/session/managed_agents_start_event.py +31 -0
- arkruntime/types/session/managed_agents_start_event_preview.py +27 -0
- arkruntime/types/session/managed_agents_stream_preview_event.py +26 -0
- arkruntime/types/session/managed_agents_system_content_block.py +23 -0
- arkruntime/types/session/managed_agents_system_message_event_params.py +34 -0
- arkruntime/types/session/managed_agents_text_block.py +23 -0
- arkruntime/types/session/managed_agents_text_rubric_params.py +23 -0
- arkruntime/types/session/managed_agents_tool_result_content_block.py +34 -0
- arkruntime/types/session/managed_agents_user_custom_tool_result_event_params.py +44 -0
- arkruntime/types/session/managed_agents_user_define_outcome_event_params.py +45 -0
- arkruntime/types/session/managed_agents_user_interrupt_event_params.py +31 -0
- arkruntime/types/session/managed_agents_user_message_event_params.py +34 -0
- arkruntime/types/session/managed_agents_user_tool_confirmation_event_params.py +46 -0
- arkruntime/types/session/managed_agents_user_tool_result_event_params.py +44 -0
- arkruntime/types/session/plain_text_document_source.py +27 -0
- arkruntime/types/session/search_result_citations.py +20 -0
- arkruntime/types/session/search_result_content.py +20 -0
- arkruntime/types/session/send_session_events_request.py +24 -0
- arkruntime/types/session/send_session_events_response.py +22 -0
- arkruntime/types/session/session.py +80 -0
- arkruntime/types/session/session_resource.py +70 -0
- arkruntime/types/session/session_resource_access.py +18 -0
- arkruntime/types/session/session_resource_type.py +19 -0
- arkruntime/types/session/session_status.py +20 -0
- arkruntime/types/session/session_stream_shim.py +540 -0
- arkruntime/types/session/session_thread.py +56 -0
- arkruntime/types/session/session_thread_status.py +20 -0
- arkruntime/types/session/session_usage.py +36 -0
- arkruntime/types/session/tag.py +26 -0
- arkruntime/types/session/tool_confirmation_result.py +18 -0
- arkruntime/types/session/update_session_request.py +28 -0
- arkruntime/types/session/url_document_source.py +23 -0
- arkruntime/types/session/url_image_source.py +23 -0
- arkruntime/types/skill/__init__.py +18 -0
- arkruntime/types/skill/_init_extras_shim.py +12 -0
- arkruntime/types/skill/create_skill_request.py +18 -0
- arkruntime/types/skill/skill.py +46 -0
- arkruntime/types/tokenization/__init__.py +24 -0
- arkruntime/types/tokenization/_init_extras_shim.py +12 -0
- arkruntime/types/tokenization/tokenization_input.py +17 -0
- arkruntime/types/tokenization/tokenization_input_param.py +15 -0
- arkruntime/types/tokenization/tokenization_item.py +39 -0
- arkruntime/types/tokenization/tokenization_request.py +30 -0
- arkruntime/types/tokenization/tokenization_request_param.py +30 -0
- arkruntime/types/tokenization/tokenization_response.py +36 -0
- arkruntime/types/vault/__init__.py +62 -0
- arkruntime/types/vault/_init_extras_shim.py +12 -0
- arkruntime/types/vault/create_credential_request.py +32 -0
- arkruntime/types/vault/create_vault_request.py +26 -0
- arkruntime/types/vault/credential.py +52 -0
- arkruntime/types/vault/credential_auth.py +64 -0
- arkruntime/types/vault/credential_auth_type.py +22 -0
- arkruntime/types/vault/credential_networking.py +29 -0
- arkruntime/types/vault/credential_networking_type.py +18 -0
- arkruntime/types/vault/credential_validation.py +54 -0
- arkruntime/types/vault/delete_credential_response.py +26 -0
- arkruntime/types/vault/delete_vault_response.py +26 -0
- arkruntime/types/vault/limited_credential_networking.py +22 -0
- arkruntime/types/vault/list_credentials_response.py +35 -0
- arkruntime/types/vault/list_vaults_response.py +32 -0
- arkruntime/types/vault/mcp_probe.py +26 -0
- arkruntime/types/vault/mcpo_auth_refresh.py +45 -0
- arkruntime/types/vault/refresh_http_response.py +32 -0
- arkruntime/types/vault/refresh_object.py +27 -0
- arkruntime/types/vault/refresh_status.py +20 -0
- arkruntime/types/vault/token_endpoint_auth.py +29 -0
- arkruntime/types/vault/token_endpoint_auth_type.py +19 -0
- arkruntime/types/vault/update_credential_request.py +35 -0
- arkruntime/types/vault/update_vault_request.py +27 -0
- arkruntime/types/vault/validation_status.py +19 -0
- arkruntime/types/vault/vault.py +42 -0
- arkruntime-0.1.0.dist-info/METADATA +347 -0
- arkruntime-0.1.0.dist-info/RECORD +714 -0
- arkruntime-0.1.0.dist-info/WHEEL +5 -0
- arkruntime-0.1.0.dist-info/licenses/LICENSE +201 -0
- arkruntime-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
|
|
4
|
+
|
|
5
|
+
from .._compat import (
|
|
6
|
+
parse_date as parse_date,
|
|
7
|
+
)
|
|
8
|
+
from .._compat import (
|
|
9
|
+
parse_datetime as parse_datetime,
|
|
10
|
+
)
|
|
11
|
+
from ._logs import setup_logging as setup_logging
|
|
12
|
+
from ._streams import (
|
|
13
|
+
consume_async_iterator as consume_async_iterator,
|
|
14
|
+
)
|
|
15
|
+
from ._streams import (
|
|
16
|
+
consume_sync_iterator as consume_sync_iterator,
|
|
17
|
+
)
|
|
18
|
+
from ._transform import (
|
|
19
|
+
PropertyInfo as PropertyInfo,
|
|
20
|
+
)
|
|
21
|
+
from ._transform import (
|
|
22
|
+
async_maybe_transform as async_maybe_transform,
|
|
23
|
+
)
|
|
24
|
+
from ._transform import (
|
|
25
|
+
async_transform as async_transform,
|
|
26
|
+
)
|
|
27
|
+
from ._transform import (
|
|
28
|
+
maybe_transform as maybe_transform,
|
|
29
|
+
)
|
|
30
|
+
from ._transform import (
|
|
31
|
+
transform as transform,
|
|
32
|
+
)
|
|
33
|
+
from ._typing import (
|
|
34
|
+
extract_type_arg as extract_type_arg,
|
|
35
|
+
)
|
|
36
|
+
from ._typing import (
|
|
37
|
+
extract_type_var_from_base as extract_type_var_from_base,
|
|
38
|
+
)
|
|
39
|
+
from ._typing import (
|
|
40
|
+
is_annotated_type as is_annotated_type,
|
|
41
|
+
)
|
|
42
|
+
from ._typing import (
|
|
43
|
+
is_iterable_type as is_iterable_type,
|
|
44
|
+
)
|
|
45
|
+
from ._typing import (
|
|
46
|
+
is_list_type as is_list_type,
|
|
47
|
+
)
|
|
48
|
+
from ._typing import (
|
|
49
|
+
is_required_type as is_required_type,
|
|
50
|
+
)
|
|
51
|
+
from ._typing import (
|
|
52
|
+
is_type_alias_type as is_type_alias_type,
|
|
53
|
+
)
|
|
54
|
+
from ._typing import (
|
|
55
|
+
is_union_type as is_union_type,
|
|
56
|
+
)
|
|
57
|
+
from ._typing import (
|
|
58
|
+
strip_annotated_type as strip_annotated_type,
|
|
59
|
+
)
|
|
60
|
+
from ._utils import (
|
|
61
|
+
async_with_sts_token,
|
|
62
|
+
with_sts_token,
|
|
63
|
+
)
|
|
64
|
+
from ._utils import (
|
|
65
|
+
coerce_boolean as coerce_boolean,
|
|
66
|
+
)
|
|
67
|
+
from ._utils import (
|
|
68
|
+
coerce_float as coerce_float,
|
|
69
|
+
)
|
|
70
|
+
from ._utils import (
|
|
71
|
+
coerce_integer as coerce_integer,
|
|
72
|
+
)
|
|
73
|
+
from ._utils import (
|
|
74
|
+
deepcopy_minimal as deepcopy_minimal,
|
|
75
|
+
)
|
|
76
|
+
from ._utils import (
|
|
77
|
+
extract_files as extract_files,
|
|
78
|
+
)
|
|
79
|
+
from ._utils import (
|
|
80
|
+
file_from_path as file_from_path,
|
|
81
|
+
)
|
|
82
|
+
from ._utils import (
|
|
83
|
+
flatten as flatten,
|
|
84
|
+
)
|
|
85
|
+
from ._utils import (
|
|
86
|
+
get_async_library as get_async_library,
|
|
87
|
+
)
|
|
88
|
+
from ._utils import (
|
|
89
|
+
is_dict as is_dict,
|
|
90
|
+
)
|
|
91
|
+
from ._utils import (
|
|
92
|
+
is_given as is_given,
|
|
93
|
+
)
|
|
94
|
+
from ._utils import (
|
|
95
|
+
is_iterable as is_iterable,
|
|
96
|
+
)
|
|
97
|
+
from ._utils import (
|
|
98
|
+
is_list as is_list,
|
|
99
|
+
)
|
|
100
|
+
from ._utils import (
|
|
101
|
+
is_mapping as is_mapping,
|
|
102
|
+
)
|
|
103
|
+
from ._utils import (
|
|
104
|
+
is_mapping_t as is_mapping_t,
|
|
105
|
+
)
|
|
106
|
+
from ._utils import (
|
|
107
|
+
is_sequence as is_sequence,
|
|
108
|
+
)
|
|
109
|
+
from ._utils import (
|
|
110
|
+
is_sequence_t as is_sequence_t,
|
|
111
|
+
)
|
|
112
|
+
from ._utils import (
|
|
113
|
+
is_tuple as is_tuple,
|
|
114
|
+
)
|
|
115
|
+
from ._utils import (
|
|
116
|
+
is_tuple_t as is_tuple_t,
|
|
117
|
+
)
|
|
118
|
+
from ._utils import (
|
|
119
|
+
json_safe as json_safe,
|
|
120
|
+
)
|
|
121
|
+
from ._utils import (
|
|
122
|
+
lru_cache as lru_cache,
|
|
123
|
+
)
|
|
124
|
+
from ._utils import (
|
|
125
|
+
maybe_coerce_boolean as maybe_coerce_boolean,
|
|
126
|
+
)
|
|
127
|
+
from ._utils import (
|
|
128
|
+
maybe_coerce_float as maybe_coerce_float,
|
|
129
|
+
)
|
|
130
|
+
from ._utils import (
|
|
131
|
+
maybe_coerce_integer as maybe_coerce_integer,
|
|
132
|
+
)
|
|
133
|
+
from ._utils import (
|
|
134
|
+
removeprefix as removeprefix,
|
|
135
|
+
)
|
|
136
|
+
from ._utils import (
|
|
137
|
+
removesuffix as removesuffix,
|
|
138
|
+
)
|
|
139
|
+
from ._utils import (
|
|
140
|
+
required_args as required_args,
|
|
141
|
+
)
|
|
142
|
+
from ._utils import (
|
|
143
|
+
strip_not_given as strip_not_given,
|
|
144
|
+
)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import base64
|
|
8
|
+
import re
|
|
9
|
+
import time
|
|
10
|
+
from typing import Tuple
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_cert_info(cert_pem: str) -> Tuple[str, str, float]:
|
|
14
|
+
from cryptography import x509
|
|
15
|
+
from cryptography.hazmat.backends import default_backend
|
|
16
|
+
|
|
17
|
+
cert = x509.load_pem_x509_certificate(cert_pem.encode(), default_backend())
|
|
18
|
+
try:
|
|
19
|
+
dns = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName).value.get_values_for_type(
|
|
20
|
+
x509.DNSName
|
|
21
|
+
)
|
|
22
|
+
if dns and len(dns) > 1 and re.match(r"^ring\..*$", dns[0]) and re.match(r"^key\..*$", dns[1]):
|
|
23
|
+
return dns[0][5:], dns[1][4:], cert.not_valid_after_utc.timestamp()
|
|
24
|
+
except Exception:
|
|
25
|
+
pass
|
|
26
|
+
return "", "", cert.not_valid_after_utc.timestamp()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def aes_gcm_encrypt_bytes(key: bytes, iv: bytes, plain_bytes: bytes, associated_data: bytes = b"") -> bytes:
|
|
30
|
+
# aes_gcm_encrypt_bytes encrypt message using AES-GCM
|
|
31
|
+
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
32
|
+
|
|
33
|
+
encryptor = Cipher(
|
|
34
|
+
algorithms.AES(key),
|
|
35
|
+
modes.GCM(iv),
|
|
36
|
+
).encryptor()
|
|
37
|
+
# associated_data will be authenticated but not encrypted,
|
|
38
|
+
# it must also be passed in on decryption.
|
|
39
|
+
encryptor.authenticate_additional_data(associated_data)
|
|
40
|
+
# Encrypt the plaintext and get the associated ciphertext.
|
|
41
|
+
# GCM does not require padding.
|
|
42
|
+
ciphertext = encryptor.update(plain_bytes) + encryptor.finalize()
|
|
43
|
+
return ciphertext + encryptor.tag
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def aes_gcm_encrypt_base64_string(key: bytes, nonce: bytes, plaintext: str) -> str:
|
|
47
|
+
"""aes_gcm_encrypt_base64_string Encrypt message from base64 string to string using AES-GCM"""
|
|
48
|
+
plain_bytes = plaintext.encode()
|
|
49
|
+
# Encrypt message to string using AES-GCM
|
|
50
|
+
c = aes_gcm_encrypt_bytes(key, nonce, plain_bytes)
|
|
51
|
+
return base64.b64encode(c).decode()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def aes_gcm_decrypt_bytes(key: bytes, iv: bytes, cipher_bytes: bytes, associated_data: bytes = b"") -> bytes:
|
|
55
|
+
"""aes_gcm_decrypt_bytes Decrypt message from bytes to bytes using AES-GCM"""
|
|
56
|
+
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
57
|
+
|
|
58
|
+
tag_length = 16 # default aes gcm tag length
|
|
59
|
+
cipher = cipher_bytes[:-tag_length]
|
|
60
|
+
tag = cipher_bytes[-tag_length:]
|
|
61
|
+
# Construct a Cipher object, with the key, iv, and additionally the
|
|
62
|
+
# GCM tag used for authenticating the message.
|
|
63
|
+
decryptor = Cipher(
|
|
64
|
+
algorithms.AES(key),
|
|
65
|
+
modes.GCM(iv, tag),
|
|
66
|
+
).decryptor()
|
|
67
|
+
# We put associated_data back in or the tag will fail to verify
|
|
68
|
+
# when we finalize the decryptor.
|
|
69
|
+
decryptor.authenticate_additional_data(associated_data)
|
|
70
|
+
# Decryption gets us the authenticated plaintext.
|
|
71
|
+
# If the tag does not match an InvalidTag exception will be raised.
|
|
72
|
+
return decryptor.update(cipher) + decryptor.finalize()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def aes_gcm_decrypt_base64_string(key: bytes, nonce: bytes, ciphertext: str) -> str:
|
|
76
|
+
# Decrypt message(base64.std.string) using AES-GCM
|
|
77
|
+
cipher_bytes = base64.decodebytes(ciphertext.encode())
|
|
78
|
+
return aes_gcm_decrypt_bytes(key, nonce, cipher_bytes).decode()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
base64_pattern = r"(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def decrypt_corner_case(key: bytes, nonce: bytes, data: str) -> str:
|
|
85
|
+
"""decrypt_corner_case Decrypt corner case data"""
|
|
86
|
+
if len(data) < 24:
|
|
87
|
+
return ""
|
|
88
|
+
for i in range(20, len(data), 4):
|
|
89
|
+
try:
|
|
90
|
+
decrypted = aes_gcm_decrypt_base64_string(key, nonce, data[: i + 4])
|
|
91
|
+
if i + 4 == len(data):
|
|
92
|
+
return decrypted
|
|
93
|
+
return decrypted + decrypt_corner_case(key, nonce, data[i + 4 :])
|
|
94
|
+
except Exception:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def aes_gcm_decrypt_base64_list(key: bytes, nonce: bytes, ciphertext: str) -> str:
|
|
99
|
+
# Decrypt
|
|
100
|
+
base64_array = re.findall(base64_pattern, ciphertext)
|
|
101
|
+
result = []
|
|
102
|
+
for b64 in base64_array:
|
|
103
|
+
try:
|
|
104
|
+
result.append(aes_gcm_decrypt_base64_string(key, nonce, b64))
|
|
105
|
+
except Exception:
|
|
106
|
+
result.append(decrypt_corner_case(key, nonce, b64))
|
|
107
|
+
return "".join(result)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def decrypt_validate(ciphertext: str) -> bool:
|
|
111
|
+
cipher_bytes = ciphertext.encode()
|
|
112
|
+
cipher_b64_bytes = base64.decodebytes(cipher_bytes)
|
|
113
|
+
return len(cipher_bytes) / 4 >= len(cipher_b64_bytes) / 3 >= len(cipher_bytes) / 4 - 1
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def marshal_cryptography_pub_key(key) -> bytes:
|
|
117
|
+
# python version of crypto/elliptic/elliptic.go Marshal
|
|
118
|
+
# without point on curve check
|
|
119
|
+
return bytes([4]) + key.x.to_bytes(32, "big") + key.y.to_bytes(32, "big")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class key_agreement_client:
|
|
123
|
+
def __init__(self, certificate_pem_string: str) -> None:
|
|
124
|
+
"""Load cert and extract public key"""
|
|
125
|
+
__fixed_version__ = "42.0.0" # version check
|
|
126
|
+
from cryptography import __version__
|
|
127
|
+
|
|
128
|
+
if __version__ < __fixed_version__:
|
|
129
|
+
raise Exception(
|
|
130
|
+
"The cryptography package of Ark SDK only supports versions after {}, "
|
|
131
|
+
'please install the cryptography package by using pip install "cryptography>={}"'.format(
|
|
132
|
+
__fixed_version__, __fixed_version__
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
from cryptography import x509
|
|
136
|
+
from cryptography.hazmat.primitives.asymmetric import ec
|
|
137
|
+
|
|
138
|
+
pem_data = certificate_pem_string.encode()
|
|
139
|
+
self._cert = x509.load_pem_x509_certificate(pem_data)
|
|
140
|
+
cert_pub = self._cert.public_key().public_numbers()
|
|
141
|
+
self._curve = ec._CURVE_TYPES[self._cert.public_key().curve.name]
|
|
142
|
+
self._public_key = ec.EllipticCurvePublicNumbers(cert_pub.x, cert_pub.y, self._curve).public_key()
|
|
143
|
+
self._not_valid_after_utc = self._cert.not_valid_after_utc.timestamp()
|
|
144
|
+
self._reload_time = time.time() + 60 * 60 * 12 * 14 # 14 days
|
|
145
|
+
self.init_cert_ring_key_id()
|
|
146
|
+
|
|
147
|
+
def encrypt_string(self, plaintext: str) -> Tuple[bytes, bytes, str, str]:
|
|
148
|
+
"""encrypt_string encrypt plaintext with ECIES DH protocol"""
|
|
149
|
+
key, nonce, token = self.generate_ecies_key_pair()
|
|
150
|
+
# Encrypt message using AES-GCM
|
|
151
|
+
ciphertext = aes_gcm_encrypt_base64_string(key, nonce, plaintext)
|
|
152
|
+
return key, nonce, token, ciphertext
|
|
153
|
+
|
|
154
|
+
def encrypt_string_with_key(self, key: bytes, nonce: bytes, plaintext: str) -> str:
|
|
155
|
+
"""encrypt_string_with_key encrypt plaintext with ECIES DH protocol"""
|
|
156
|
+
# Encrypt message using AES-GCM
|
|
157
|
+
ciphertext = aes_gcm_encrypt_base64_string(key, nonce, plaintext)
|
|
158
|
+
return ciphertext
|
|
159
|
+
|
|
160
|
+
def decrypt_string_with_key(self, key: bytes, nonce: bytes, ciphertext: str) -> str:
|
|
161
|
+
"""decrypt_string_with_key decrypt ciphertext with ECIES DH protocol"""
|
|
162
|
+
# Decrypt message using AES-GCM
|
|
163
|
+
return aes_gcm_decrypt_base64_string(key, nonce, ciphertext)
|
|
164
|
+
|
|
165
|
+
def generate_ecies_key_pair(self) -> Tuple[bytes, bytes, str]:
|
|
166
|
+
"""generate_ecies_key_pair generate ECIES key pair"""
|
|
167
|
+
from cryptography.hazmat.primitives import hashes
|
|
168
|
+
from cryptography.hazmat.primitives.asymmetric import ec
|
|
169
|
+
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
|
|
170
|
+
|
|
171
|
+
# Generate an ephemeral elliptic curve scalar and point
|
|
172
|
+
peer_private_key = ec.generate_private_key(self._curve)
|
|
173
|
+
dh = peer_private_key.exchange(ec.ECDH(), self._public_key)
|
|
174
|
+
R = peer_private_key.public_key().public_numbers()
|
|
175
|
+
|
|
176
|
+
# Derive symmetric key and nonce via HKDF
|
|
177
|
+
length = 32 + 12
|
|
178
|
+
buf = HKDF(
|
|
179
|
+
algorithm=hashes.SHA256(),
|
|
180
|
+
length=length,
|
|
181
|
+
salt=None,
|
|
182
|
+
info=None,
|
|
183
|
+
).derive(dh)
|
|
184
|
+
key = buf[:32]
|
|
185
|
+
nonce = buf[32:length]
|
|
186
|
+
|
|
187
|
+
token = marshal_cryptography_pub_key(R)
|
|
188
|
+
return key, nonce, base64.b64encode(token).decode()
|
|
189
|
+
|
|
190
|
+
def need_reload(self) -> bool:
|
|
191
|
+
"""need_reload check if the cert need reload"""
|
|
192
|
+
return time.time() > self._reload_time
|
|
193
|
+
|
|
194
|
+
def init_cert_ring_key_id(self) -> None:
|
|
195
|
+
"""init_cert_ring_key_id init ring id and key id from cert"""
|
|
196
|
+
try:
|
|
197
|
+
from cryptography import x509
|
|
198
|
+
|
|
199
|
+
dns = self._cert.extensions.get_extension_for_class(x509.SubjectAlternativeName).value.get_values_for_type(
|
|
200
|
+
x509.DNSName
|
|
201
|
+
)
|
|
202
|
+
if dns and len(dns) > 1 and re.match(r"^ring\..*$", dns[0]) and re.match(r"^key\..*$", dns[1]):
|
|
203
|
+
self._ring_id = dns[0][5:]
|
|
204
|
+
self._key_id = dns[1][4:]
|
|
205
|
+
else:
|
|
206
|
+
self._ring_id = ""
|
|
207
|
+
self._key_id = ""
|
|
208
|
+
except Exception:
|
|
209
|
+
pass
|
|
210
|
+
|
|
211
|
+
def get_cert_ring_key_id(self) -> Tuple[str, str]:
|
|
212
|
+
"""get_cert_ring_key_id get ring id and key id from cert"""
|
|
213
|
+
return self._ring_id, self._key_id
|
|
214
|
+
|
|
215
|
+
def get_cert_expiration_time(self) -> float:
|
|
216
|
+
"""get_cert_expiration_time get cert expiration time"""
|
|
217
|
+
return self._not_valid_after_utc
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
logger: logging.Logger = logging.getLogger("ark")
|
|
9
|
+
httpx_logger: logging.Logger = logging.getLogger("httpx")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _basic_config() -> None:
|
|
13
|
+
logging.basicConfig(
|
|
14
|
+
format="%(asctime)s %(levelname)s %(message)s",
|
|
15
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def setup_logging() -> None:
|
|
20
|
+
env = os.environ.get("ARK_LOG")
|
|
21
|
+
if env == "debug":
|
|
22
|
+
_basic_config()
|
|
23
|
+
logger.setLevel(logging.DEBUG)
|
|
24
|
+
httpx_logger.setLevel(logging.DEBUG)
|
|
25
|
+
elif env == "info":
|
|
26
|
+
_basic_config()
|
|
27
|
+
logger.setLevel(logging.INFO)
|
|
28
|
+
httpx_logger.setLevel(logging.INFO)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import threading
|
|
7
|
+
import time
|
|
8
|
+
import uuid
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class _QuerySet(object):
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self._items = list()
|
|
14
|
+
self._index = dict()
|
|
15
|
+
self._lock = threading.Lock()
|
|
16
|
+
|
|
17
|
+
def add(self, item: int) -> None:
|
|
18
|
+
with self._lock:
|
|
19
|
+
if item in self._index:
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
self._items.append(item)
|
|
23
|
+
self._index[item] = len(self._items) - 1
|
|
24
|
+
|
|
25
|
+
def remove(self, item: int) -> None:
|
|
26
|
+
with self._lock:
|
|
27
|
+
if item not in self._index:
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
index = self._index[item]
|
|
31
|
+
self._items[index] = self._items[-1]
|
|
32
|
+
self._index[self._items[-1]] = index
|
|
33
|
+
self._items.pop()
|
|
34
|
+
del self._index[item]
|
|
35
|
+
|
|
36
|
+
def query(self, item: int) -> int:
|
|
37
|
+
with self._lock:
|
|
38
|
+
return self._index[item]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ModelBreaker(object):
|
|
42
|
+
def __init__(self):
|
|
43
|
+
# 初始化 allow_time 为当前时间
|
|
44
|
+
self._allow_time = time.perf_counter()
|
|
45
|
+
self._waiters = _QuerySet()
|
|
46
|
+
|
|
47
|
+
def _allow(self, id: int) -> bool:
|
|
48
|
+
cur = time.perf_counter()
|
|
49
|
+
# 如果当前时间小于等于 allow_time,不允许通过
|
|
50
|
+
if cur <= self._allow_time:
|
|
51
|
+
return 0
|
|
52
|
+
# 如果当前时间与 allow_time 的差值大于 10,允许通过
|
|
53
|
+
if cur - self._allow_time > 10:
|
|
54
|
+
return True
|
|
55
|
+
# 如果当前时间与 allow_time 的差值小于等于 10,慢启动通过
|
|
56
|
+
return self._waiters.query(id) < 2 ** (cur - self._allow_time)
|
|
57
|
+
|
|
58
|
+
def _get_allowed_duration(self) -> float:
|
|
59
|
+
# 计算当前时间与 allow_time 之间的持续时间
|
|
60
|
+
allow_duration = self._allow_time - time.perf_counter()
|
|
61
|
+
|
|
62
|
+
# 至少有 1 秒的等待时间
|
|
63
|
+
return max(allow_duration, 1)
|
|
64
|
+
|
|
65
|
+
def _acquire(self) -> int:
|
|
66
|
+
id = uuid.uuid4().int
|
|
67
|
+
self._waiters.add(id)
|
|
68
|
+
return id
|
|
69
|
+
|
|
70
|
+
def _release(self, id: int) -> None:
|
|
71
|
+
self._waiters.remove(id)
|
|
72
|
+
|
|
73
|
+
def reset(self, duration: float) -> None:
|
|
74
|
+
# 将 allow_time 重置为当前时间加上指定的持续时间
|
|
75
|
+
self._allow_time = time.perf_counter() + duration
|
|
76
|
+
|
|
77
|
+
def wait(self) -> None:
|
|
78
|
+
id = self._acquire()
|
|
79
|
+
while not self._allow(id):
|
|
80
|
+
time.sleep(self._get_allowed_duration())
|
|
81
|
+
self._release(id)
|
|
82
|
+
|
|
83
|
+
async def asyncwait(self) -> None:
|
|
84
|
+
id = self._acquire()
|
|
85
|
+
while not self._allow(id):
|
|
86
|
+
await asyncio.sleep(self._get_allowed_duration())
|
|
87
|
+
self._release(id)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
# License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from typing_extensions import AsyncIterator, Iterator
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def consume_sync_iterator(iterator: Iterator[Any]) -> None:
|
|
11
|
+
for _ in iterator:
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async def consume_async_iterator(iterator: AsyncIterator[Any]) -> None:
|
|
16
|
+
async for _ in iterator:
|
|
17
|
+
...
|