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,473 @@
|
|
|
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 functools
|
|
8
|
+
import inspect
|
|
9
|
+
import io
|
|
10
|
+
import os
|
|
11
|
+
import random
|
|
12
|
+
import string
|
|
13
|
+
from datetime import date, datetime
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import (
|
|
16
|
+
Any,
|
|
17
|
+
Callable,
|
|
18
|
+
Iterable,
|
|
19
|
+
Mapping,
|
|
20
|
+
Sequence,
|
|
21
|
+
Tuple,
|
|
22
|
+
TypeVar,
|
|
23
|
+
cast,
|
|
24
|
+
overload,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
from typing_extensions import TypeGuard
|
|
28
|
+
|
|
29
|
+
from .._constants import ARK_APIKEY_PROJECT_NAME
|
|
30
|
+
from .._types import FileTypes, NotGiven, NotGivenOr
|
|
31
|
+
|
|
32
|
+
_T = TypeVar("_T")
|
|
33
|
+
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
|
|
34
|
+
_MappingT = TypeVar("_MappingT", bound=Mapping[str, object])
|
|
35
|
+
_SequenceT = TypeVar("_SequenceT", bound=Sequence[object])
|
|
36
|
+
CallableT = TypeVar("CallableT", bound=Callable[..., Any])
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def flatten(t: Iterable[Iterable[_T]]) -> list[_T]:
|
|
40
|
+
return [item for sublist in t for item in sublist]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def extract_files(
|
|
44
|
+
# TODO: this needs to take Dict but variance issues.....
|
|
45
|
+
# create protocol type ?
|
|
46
|
+
query: Mapping[str, object],
|
|
47
|
+
*,
|
|
48
|
+
paths: Sequence[Sequence[str]],
|
|
49
|
+
) -> list[tuple[str, FileTypes]]:
|
|
50
|
+
"""Recursively extract files from the given dictionary based on specified paths.
|
|
51
|
+
|
|
52
|
+
A path may look like this ['foo', 'files', '<array>', 'data'].
|
|
53
|
+
|
|
54
|
+
Note: this mutates the given dictionary.
|
|
55
|
+
"""
|
|
56
|
+
files: list[tuple[str, FileTypes]] = []
|
|
57
|
+
for path in paths:
|
|
58
|
+
files.extend(_extract_items(query, path, index=0, flattened_key=None))
|
|
59
|
+
return files
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _extract_items(
|
|
63
|
+
obj: object,
|
|
64
|
+
path: Sequence[str],
|
|
65
|
+
*,
|
|
66
|
+
index: int,
|
|
67
|
+
flattened_key: str | None,
|
|
68
|
+
) -> list[tuple[str, FileTypes]]:
|
|
69
|
+
try:
|
|
70
|
+
key = path[index]
|
|
71
|
+
except IndexError:
|
|
72
|
+
if isinstance(obj, NotGiven):
|
|
73
|
+
# no value was provided - we can safely ignore
|
|
74
|
+
return []
|
|
75
|
+
|
|
76
|
+
# cyclical import
|
|
77
|
+
from .._files import assert_is_file_content
|
|
78
|
+
|
|
79
|
+
# We have exhausted the path, return the entry we found.
|
|
80
|
+
assert_is_file_content(obj, key=flattened_key)
|
|
81
|
+
assert flattened_key is not None
|
|
82
|
+
return [(flattened_key, cast(FileTypes, obj))]
|
|
83
|
+
|
|
84
|
+
index += 1
|
|
85
|
+
if is_dict(obj):
|
|
86
|
+
try:
|
|
87
|
+
# We are at the last entry in the path so we must remove the field
|
|
88
|
+
if (len(path)) == index:
|
|
89
|
+
item = obj.pop(key)
|
|
90
|
+
else:
|
|
91
|
+
item = obj[key]
|
|
92
|
+
except KeyError:
|
|
93
|
+
# Key was not present in the dictionary, this is not indicative of an error
|
|
94
|
+
# as the given path may not point to a required field. We also do not want
|
|
95
|
+
# to enforce required fields as the API may differ from the spec in some cases.
|
|
96
|
+
return []
|
|
97
|
+
if flattened_key is None:
|
|
98
|
+
flattened_key = key
|
|
99
|
+
else:
|
|
100
|
+
flattened_key += f"[{key}]"
|
|
101
|
+
return _extract_items(
|
|
102
|
+
item,
|
|
103
|
+
path,
|
|
104
|
+
index=index,
|
|
105
|
+
flattened_key=flattened_key,
|
|
106
|
+
)
|
|
107
|
+
elif is_list(obj):
|
|
108
|
+
if key != "<array>":
|
|
109
|
+
return []
|
|
110
|
+
|
|
111
|
+
return flatten(
|
|
112
|
+
[
|
|
113
|
+
_extract_items(
|
|
114
|
+
item,
|
|
115
|
+
path,
|
|
116
|
+
index=index,
|
|
117
|
+
flattened_key=flattened_key + "[]" if flattened_key is not None else "[]",
|
|
118
|
+
)
|
|
119
|
+
for item in obj
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Something unexpected was passed, just ignore it.
|
|
124
|
+
return []
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]:
|
|
128
|
+
return not isinstance(obj, NotGiven)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Type safe methods for narrowing types with TypeVars.
|
|
132
|
+
# The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
|
|
133
|
+
# however this cause Pyright to rightfully report errors. As we know we don't
|
|
134
|
+
# care about the contained types we can safely use `object` in it's place.
|
|
135
|
+
#
|
|
136
|
+
# There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
|
|
137
|
+
# `is_*` is for when you're dealing with an unknown input
|
|
138
|
+
# `is_*_t` is for when you're narrowing a known union type to a specific subset
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def is_tuple(obj: object) -> TypeGuard[tuple[object, ...]]:
|
|
142
|
+
return isinstance(obj, tuple)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def is_tuple_t(obj: _TupleT | object) -> TypeGuard[_TupleT]:
|
|
146
|
+
return isinstance(obj, tuple)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def is_sequence(obj: object) -> TypeGuard[Sequence[object]]:
|
|
150
|
+
return isinstance(obj, Sequence)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def is_sequence_t(obj: _SequenceT | object) -> TypeGuard[_SequenceT]:
|
|
154
|
+
return isinstance(obj, Sequence)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def is_mapping(obj: object) -> TypeGuard[Mapping[str, object]]:
|
|
158
|
+
return isinstance(obj, Mapping)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def is_mapping_t(obj: _MappingT | object) -> TypeGuard[_MappingT]:
|
|
162
|
+
return isinstance(obj, Mapping)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def is_dict(obj: object) -> TypeGuard[dict[object, object]]:
|
|
166
|
+
return isinstance(obj, dict)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def is_list(obj: object) -> TypeGuard[list[object]]:
|
|
170
|
+
return isinstance(obj, list)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
|
|
174
|
+
return isinstance(obj, Iterable)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def is_base64_file_input(obj: object) -> bool:
|
|
178
|
+
return isinstance(obj, io.IOBase) or isinstance(obj, os.PathLike)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def deepcopy_minimal(item: _T) -> _T:
|
|
182
|
+
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
|
|
183
|
+
|
|
184
|
+
- mappings, e.g. `dict`
|
|
185
|
+
- list
|
|
186
|
+
|
|
187
|
+
This is done for performance reasons.
|
|
188
|
+
"""
|
|
189
|
+
if is_mapping(item):
|
|
190
|
+
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
|
|
191
|
+
if is_list(item):
|
|
192
|
+
return cast(_T, [deepcopy_minimal(entry) for entry in item])
|
|
193
|
+
return item
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# copied from https://github.com/Rapptz/RoboDanny
|
|
197
|
+
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
|
|
198
|
+
size = len(seq)
|
|
199
|
+
if size == 0:
|
|
200
|
+
return ""
|
|
201
|
+
|
|
202
|
+
if size == 1:
|
|
203
|
+
return seq[0]
|
|
204
|
+
|
|
205
|
+
if size == 2:
|
|
206
|
+
return f"{seq[0]} {final} {seq[1]}"
|
|
207
|
+
|
|
208
|
+
return delim.join(seq[:-1]) + f" {final} {seq[-1]}"
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def quote(string: str) -> str:
|
|
212
|
+
"""Add single quotation marks around the given string. Does *not* do any escaping."""
|
|
213
|
+
return f"'{string}'"
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]:
|
|
217
|
+
"""Decorator to enforce a given set of arguments or variants of arguments are passed to the decorated function.
|
|
218
|
+
|
|
219
|
+
Useful for enforcing runtime validation of overloaded functions.
|
|
220
|
+
|
|
221
|
+
Example usage:
|
|
222
|
+
```py
|
|
223
|
+
@overload
|
|
224
|
+
def foo(*, a: str) -> str: ...
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@overload
|
|
228
|
+
def foo(*, b: bool) -> str: ...
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
# This enforces the same constraints that a static type checker would
|
|
232
|
+
# i.e. that either a or b must be passed to the function
|
|
233
|
+
@required_args(["a"], ["b"])
|
|
234
|
+
def foo(*, a: str | None = None, b: bool | None = None) -> str: ...
|
|
235
|
+
```
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
def inner(func: CallableT) -> CallableT:
|
|
239
|
+
params = inspect.signature(func).parameters
|
|
240
|
+
positional = [
|
|
241
|
+
name
|
|
242
|
+
for name, param in params.items()
|
|
243
|
+
if param.kind
|
|
244
|
+
in {
|
|
245
|
+
param.POSITIONAL_ONLY,
|
|
246
|
+
param.POSITIONAL_OR_KEYWORD,
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
|
|
250
|
+
@functools.wraps(func)
|
|
251
|
+
def wrapper(*args: object, **kwargs: object) -> object:
|
|
252
|
+
given_params: set[str] = set()
|
|
253
|
+
for i, _ in enumerate(args):
|
|
254
|
+
try:
|
|
255
|
+
given_params.add(positional[i])
|
|
256
|
+
except IndexError:
|
|
257
|
+
raise TypeError(
|
|
258
|
+
f"{func.__name__}() takes {len(positional)} argument(s) but {len(args)} were given"
|
|
259
|
+
) from None
|
|
260
|
+
|
|
261
|
+
for key in kwargs.keys():
|
|
262
|
+
given_params.add(key)
|
|
263
|
+
|
|
264
|
+
for variant in variants:
|
|
265
|
+
matches = all((param in given_params for param in variant))
|
|
266
|
+
if matches:
|
|
267
|
+
break
|
|
268
|
+
else: # no break
|
|
269
|
+
if len(variants) > 1:
|
|
270
|
+
variations = human_join(
|
|
271
|
+
["(" + human_join([quote(arg) for arg in variant], final="and") + ")" for variant in variants]
|
|
272
|
+
)
|
|
273
|
+
msg = f"Missing required arguments; Expected either {variations} arguments to be given"
|
|
274
|
+
else:
|
|
275
|
+
assert len(variants) > 0
|
|
276
|
+
|
|
277
|
+
# TODO: this error message is not deterministic
|
|
278
|
+
missing = list(set(variants[0]) - given_params)
|
|
279
|
+
if len(missing) > 1:
|
|
280
|
+
msg = f"Missing required arguments: {human_join([quote(arg) for arg in missing])}"
|
|
281
|
+
else:
|
|
282
|
+
msg = f"Missing required argument: {quote(missing[0])}"
|
|
283
|
+
raise TypeError(msg)
|
|
284
|
+
return func(*args, **kwargs)
|
|
285
|
+
|
|
286
|
+
return wrapper # type: ignore
|
|
287
|
+
|
|
288
|
+
return inner
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
_K = TypeVar("_K")
|
|
292
|
+
_V = TypeVar("_V")
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
@overload
|
|
296
|
+
def strip_not_given(obj: None) -> None: ...
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@overload
|
|
300
|
+
def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ...
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@overload
|
|
304
|
+
def strip_not_given(obj: object) -> object: ...
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def strip_not_given(obj: object | None) -> object:
|
|
308
|
+
"""Remove all top-level keys where their values are instances of `NotGiven`"""
|
|
309
|
+
if obj is None:
|
|
310
|
+
return None
|
|
311
|
+
|
|
312
|
+
if not is_mapping(obj):
|
|
313
|
+
return obj
|
|
314
|
+
|
|
315
|
+
return {key: value for key, value in obj.items() if not isinstance(value, NotGiven)}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def coerce_integer(val: str) -> int:
|
|
319
|
+
return int(val, base=10)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def coerce_float(val: str) -> float:
|
|
323
|
+
return float(val)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def coerce_boolean(val: str) -> bool:
|
|
327
|
+
return val == "true" or val == "1" or val == "on"
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def maybe_coerce_integer(val: str | None) -> int | None:
|
|
331
|
+
if val is None:
|
|
332
|
+
return None
|
|
333
|
+
return coerce_integer(val)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def maybe_coerce_float(val: str | None) -> float | None:
|
|
337
|
+
if val is None:
|
|
338
|
+
return None
|
|
339
|
+
return coerce_float(val)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def maybe_coerce_boolean(val: str | None) -> bool | None:
|
|
343
|
+
if val is None:
|
|
344
|
+
return None
|
|
345
|
+
return coerce_boolean(val)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def removeprefix(string: str, prefix: str) -> str:
|
|
349
|
+
"""Remove a prefix from a string.
|
|
350
|
+
|
|
351
|
+
Backport of `str.removeprefix` for Python < 3.9
|
|
352
|
+
"""
|
|
353
|
+
if string.startswith(prefix):
|
|
354
|
+
return string[len(prefix) :]
|
|
355
|
+
return string
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def removesuffix(string: str, suffix: str) -> str:
|
|
359
|
+
"""Remove a suffix from a string.
|
|
360
|
+
|
|
361
|
+
Backport of `str.removesuffix` for Python < 3.9
|
|
362
|
+
"""
|
|
363
|
+
if string.endswith(suffix):
|
|
364
|
+
return string[: -len(suffix)]
|
|
365
|
+
return string
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def file_from_path(path: str) -> FileTypes:
|
|
369
|
+
contents = Path(path).read_bytes()
|
|
370
|
+
file_name = os.path.basename(path)
|
|
371
|
+
return (file_name, contents)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def get_async_library() -> str:
|
|
375
|
+
try:
|
|
376
|
+
import sniffio
|
|
377
|
+
|
|
378
|
+
return sniffio.current_async_library()
|
|
379
|
+
except Exception:
|
|
380
|
+
return "false"
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
|
|
384
|
+
"""A version of functools.lru_cache that retains the type signature
|
|
385
|
+
for the wrapped function arguments.
|
|
386
|
+
"""
|
|
387
|
+
wrapper = functools.lru_cache( # noqa: TID251
|
|
388
|
+
maxsize=maxsize,
|
|
389
|
+
)
|
|
390
|
+
return cast(Any, wrapper) # type: ignore[no-any-return]
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def json_safe(data: object) -> object:
|
|
394
|
+
"""Translates a mapping / sequence recursively in the same fashion
|
|
395
|
+
as `pydantic` v2's `model_dump(mode="json")`.
|
|
396
|
+
"""
|
|
397
|
+
if is_mapping(data):
|
|
398
|
+
return {json_safe(key): json_safe(value) for key, value in data.items()}
|
|
399
|
+
|
|
400
|
+
if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
|
|
401
|
+
return [json_safe(item) for item in data]
|
|
402
|
+
|
|
403
|
+
if isinstance(data, (datetime, date)):
|
|
404
|
+
return data.isoformat()
|
|
405
|
+
|
|
406
|
+
return data
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def _gen_request_id():
|
|
410
|
+
time_str = datetime.now().strftime("%Y%m%d%H%M%S")
|
|
411
|
+
chars = string.ascii_letters + string.digits
|
|
412
|
+
rand_str = "".join(random.choice(chars) for i in range(20))
|
|
413
|
+
return f"{time_str}{rand_str}"
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def with_sts_token(func):
|
|
417
|
+
def wrapper(*args, **kwargs):
|
|
418
|
+
_insert_sts_token(args, kwargs)
|
|
419
|
+
return func(*args, **kwargs)
|
|
420
|
+
|
|
421
|
+
return wrapper
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def async_with_sts_token(func):
|
|
425
|
+
async def wrapper(*args, **kwargs):
|
|
426
|
+
_insert_sts_token(args, kwargs)
|
|
427
|
+
return await func(*args, **kwargs)
|
|
428
|
+
|
|
429
|
+
return wrapper
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def _insert_sts_token(args, kwargs):
|
|
433
|
+
assert len(args) > 0
|
|
434
|
+
assert "model" in kwargs, "you need to support model"
|
|
435
|
+
|
|
436
|
+
ark_client = args[0]._client
|
|
437
|
+
model = kwargs.get("model", "")
|
|
438
|
+
if ark_client.api_key is None and model and model.startswith("bot-") and ark_client.ak and ark_client.sk:
|
|
439
|
+
default_auth_header = {"Authorization": "Bearer " + ark_client._get_bot_sts_token(model)}
|
|
440
|
+
extra_headers = kwargs.get("extra_headers") if kwargs.get("extra_headers") else {}
|
|
441
|
+
kwargs["extra_headers"] = {**default_auth_header, **extra_headers}
|
|
442
|
+
elif ark_client.api_key is None and model and ark_client.ak and ark_client.sk:
|
|
443
|
+
extra_headers = kwargs.get("extra_headers") if kwargs.get("extra_headers") else {}
|
|
444
|
+
project_name: str = None
|
|
445
|
+
if extra_headers is not None and extra_headers.get(ARK_APIKEY_PROJECT_NAME, None) is not None:
|
|
446
|
+
project_name = extra_headers[ARK_APIKEY_PROJECT_NAME]
|
|
447
|
+
default_auth_header = {"Authorization": "Bearer " + ark_client._get_endpoint_sts_token(model, project_name)}
|
|
448
|
+
kwargs["extra_headers"] = {**default_auth_header, **extra_headers}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def apikey_required(func):
|
|
452
|
+
def wrapper(*args, **kwargs):
|
|
453
|
+
_assert_apikey(args, kwargs)
|
|
454
|
+
return func(*args, **kwargs)
|
|
455
|
+
|
|
456
|
+
return wrapper
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def async_apikey_required(func):
|
|
460
|
+
async def wrapper(*args, **kwargs):
|
|
461
|
+
_assert_apikey(args, kwargs)
|
|
462
|
+
return await func(*args, **kwargs)
|
|
463
|
+
|
|
464
|
+
return wrapper
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def _assert_apikey(args, kwargs):
|
|
468
|
+
assert len(args) > 0
|
|
469
|
+
|
|
470
|
+
ark_client = args[0]._client
|
|
471
|
+
assert ark_client.api_key is not None, (
|
|
472
|
+
"ak&sk authentication is currently not supported for this method, please use api key instead"
|
|
473
|
+
)
|
|
@@ -0,0 +1,6 @@
|
|
|
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 ._parsing import ResponseFormatT as ResponseFormatT
|
|
6
|
+
from ._tools import pydantic_function_tool as pydantic_function_tool
|
|
@@ -0,0 +1,31 @@
|
|
|
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 ._completions import (
|
|
6
|
+
ResponseFormatT as ResponseFormatT,
|
|
7
|
+
)
|
|
8
|
+
from ._completions import (
|
|
9
|
+
get_input_tool_by_name as get_input_tool_by_name,
|
|
10
|
+
)
|
|
11
|
+
from ._completions import (
|
|
12
|
+
has_parseable_input as has_parseable_input,
|
|
13
|
+
)
|
|
14
|
+
from ._completions import (
|
|
15
|
+
maybe_parse_content as maybe_parse_content,
|
|
16
|
+
)
|
|
17
|
+
from ._completions import (
|
|
18
|
+
parse_chat_completion as parse_chat_completion,
|
|
19
|
+
)
|
|
20
|
+
from ._completions import (
|
|
21
|
+
parse_function_tool_arguments as parse_function_tool_arguments,
|
|
22
|
+
)
|
|
23
|
+
from ._completions import (
|
|
24
|
+
solve_response_format_t as solve_response_format_t,
|
|
25
|
+
)
|
|
26
|
+
from ._completions import (
|
|
27
|
+
type_to_response_format_param as type_to_response_format_param,
|
|
28
|
+
)
|
|
29
|
+
from ._completions import (
|
|
30
|
+
validate_input_tools as validate_input_tools,
|
|
31
|
+
)
|