kiapi 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.
- kiapi/__init__.py +3 -0
- kiapi/__main__.py +4 -0
- kiapi/api/__init__.py +26 -0
- kiapi/api/_constants/require_auth.py +14 -0
- kiapi/api/_helpers/build_job_responses.py +73 -0
- kiapi/api/_helpers/build_openapi.py +55 -0
- kiapi/api/_helpers/build_train_responses.py +21 -0
- kiapi/api/_helpers/get_accept.py +20 -0
- kiapi/api/_helpers/get_ctx.py +7 -0
- kiapi/api/_helpers/get_worker.py +7 -0
- kiapi/api/_helpers/register_capability_endpoints.py +70 -0
- kiapi/api/_helpers/submit_and_maybe_wait.py +113 -0
- kiapi/api/_settings.py +50 -0
- kiapi/api/_views/async_job_response.py +21 -0
- kiapi/api/_views/capability_model_spec.py +49 -0
- kiapi/api/app.py +150 -0
- kiapi/api/audio/acestep/_views/extract_response.py +57 -0
- kiapi/api/audio/acestep/_views/track_response.py +57 -0
- kiapi/api/audio/acestep/router.py +190 -0
- kiapi/api/audio/audiogen/_views/audio_response.py +46 -0
- kiapi/api/audio/audiogen/router.py +77 -0
- kiapi/api/chat/_views/chat_completion_response.py +71 -0
- kiapi/api/chat/router.py +253 -0
- kiapi/api/embedding/_views/embedding_response.py +35 -0
- kiapi/api/embedding/router.py +82 -0
- kiapi/api/files/_operations/get_file.py +14 -0
- kiapi/api/files/_operations/get_file_id.py +18 -0
- kiapi/api/files/_views/file_delete_response.py +14 -0
- kiapi/api/files/_views/file_list_response.py +15 -0
- kiapi/api/files/router.py +105 -0
- kiapi/api/health/_views/health_response.py +26 -0
- kiapi/api/health/router.py +28 -0
- kiapi/api/image/depthpro/_views/estimate_response.py +70 -0
- kiapi/api/image/depthpro/router.py +81 -0
- kiapi/api/image/ernie/_views/image_response.py +50 -0
- kiapi/api/image/ernie/router.py +181 -0
- kiapi/api/image/flux2/_views/image_response.py +53 -0
- kiapi/api/image/flux2/router.py +197 -0
- kiapi/api/image/ideogram4/_views/image_response.py +55 -0
- kiapi/api/image/ideogram4/router.py +87 -0
- kiapi/api/image/qwen/_views/image_response.py +47 -0
- kiapi/api/image/qwen/router.py +141 -0
- kiapi/api/image/seedvr2/_views/image_response.py +50 -0
- kiapi/api/image/seedvr2/router.py +83 -0
- kiapi/api/image/zimage/_views/image_response.py +49 -0
- kiapi/api/image/zimage/router.py +131 -0
- kiapi/api/jobs/_operations/get_job_id.py +18 -0
- kiapi/api/jobs/_views/job_delete_response.py +19 -0
- kiapi/api/jobs/_views/job_list_response.py +15 -0
- kiapi/api/jobs/router.py +62 -0
- kiapi/api/models/_schemas/openai_model_spec.py +26 -0
- kiapi/api/models/_views/model_list_response.py +15 -0
- kiapi/api/models/router.py +29 -0
- kiapi/api/video/ltx2/_views/__init__.py +1 -0
- kiapi/api/video/ltx2/_views/video_response.py +59 -0
- kiapi/api/video/ltx2/router.py +89 -0
- kiapi/api/web/_views/__init__.py +7 -0
- kiapi/api/web/_views/fetch_api_request.py +26 -0
- kiapi/api/web/_views/fetch_error_response.py +25 -0
- kiapi/api/web/router.py +302 -0
- kiapi/capabilities/__init__.py +24 -0
- kiapi/capabilities/_exceptions/CapabilityError.py +2 -0
- kiapi/capabilities/_exceptions/ValidationError.py +2 -0
- kiapi/capabilities/_helpers/attach_mflux_progress.py +50 -0
- kiapi/capabilities/_helpers/get_file_path.py +20 -0
- kiapi/capabilities/_helpers/resolve_file_ref.py +16 -0
- kiapi/capabilities/acestep/README.ja.md +174 -0
- kiapi/capabilities/acestep/README.md +167 -0
- kiapi/capabilities/acestep/__init__.py +37 -0
- kiapi/capabilities/acestep/_constants/description.py +122 -0
- kiapi/capabilities/acestep/_exceptions/ace_step_engine_error.py +2 -0
- kiapi/capabilities/acestep/_helpers/register.py +96 -0
- kiapi/capabilities/acestep/_models/acestep.py +105 -0
- kiapi/capabilities/acestep/_operations/handle_cover.py +23 -0
- kiapi/capabilities/acestep/_operations/handle_extract.py +38 -0
- kiapi/capabilities/acestep/_operations/handle_generate.py +18 -0
- kiapi/capabilities/acestep/_operations/handle_repaint.py +25 -0
- kiapi/capabilities/acestep/_operations/resolve_ace_step_paths.py +30 -0
- kiapi/capabilities/acestep/_operations/resolve_cover_params.py +21 -0
- kiapi/capabilities/acestep/_operations/resolve_engine.py +10 -0
- kiapi/capabilities/acestep/_operations/resolve_extract_params.py +24 -0
- kiapi/capabilities/acestep/_operations/resolve_generate_params.py +18 -0
- kiapi/capabilities/acestep/_operations/resolve_repaint_params.py +22 -0
- kiapi/capabilities/acestep/_schemas/ace_step_paths.py +29 -0
- kiapi/capabilities/acestep/_services/ace_step_engine.py +143 -0
- kiapi/capabilities/acestep/_settings.py +82 -0
- kiapi/capabilities/acestep/_views/ace_step_base.py +61 -0
- kiapi/capabilities/acestep/_views/cover_params.py +26 -0
- kiapi/capabilities/acestep/_views/cover_request.py +49 -0
- kiapi/capabilities/acestep/_views/extract_params.py +24 -0
- kiapi/capabilities/acestep/_views/extract_request.py +33 -0
- kiapi/capabilities/acestep/_views/generate_params.py +25 -0
- kiapi/capabilities/acestep/_views/generate_request.py +54 -0
- kiapi/capabilities/acestep/_views/repaint_params.py +27 -0
- kiapi/capabilities/acestep/_views/repaint_request.py +51 -0
- kiapi/capabilities/acestep/_views/track_params.py +7 -0
- kiapi/capabilities/acestep/worker_subprocess.py +247 -0
- kiapi/capabilities/audiogen/README.ja.md +49 -0
- kiapi/capabilities/audiogen/README.md +48 -0
- kiapi/capabilities/audiogen/__init__.py +25 -0
- kiapi/capabilities/audiogen/_constants/description.py +60 -0
- kiapi/capabilities/audiogen/_helpers/attach_audiogen_progress.py +27 -0
- kiapi/capabilities/audiogen/_helpers/register.py +42 -0
- kiapi/capabilities/audiogen/_helpers/validate_generate.py +14 -0
- kiapi/capabilities/audiogen/_models/audiogen.py +98 -0
- kiapi/capabilities/audiogen/_operations/handle_generate.py +27 -0
- kiapi/capabilities/audiogen/_operations/resolve_generate_params.py +25 -0
- kiapi/capabilities/audiogen/_settings.py +34 -0
- kiapi/capabilities/audiogen/_views/generate_params.py +14 -0
- kiapi/capabilities/audiogen/_views/generate_request.py +96 -0
- kiapi/capabilities/chat/README.ja.md +822 -0
- kiapi/capabilities/chat/README.md +806 -0
- kiapi/capabilities/chat/__init__.py +25 -0
- kiapi/capabilities/chat/_constants/description.py +163 -0
- kiapi/capabilities/chat/_helpers/register.py +67 -0
- kiapi/capabilities/chat/_models/qwen3_5.py +183 -0
- kiapi/capabilities/chat/_models/qwen3_omni.py +242 -0
- kiapi/capabilities/chat/_operations/apply_template.py +74 -0
- kiapi/capabilities/chat/_operations/completed_hermes_tool_call_text.py +9 -0
- kiapi/capabilities/chat/_operations/emit_streaming_response.py +297 -0
- kiapi/capabilities/chat/_operations/ensure_streaming_detokenizer_compat.py +49 -0
- kiapi/capabilities/chat/_operations/format_response.py +72 -0
- kiapi/capabilities/chat/_operations/handle_chat.py +25 -0
- kiapi/capabilities/chat/_operations/parse_hermes_tool_calls.py +63 -0
- kiapi/capabilities/chat/_operations/parse_json_tool_calls.py +66 -0
- kiapi/capabilities/chat/_operations/parse_messages.py +326 -0
- kiapi/capabilities/chat/_operations/resolve_chat_params.py +50 -0
- kiapi/capabilities/chat/_operations/stream_text_from_tokens.py +32 -0
- kiapi/capabilities/chat/_operations/strip_tool_calls.py +15 -0
- kiapi/capabilities/chat/_settings.py +74 -0
- kiapi/capabilities/chat/_utils/apply_parallel_tool_call_policy.py +17 -0
- kiapi/capabilities/chat/_utils/apply_seed.py +8 -0
- kiapi/capabilities/chat/_utils/load_audio_mono.py +31 -0
- kiapi/capabilities/chat/_utils/load_mlx_vlm.py +12 -0
- kiapi/capabilities/chat/_utils/warmup_params.py +26 -0
- kiapi/capabilities/chat/_views/chat_params.py +34 -0
- kiapi/capabilities/chat/_views/chat_request.py +153 -0
- kiapi/capabilities/depthpro/README.ja.md +131 -0
- kiapi/capabilities/depthpro/README.md +124 -0
- kiapi/capabilities/depthpro/__init__.py +23 -0
- kiapi/capabilities/depthpro/_constants/description.py +39 -0
- kiapi/capabilities/depthpro/_helpers/register.py +46 -0
- kiapi/capabilities/depthpro/_helpers/validate_estimate.py +32 -0
- kiapi/capabilities/depthpro/_models/depthpro.py +144 -0
- kiapi/capabilities/depthpro/_operations/handle_estimate.py +50 -0
- kiapi/capabilities/depthpro/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/depthpro/_operations/resolve_estimate_params.py +24 -0
- kiapi/capabilities/depthpro/_settings.py +46 -0
- kiapi/capabilities/depthpro/_views/estimate_params.py +21 -0
- kiapi/capabilities/depthpro/_views/estimate_request.py +63 -0
- kiapi/capabilities/embedding/README.ja.md +137 -0
- kiapi/capabilities/embedding/README.md +128 -0
- kiapi/capabilities/embedding/__init__.py +24 -0
- kiapi/capabilities/embedding/_constants/description.py +47 -0
- kiapi/capabilities/embedding/_helpers/register.py +66 -0
- kiapi/capabilities/embedding/_models/qwen3_text.py +53 -0
- kiapi/capabilities/embedding/_models/qwen3_vl.py +97 -0
- kiapi/capabilities/embedding/_operations/format_response.py +24 -0
- kiapi/capabilities/embedding/_operations/handle_embed.py +24 -0
- kiapi/capabilities/embedding/_operations/parse_inputs.py +108 -0
- kiapi/capabilities/embedding/_operations/resolve_embed_params.py +18 -0
- kiapi/capabilities/embedding/_settings.py +27 -0
- kiapi/capabilities/embedding/_utils/to_vector.py +20 -0
- kiapi/capabilities/embedding/_views/embed_params.py +17 -0
- kiapi/capabilities/embedding/_views/embed_request.py +39 -0
- kiapi/capabilities/ernie/README.ja.md +242 -0
- kiapi/capabilities/ernie/README.md +223 -0
- kiapi/capabilities/ernie/__init__.py +34 -0
- kiapi/capabilities/ernie/_constants/description.py +71 -0
- kiapi/capabilities/ernie/_helpers/register.py +60 -0
- kiapi/capabilities/ernie/_helpers/validate_edit.py +19 -0
- kiapi/capabilities/ernie/_helpers/validate_generate.py +8 -0
- kiapi/capabilities/ernie/_models/ernie.py +356 -0
- kiapi/capabilities/ernie/_operations/handle_edit.py +39 -0
- kiapi/capabilities/ernie/_operations/handle_generate.py +38 -0
- kiapi/capabilities/ernie/_operations/handle_train.py +77 -0
- kiapi/capabilities/ernie/_operations/is_quantize_override.py +16 -0
- kiapi/capabilities/ernie/_operations/resolve_edit_params.py +44 -0
- kiapi/capabilities/ernie/_operations/resolve_generate_params.py +40 -0
- kiapi/capabilities/ernie/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/ernie/_operations/resolve_train_params.py +43 -0
- kiapi/capabilities/ernie/_operations/validate_common.py +33 -0
- kiapi/capabilities/ernie/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/ernie/_settings.py +151 -0
- kiapi/capabilities/ernie/_views/edit_params.py +36 -0
- kiapi/capabilities/ernie/_views/edit_request.py +142 -0
- kiapi/capabilities/ernie/_views/generate_params.py +32 -0
- kiapi/capabilities/ernie/_views/generate_request.py +127 -0
- kiapi/capabilities/ernie/_views/train_params.py +28 -0
- kiapi/capabilities/ernie/_views/train_request.py +96 -0
- kiapi/capabilities/flux2/README.ja.md +260 -0
- kiapi/capabilities/flux2/README.md +241 -0
- kiapi/capabilities/flux2/__init__.py +36 -0
- kiapi/capabilities/flux2/_constants/description.py +81 -0
- kiapi/capabilities/flux2/_helpers/register.py +98 -0
- kiapi/capabilities/flux2/_helpers/validate_edit.py +12 -0
- kiapi/capabilities/flux2/_helpers/validate_generate.py +8 -0
- kiapi/capabilities/flux2/_models/flux2.py +396 -0
- kiapi/capabilities/flux2/_operations/handle_edit.py +44 -0
- kiapi/capabilities/flux2/_operations/handle_generate.py +46 -0
- kiapi/capabilities/flux2/_operations/handle_train.py +105 -0
- kiapi/capabilities/flux2/_operations/is_quantize_override.py +16 -0
- kiapi/capabilities/flux2/_operations/resolve_edit_params.py +43 -0
- kiapi/capabilities/flux2/_operations/resolve_generate_params.py +44 -0
- kiapi/capabilities/flux2/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/flux2/_operations/resolve_train_params.py +42 -0
- kiapi/capabilities/flux2/_operations/role_spec.py +13 -0
- kiapi/capabilities/flux2/_operations/split_repo.py +11 -0
- kiapi/capabilities/flux2/_operations/validate_common.py +35 -0
- kiapi/capabilities/flux2/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/flux2/_settings.py +181 -0
- kiapi/capabilities/flux2/_views/edit_params.py +36 -0
- kiapi/capabilities/flux2/_views/edit_request.py +145 -0
- kiapi/capabilities/flux2/_views/generate_params.py +36 -0
- kiapi/capabilities/flux2/_views/generate_request.py +150 -0
- kiapi/capabilities/flux2/_views/train_params.py +32 -0
- kiapi/capabilities/flux2/_views/train_request.py +102 -0
- kiapi/capabilities/ideogram4/README.ja.md +230 -0
- kiapi/capabilities/ideogram4/README.md +219 -0
- kiapi/capabilities/ideogram4/__init__.py +24 -0
- kiapi/capabilities/ideogram4/_constants/description.py +65 -0
- kiapi/capabilities/ideogram4/_helpers/register.py +44 -0
- kiapi/capabilities/ideogram4/_helpers/validate_generate.py +31 -0
- kiapi/capabilities/ideogram4/_models/ideogram4.py +120 -0
- kiapi/capabilities/ideogram4/_operations/handle_generate.py +30 -0
- kiapi/capabilities/ideogram4/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/ideogram4/_operations/resolve_generate_params.py +30 -0
- kiapi/capabilities/ideogram4/_settings.py +89 -0
- kiapi/capabilities/ideogram4/_views/generate_params.py +27 -0
- kiapi/capabilities/ideogram4/_views/generate_request.py +118 -0
- kiapi/capabilities/ltx2/README.ja.md +287 -0
- kiapi/capabilities/ltx2/README.md +274 -0
- kiapi/capabilities/ltx2/__init__.py +26 -0
- kiapi/capabilities/ltx2/_constants/description.py +81 -0
- kiapi/capabilities/ltx2/_helpers/register.py +58 -0
- kiapi/capabilities/ltx2/_helpers/validate_generate.py +42 -0
- kiapi/capabilities/ltx2/_models/ltx2.py +106 -0
- kiapi/capabilities/ltx2/_operations/detect_mode.py +19 -0
- kiapi/capabilities/ltx2/_operations/handle_generate.py +52 -0
- kiapi/capabilities/ltx2/_operations/resolve_generate_params.py +31 -0
- kiapi/capabilities/ltx2/_settings.py +93 -0
- kiapi/capabilities/ltx2/_views/generate_params.py +34 -0
- kiapi/capabilities/ltx2/_views/generate_request.py +151 -0
- kiapi/capabilities/qwen/README.ja.md +251 -0
- kiapi/capabilities/qwen/README.md +235 -0
- kiapi/capabilities/qwen/__init__.py +30 -0
- kiapi/capabilities/qwen/_constants/description.py +53 -0
- kiapi/capabilities/qwen/_helpers/register.py +60 -0
- kiapi/capabilities/qwen/_helpers/validate_edit.py +12 -0
- kiapi/capabilities/qwen/_helpers/validate_generate.py +12 -0
- kiapi/capabilities/qwen/_models/qwen.py +224 -0
- kiapi/capabilities/qwen/_operations/handle_edit.py +44 -0
- kiapi/capabilities/qwen/_operations/handle_generate.py +46 -0
- kiapi/capabilities/qwen/_operations/is_quantize_override.py +15 -0
- kiapi/capabilities/qwen/_operations/resolve_edit_params.py +35 -0
- kiapi/capabilities/qwen/_operations/resolve_generate_params.py +39 -0
- kiapi/capabilities/qwen/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/qwen/_operations/validate_common.py +32 -0
- kiapi/capabilities/qwen/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/qwen/_settings.py +107 -0
- kiapi/capabilities/qwen/_views/edit_params.py +36 -0
- kiapi/capabilities/qwen/_views/edit_request.py +138 -0
- kiapi/capabilities/qwen/_views/generate_params.py +37 -0
- kiapi/capabilities/qwen/_views/generate_request.py +149 -0
- kiapi/capabilities/seedvr2/README.ja.md +234 -0
- kiapi/capabilities/seedvr2/README.md +219 -0
- kiapi/capabilities/seedvr2/__init__.py +24 -0
- kiapi/capabilities/seedvr2/_constants/description.py +46 -0
- kiapi/capabilities/seedvr2/_helpers/register.py +60 -0
- kiapi/capabilities/seedvr2/_helpers/validate_upscale.py +52 -0
- kiapi/capabilities/seedvr2/_models/seedvr2.py +140 -0
- kiapi/capabilities/seedvr2/_operations/handle_upscale.py +42 -0
- kiapi/capabilities/seedvr2/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/seedvr2/_operations/resolve_upscale_params.py +30 -0
- kiapi/capabilities/seedvr2/_settings.py +74 -0
- kiapi/capabilities/seedvr2/_views/upscale_params.py +27 -0
- kiapi/capabilities/seedvr2/_views/upscale_request.py +94 -0
- kiapi/capabilities/web/README.ja.md +187 -0
- kiapi/capabilities/web/README.md +171 -0
- kiapi/capabilities/web/__init__.py +30 -0
- kiapi/capabilities/web/_constants/description.py +38 -0
- kiapi/capabilities/web/_exceptions/FetchError.py +24 -0
- kiapi/capabilities/web/_exceptions/SearchBackendError.py +11 -0
- kiapi/capabilities/web/_helpers/register.py +59 -0
- kiapi/capabilities/web/_models/crawl4ai.py +32 -0
- kiapi/capabilities/web/_models/searxng.py +44 -0
- kiapi/capabilities/web/_operations/handle_fetch.py +145 -0
- kiapi/capabilities/web/_operations/handle_search.py +56 -0
- kiapi/capabilities/web/_operations/resolve_fetch_params.py +19 -0
- kiapi/capabilities/web/_operations/resolve_search_params.py +34 -0
- kiapi/capabilities/web/_operations/resolve_searxng_config_dir.py +21 -0
- kiapi/capabilities/web/_services/__init__.py +1 -0
- kiapi/capabilities/web/_services/web_backend_process.py +144 -0
- kiapi/capabilities/web/_settings.py +138 -0
- kiapi/capabilities/web/_views/fetch_params.py +27 -0
- kiapi/capabilities/web/_views/fetch_request.py +29 -0
- kiapi/capabilities/web/_views/fetch_result.py +20 -0
- kiapi/capabilities/web/_views/search_params.py +43 -0
- kiapi/capabilities/web/_views/search_request.py +93 -0
- kiapi/capabilities/web/_views/search_response.py +49 -0
- kiapi/capabilities/web/resources/__init__.py +0 -0
- kiapi/capabilities/web/resources/searxng/__init__.py +0 -0
- kiapi/capabilities/web/resources/searxng/settings.yml +11 -0
- kiapi/capabilities/zimage/README.ja.md +249 -0
- kiapi/capabilities/zimage/README.md +231 -0
- kiapi/capabilities/zimage/__init__.py +34 -0
- kiapi/capabilities/zimage/_constants/description.py +73 -0
- kiapi/capabilities/zimage/_helpers/register.py +62 -0
- kiapi/capabilities/zimage/_helpers/validate_generate.py +37 -0
- kiapi/capabilities/zimage/_models/zimage.py +278 -0
- kiapi/capabilities/zimage/_operations/handle_generate.py +38 -0
- kiapi/capabilities/zimage/_operations/handle_train.py +78 -0
- kiapi/capabilities/zimage/_operations/is_quantize_override.py +11 -0
- kiapi/capabilities/zimage/_operations/resolve_generate_params.py +39 -0
- kiapi/capabilities/zimage/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/zimage/_operations/resolve_train_params.py +38 -0
- kiapi/capabilities/zimage/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/zimage/_settings.py +166 -0
- kiapi/capabilities/zimage/_views/generate_params.py +23 -0
- kiapi/capabilities/zimage/_views/generate_request.py +127 -0
- kiapi/capabilities/zimage/_views/train_params.py +22 -0
- kiapi/capabilities/zimage/_views/train_request.py +101 -0
- kiapi/cli/__init__.py +11 -0
- kiapi/cli/_helpers/dedupe_resources.py +12 -0
- kiapi/cli/_helpers/register_all_capabilities.py +36 -0
- kiapi/cli/_helpers/run_resources.py +24 -0
- kiapi/cli/_helpers/select_specs.py +67 -0
- kiapi/cli/activate/_operations/preflight_hf_access.py +129 -0
- kiapi/cli/activate/cli.py +37 -0
- kiapi/cli/check/_helpers/check_audio_acestep_turbo.py +22 -0
- kiapi/cli/check/_helpers/check_audio_acestep_xl_base.py +22 -0
- kiapi/cli/check/_helpers/check_audio_audiogen_medium.py +24 -0
- kiapi/cli/check/_helpers/check_chat_chat_qwen3_6_27b.py +19 -0
- kiapi/cli/check/_helpers/check_chat_chat_qwen3_omni.py +19 -0
- kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_embedding_8b.py +14 -0
- kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_vl_embedding_2b.py +19 -0
- kiapi/cli/check/_helpers/check_image_depthpro_base.py +21 -0
- kiapi/cli/check/_helpers/check_image_ernie_base.py +23 -0
- kiapi/cli/check/_helpers/check_image_ernie_turbo.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_9b.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_base_4b.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_base_9b.py +23 -0
- kiapi/cli/check/_helpers/check_image_ideogram4_fp8.py +23 -0
- kiapi/cli/check/_helpers/check_image_qwen_edit_2509.py +27 -0
- kiapi/cli/check/_helpers/check_image_qwen_image.py +23 -0
- kiapi/cli/check/_helpers/check_image_seedvr2_3b.py +23 -0
- kiapi/cli/check/_helpers/check_image_seedvr2_7b.py +23 -0
- kiapi/cli/check/_helpers/check_image_zimage_base.py +23 -0
- kiapi/cli/check/_helpers/check_image_zimage_turbo.py +23 -0
- kiapi/cli/check/_helpers/check_video_ltx2_distilled.py +26 -0
- kiapi/cli/check/_helpers/check_web_web_fetch.py +14 -0
- kiapi/cli/check/_helpers/check_web_web_search.py +14 -0
- kiapi/cli/check/_operations/build_check_result.py +20 -0
- kiapi/cli/check/_operations/check_context.py +10 -0
- kiapi/cli/check/_operations/create_sample_image.py +46 -0
- kiapi/cli/check/_schemas/check_result.py +12 -0
- kiapi/cli/check/cli.py +89 -0
- kiapi/cli/cli.py +29 -0
- kiapi/cli/config/cli.py +17 -0
- kiapi/cli/config/edit/cli.py +32 -0
- kiapi/cli/config/init/cli.py +33 -0
- kiapi/cli/config/show/cli.py +13 -0
- kiapi/cli/config/template/cli.py +36 -0
- kiapi/cli/deactivate/cli.py +49 -0
- kiapi/cli/run/asgi.py +16 -0
- kiapi/cli/run/cli.py +59 -0
- kiapi/cli/service/__init__.py +5 -0
- kiapi/cli/service/_services/service_manager.py +107 -0
- kiapi/cli/service/cli.py +19 -0
- kiapi/cli/service/install/cli.py +17 -0
- kiapi/cli/service/start/cli.py +22 -0
- kiapi/cli/service/status/cli.py +81 -0
- kiapi/cli/service/stop/cli.py +19 -0
- kiapi/cli/service/uninstall/cli.py +16 -0
- kiapi/cli/status/cli.py +226 -0
- kiapi/core/app/__init__.py +16 -0
- kiapi/core/app/_schemas/app_context.py +28 -0
- kiapi/core/app/_services/user_directory.py +59 -0
- kiapi/core/app/_settings.py +46 -0
- kiapi/core/capability/__init__.py +11 -0
- kiapi/core/capability/_schemas/capability_spec.py +17 -0
- kiapi/core/capability/_services/capability_spec_registry.py +21 -0
- kiapi/core/config/__init__.py +11 -0
- kiapi/core/config/_exceptions/user_config_error.py +2 -0
- kiapi/core/config/_helpers/get_user_settings_path.py +7 -0
- kiapi/core/config/_helpers/load_user_settings.py +54 -0
- kiapi/core/file/__init__.py +37 -0
- kiapi/core/file/_helpers/create_file_store.py +7 -0
- kiapi/core/file/_helpers/resolve_file_ref.py +90 -0
- kiapi/core/file/_schemas/file_data_url_ref.py +19 -0
- kiapi/core/file/_schemas/file_id_ref.py +16 -0
- kiapi/core/file/_schemas/file_record.py +46 -0
- kiapi/core/file/_schemas/file_url_ref.py +16 -0
- kiapi/core/file/_services/file_store.py +138 -0
- kiapi/core/file/_settings.py +22 -0
- kiapi/core/file/_types/file_id.py +2 -0
- kiapi/core/file/_types/file_ref.py +12 -0
- kiapi/core/file/_views/resolved_file_ref.py +16 -0
- kiapi/core/job/__init__.py +24 -0
- kiapi/core/job/_enums/job_status.py +9 -0
- kiapi/core/job/_helpers/creep_progress.py +123 -0
- kiapi/core/job/_models/job.py +121 -0
- kiapi/core/job/_services/job_store.py +33 -0
- kiapi/core/job/_services/progress_reporter.py +79 -0
- kiapi/core/job/_types/job_id.py +3 -0
- kiapi/core/job/_types/job_result.py +5 -0
- kiapi/core/job/_types/job_type.py +4 -0
- kiapi/core/logging/__init__.py +14 -0
- kiapi/core/logging/_helpers/get_log_level.py +8 -0
- kiapi/core/logging/_helpers/setup_logger.py +14 -0
- kiapi/core/logging/_settings.py +34 -0
- kiapi/core/logging/_types/log_level.py +3 -0
- kiapi/core/memory/__init__.py +21 -0
- kiapi/core/memory/_exceptions/memory_budget_error.py +2 -0
- kiapi/core/memory/_helpers/create_memory_manager.py +17 -0
- kiapi/core/memory/_operations/log_memory_limit.py +29 -0
- kiapi/core/memory/_operations/resolve_effective_memory_limit_gb.py +13 -0
- kiapi/core/memory/_operations/resolve_framework_strategy.py +42 -0
- kiapi/core/memory/_schemas/framework_strategy.py +14 -0
- kiapi/core/memory/_schemas/memory_stats.py +24 -0
- kiapi/core/memory/_schemas/resident_model.py +14 -0
- kiapi/core/memory/_schemas/resident_model_stats.py +49 -0
- kiapi/core/memory/_services/memory_manager.py +257 -0
- kiapi/core/memory/_settings.py +36 -0
- kiapi/core/memory/_types/framework_name.py +4 -0
- kiapi/core/memory/_types/resident_key.py +4 -0
- kiapi/core/model/__init__.py +36 -0
- kiapi/core/model/_exceptions/unknown_model_error.py +2 -0
- kiapi/core/model/_schemas/model_spec.py +145 -0
- kiapi/core/model/_services/model_registry.py +85 -0
- kiapi/core/model/_types/model_alias.py +2 -0
- kiapi/core/model/_types/model_domain.py +6 -0
- kiapi/core/model/_types/model_family.py +5 -0
- kiapi/core/model/_types/model_key.py +8 -0
- kiapi/core/model/_types/model_name.py +4 -0
- kiapi/core/model/_types/model_repo.py +3 -0
- kiapi/core/net/__init__.py +16 -0
- kiapi/core/net/_exceptions/unsafe_url_error.py +7 -0
- kiapi/core/net/_helpers/verify_public_url.py +68 -0
- kiapi/core/net/_settings.py +28 -0
- kiapi/core/setup/__init__.py +25 -0
- kiapi/core/setup/_exceptions/setup_required_error.py +2 -0
- kiapi/core/setup/_schemas/docker_image_resource.py +37 -0
- kiapi/core/setup/_schemas/hf_snapshot_resource.py +50 -0
- kiapi/core/setup/_schemas/local_path_resource.py +43 -0
- kiapi/core/setup/_schemas/python_package_resource.py +58 -0
- kiapi/core/setup/_schemas/python_venv_resource.py +63 -0
- kiapi/core/setup/_schemas/setup_status.py +7 -0
- kiapi/core/setup/_schemas/url_file_resource.py +43 -0
- kiapi/core/setup/_services/setup_manager.py +331 -0
- kiapi/core/setup/_types/setup_resource.py +21 -0
- kiapi/core/setup/_types/setup_target.py +11 -0
- kiapi/core/workdir/__init__.py +8 -0
- kiapi/core/workdir/_helpers/create_work_dir.py +11 -0
- kiapi/core/workdir/_settings.py +21 -0
- kiapi/core/worker/__init__.py +23 -0
- kiapi/core/worker/_helpers/create_worker.py +9 -0
- kiapi/core/worker/_services/worker.py +165 -0
- kiapi/core/worker/_settings.py +36 -0
- kiapi/core/worker/_types/job_thunk.py +6 -0
- kiapi-0.1.0.dist-info/METADATA +337 -0
- kiapi-0.1.0.dist-info/RECORD +465 -0
- kiapi-0.1.0.dist-info/WHEEL +4 -0
- kiapi-0.1.0.dist-info/entry_points.txt +2 -0
- kiapi-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Register acestep's models + OpenAPI description in the global registries."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from kiapi.core.capability import CapabilitySpec, capability_spec_registry
|
|
6
|
+
from kiapi.core.model import ModelSpec, model_registry
|
|
7
|
+
from kiapi.core.setup import HfSnapshotResource, PythonVenvResource
|
|
8
|
+
|
|
9
|
+
from .._constants.description import DESCRIPTION
|
|
10
|
+
from .._models import acestep
|
|
11
|
+
from .._operations.resolve_ace_step_paths import resolve_ace_step_paths
|
|
12
|
+
from .._settings import settings_manager
|
|
13
|
+
|
|
14
|
+
_ACESTEP_PACKAGE = "ace-step @ git+https://github.com/ace-step/ACE-Step-1.5.git"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def register() -> None:
|
|
18
|
+
paths = resolve_ace_step_paths(settings_manager.get_settings())
|
|
19
|
+
capability_spec_registry.register(
|
|
20
|
+
CapabilitySpec(
|
|
21
|
+
name="acestep",
|
|
22
|
+
domain="audio",
|
|
23
|
+
title="kiapi ACE-Step API",
|
|
24
|
+
summary="Generate songs, covers, repaints, and stems with ACE-Step.",
|
|
25
|
+
description=DESCRIPTION,
|
|
26
|
+
openapi_path="/v1/audio/acestep/openapi.json",
|
|
27
|
+
docs_path="/v1/audio/acestep/docs",
|
|
28
|
+
redoc_path="/v1/audio/acestep/redoc",
|
|
29
|
+
path_prefixes=("/v1/audio/acestep",),
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# framework="rss" -> kiapi-RSS-based measurement (child RSS not captured, so the
|
|
34
|
+
# estimate below is what the budget uses). resident=True -> held until evicted/TTL.
|
|
35
|
+
model_registry.register(
|
|
36
|
+
ModelSpec(
|
|
37
|
+
name="xl-base",
|
|
38
|
+
family="acestep",
|
|
39
|
+
domain="audio",
|
|
40
|
+
repo="acestep-v15-xl-base",
|
|
41
|
+
module=acestep,
|
|
42
|
+
weight_gb=27.0, # est. turbo 12.2 GB + (19-4.5) DiT delta
|
|
43
|
+
peak_headroom_gb=6.0,
|
|
44
|
+
framework="rss",
|
|
45
|
+
priority=0,
|
|
46
|
+
default=True,
|
|
47
|
+
setup_resources=(
|
|
48
|
+
PythonVenvResource(
|
|
49
|
+
path=paths.venv_path,
|
|
50
|
+
python="3.12",
|
|
51
|
+
packages=(os.environ.get("KIAPI_ACESTEP_SPEC", _ACESTEP_PACKAGE),),
|
|
52
|
+
import_name="acestep",
|
|
53
|
+
label_name="acestep-venv",
|
|
54
|
+
disk_gb=1.3,
|
|
55
|
+
),
|
|
56
|
+
HfSnapshotResource(
|
|
57
|
+
repo="ACE-Step/Ace-Step1.5",
|
|
58
|
+
disk_gb=9.4,
|
|
59
|
+
local_dir=paths.checkpoint_dir,
|
|
60
|
+
),
|
|
61
|
+
HfSnapshotResource(
|
|
62
|
+
repo="ACE-Step/acestep-v15-xl-base",
|
|
63
|
+
disk_gb=19.0,
|
|
64
|
+
local_dir=f"{paths.checkpoint_dir}/acestep-v15-xl-base",
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
model_registry.register(
|
|
70
|
+
ModelSpec(
|
|
71
|
+
name="turbo",
|
|
72
|
+
family="acestep",
|
|
73
|
+
domain="audio",
|
|
74
|
+
repo="acestep-v15-turbo",
|
|
75
|
+
module=acestep,
|
|
76
|
+
weight_gb=12.0, # measured child RSS ~12.2 GB (LLM + turbo DiT)
|
|
77
|
+
peak_headroom_gb=4.0,
|
|
78
|
+
framework="rss",
|
|
79
|
+
priority=0,
|
|
80
|
+
setup_resources=(
|
|
81
|
+
PythonVenvResource(
|
|
82
|
+
path=paths.venv_path,
|
|
83
|
+
python="3.12",
|
|
84
|
+
packages=(os.environ.get("KIAPI_ACESTEP_SPEC", _ACESTEP_PACKAGE),),
|
|
85
|
+
import_name="acestep",
|
|
86
|
+
label_name="acestep-venv",
|
|
87
|
+
disk_gb=1.3,
|
|
88
|
+
),
|
|
89
|
+
HfSnapshotResource(
|
|
90
|
+
repo="ACE-Step/Ace-Step1.5",
|
|
91
|
+
disk_gb=9.4,
|
|
92
|
+
local_dir=paths.checkpoint_dir,
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Handler for ace-step presets (xl-base / turbo) via an isolated subprocess.
|
|
2
|
+
|
|
3
|
+
Each preset is a resident spec whose ``payload`` is an :class:`AceStepEngine` - a
|
|
4
|
+
long-lived ace-step worker subprocess holding the shared LLM + that preset's DiT.
|
|
5
|
+
``load`` spawns it (paying the model-load cost once), ``release`` terminates it
|
|
6
|
+
(freeing memory on eviction / TTL / shutdown), and ``generate_track`` runs one
|
|
7
|
+
generation over the protocol and stores the produced WAV in the global file
|
|
8
|
+
store. The memory manager treats the subprocess's footprint via the registry
|
|
9
|
+
``weight_gb`` estimate (a child process's RSS isn't visible in kiapi's own).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
import time
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
import psutil # type: ignore
|
|
18
|
+
|
|
19
|
+
from kiapi.core.file import FileStore
|
|
20
|
+
from kiapi.core.job import ProgressReporter
|
|
21
|
+
from kiapi.core.model import ModelSpec
|
|
22
|
+
from kiapi.core.workdir import create_work_dir
|
|
23
|
+
|
|
24
|
+
from .._operations.resolve_ace_step_paths import resolve_ace_step_paths
|
|
25
|
+
from .._services.ace_step_engine import AceStepEngine
|
|
26
|
+
from .._settings import settings_manager
|
|
27
|
+
from .._views.track_params import TrackParams
|
|
28
|
+
|
|
29
|
+
FEATURES = {"text", "audio"}
|
|
30
|
+
logger = logging.getLogger(__name__)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def load(spec: ModelSpec) -> AceStepEngine:
|
|
34
|
+
s = settings_manager.get_settings()
|
|
35
|
+
paths = resolve_ace_step_paths(s)
|
|
36
|
+
Path(paths.project_root).mkdir(parents=True, exist_ok=True)
|
|
37
|
+
engine = AceStepEngine.spawn(
|
|
38
|
+
python_path=paths.python_path,
|
|
39
|
+
preset_name=spec.name,
|
|
40
|
+
project_root=paths.project_root,
|
|
41
|
+
checkpoint_dir=paths.checkpoint_dir,
|
|
42
|
+
llm_model=s.llm_model,
|
|
43
|
+
ready_timeout_s=s.ready_timeout_s,
|
|
44
|
+
)
|
|
45
|
+
# The child's memory isn't in kiapi's RSS; log it so the registry estimate
|
|
46
|
+
# (weight_gb) can be tuned to the real footprint.
|
|
47
|
+
try:
|
|
48
|
+
rss_gb = psutil.Process(engine.proc.pid).memory_info().rss / (1024**3)
|
|
49
|
+
logger.info(
|
|
50
|
+
"%s subprocess ready - child RSS ~%.1f GB (registry estimate %.1f)",
|
|
51
|
+
spec.name,
|
|
52
|
+
rss_gb,
|
|
53
|
+
spec.weight_gb,
|
|
54
|
+
)
|
|
55
|
+
except Exception:
|
|
56
|
+
pass
|
|
57
|
+
return engine
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def release(payload: AceStepEngine) -> None:
|
|
61
|
+
payload.release()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def warmup(payload: AceStepEngine) -> None:
|
|
65
|
+
"""No-op: spawning already loaded the LLM + DiT weights. A real generation
|
|
66
|
+
would cost ~25 s, which warmup shouldn't pay."""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def generate_track(
|
|
70
|
+
payload: AceStepEngine,
|
|
71
|
+
params: TrackParams,
|
|
72
|
+
files: FileStore,
|
|
73
|
+
) -> dict[str, Any]:
|
|
74
|
+
"""Run one generation over the subprocess, store the WAV, return metadata."""
|
|
75
|
+
s = settings_manager.get_settings()
|
|
76
|
+
save_dir = create_work_dir("audio/acestep")
|
|
77
|
+
t0 = time.time()
|
|
78
|
+
engine_params = params.engine_params()
|
|
79
|
+
# generate_track runs on the single worker thread, so the job's ambient
|
|
80
|
+
# ProgressReporter is bound here; ace-step's native milestones (forwarded over
|
|
81
|
+
# the subprocess protocol) push straight onto the job (no-op when unbound).
|
|
82
|
+
reporter = ProgressReporter.current()
|
|
83
|
+
audio_path = payload.generate(
|
|
84
|
+
params.task,
|
|
85
|
+
engine_params,
|
|
86
|
+
str(save_dir),
|
|
87
|
+
timeout_s=s.job_timeout_s,
|
|
88
|
+
on_progress=reporter.update,
|
|
89
|
+
)
|
|
90
|
+
total_s = round(time.time() - t0, 2)
|
|
91
|
+
|
|
92
|
+
meta = {
|
|
93
|
+
"task": params.task,
|
|
94
|
+
"params": engine_params,
|
|
95
|
+
"timings": {"total_s": total_s},
|
|
96
|
+
**params.meta_extra(),
|
|
97
|
+
}
|
|
98
|
+
rec = files.put_path(
|
|
99
|
+
audio_path,
|
|
100
|
+
filename=Path(audio_path).name,
|
|
101
|
+
content_type="audio/wav",
|
|
102
|
+
meta=meta,
|
|
103
|
+
move=True,
|
|
104
|
+
)
|
|
105
|
+
return {"file_id": rec.file_id, "audio_bytes": rec.size, **meta}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""ACE-Step cover service entry (worker-thread thunk body)."""
|
|
2
|
+
|
|
3
|
+
from kiapi.capabilities import resolve_file_ref
|
|
4
|
+
from kiapi.core.app import AppContext
|
|
5
|
+
from kiapi.core.file import FileID
|
|
6
|
+
from kiapi.core.job import JobResult
|
|
7
|
+
|
|
8
|
+
from .._views.cover_request import CoverRequest
|
|
9
|
+
from .resolve_cover_params import resolve_cover_params
|
|
10
|
+
from .resolve_engine import resolve_engine
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def handle_cover(ctx: AppContext, req: CoverRequest) -> tuple[JobResult, list[FileID]]:
|
|
14
|
+
spec, module, engine = resolve_engine(ctx, req.model)
|
|
15
|
+
source = resolve_file_ref(ctx.file_store, req.source, kind="source")
|
|
16
|
+
params = resolve_cover_params(
|
|
17
|
+
req,
|
|
18
|
+
variant=spec.name,
|
|
19
|
+
source_file_id=source.file_id,
|
|
20
|
+
src_audio=source.path,
|
|
21
|
+
)
|
|
22
|
+
result = module.generate_track(engine, params, ctx.file_store)
|
|
23
|
+
return result, [result["file_id"]]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""ACE-Step extract service entry (worker-thread thunk body)."""
|
|
2
|
+
|
|
3
|
+
from kiapi.capabilities import resolve_file_ref
|
|
4
|
+
from kiapi.core.app import AppContext
|
|
5
|
+
from kiapi.core.file import FileID
|
|
6
|
+
from kiapi.core.job import JobResult
|
|
7
|
+
|
|
8
|
+
from .._views.extract_request import ExtractRequest
|
|
9
|
+
from .resolve_engine import resolve_engine
|
|
10
|
+
from .resolve_extract_params import resolve_extract_params
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def handle_extract(
|
|
14
|
+
ctx: AppContext, req: ExtractRequest
|
|
15
|
+
) -> tuple[JobResult, list[FileID]]:
|
|
16
|
+
spec, module, engine = resolve_engine(ctx, req.model)
|
|
17
|
+
source = resolve_file_ref(ctx.file_store, req.source, kind="source")
|
|
18
|
+
|
|
19
|
+
stems = []
|
|
20
|
+
artifacts = []
|
|
21
|
+
for target in req.targets:
|
|
22
|
+
params = resolve_extract_params(
|
|
23
|
+
req,
|
|
24
|
+
variant=spec.name,
|
|
25
|
+
source_file_id=source.file_id,
|
|
26
|
+
src_audio=source.path,
|
|
27
|
+
target=target,
|
|
28
|
+
)
|
|
29
|
+
res = module.generate_track(engine, params, ctx.file_store)
|
|
30
|
+
stems.append(res)
|
|
31
|
+
artifacts.append(res["file_id"])
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
"task": "extract",
|
|
35
|
+
"source_file_id": source.file_id,
|
|
36
|
+
"targets": req.targets,
|
|
37
|
+
"stems": stems,
|
|
38
|
+
}, artifacts
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""ACE-Step generate service entry (worker-thread thunk body)."""
|
|
2
|
+
|
|
3
|
+
from kiapi.core.app import AppContext
|
|
4
|
+
from kiapi.core.file import FileID
|
|
5
|
+
from kiapi.core.job import JobResult
|
|
6
|
+
|
|
7
|
+
from .._views.generate_request import GenerateRequest
|
|
8
|
+
from .resolve_engine import resolve_engine
|
|
9
|
+
from .resolve_generate_params import resolve_generate_params
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def handle_generate(
|
|
13
|
+
ctx: AppContext, req: GenerateRequest
|
|
14
|
+
) -> tuple[JobResult, list[FileID]]:
|
|
15
|
+
spec, module, engine = resolve_engine(ctx, req.model)
|
|
16
|
+
params = resolve_generate_params(req, variant=spec.name)
|
|
17
|
+
result = module.generate_track(engine, params, ctx.file_store)
|
|
18
|
+
return result, [result["file_id"]]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""ACE-Step repaint service entry (worker-thread thunk body)."""
|
|
2
|
+
|
|
3
|
+
from kiapi.capabilities import resolve_file_ref
|
|
4
|
+
from kiapi.core.app import AppContext
|
|
5
|
+
from kiapi.core.file import FileID
|
|
6
|
+
from kiapi.core.job import JobResult
|
|
7
|
+
|
|
8
|
+
from .._views.repaint_request import RepaintRequest
|
|
9
|
+
from .resolve_engine import resolve_engine
|
|
10
|
+
from .resolve_repaint_params import resolve_repaint_params
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def handle_repaint(
|
|
14
|
+
ctx: AppContext, req: RepaintRequest
|
|
15
|
+
) -> tuple[JobResult, list[FileID]]:
|
|
16
|
+
spec, module, engine = resolve_engine(ctx, req.model)
|
|
17
|
+
source = resolve_file_ref(ctx.file_store, req.source, kind="source")
|
|
18
|
+
params = resolve_repaint_params(
|
|
19
|
+
req,
|
|
20
|
+
variant=spec.name,
|
|
21
|
+
source_file_id=source.file_id,
|
|
22
|
+
src_audio=source.path,
|
|
23
|
+
)
|
|
24
|
+
result = module.generate_track(engine, params, ctx.file_store)
|
|
25
|
+
return result, [result["file_id"]]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from kiapi.core.app import get_user_data_dir
|
|
4
|
+
|
|
5
|
+
from .._schemas.ace_step_paths import AceStepPaths
|
|
6
|
+
from .._settings import AceStepSettings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_ace_step_paths(settings: AceStepSettings) -> AceStepPaths:
|
|
10
|
+
root = Path(get_user_data_dir()).expanduser() / "acestep"
|
|
11
|
+
python_path = (
|
|
12
|
+
Path(settings.python_path).expanduser()
|
|
13
|
+
if settings.python_path is not None
|
|
14
|
+
else root / ".venv" / "bin" / "python"
|
|
15
|
+
)
|
|
16
|
+
project_root = (
|
|
17
|
+
Path(settings.project_root).expanduser()
|
|
18
|
+
if settings.project_root is not None
|
|
19
|
+
else root / "project"
|
|
20
|
+
)
|
|
21
|
+
checkpoint_dir = (
|
|
22
|
+
Path(settings.checkpoint_dir).expanduser()
|
|
23
|
+
if settings.checkpoint_dir is not None
|
|
24
|
+
else root / "checkpoints"
|
|
25
|
+
)
|
|
26
|
+
return AceStepPaths.from_paths(
|
|
27
|
+
python_path=python_path,
|
|
28
|
+
project_root=project_root,
|
|
29
|
+
checkpoint_dir=checkpoint_dir,
|
|
30
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Merge an ACE-Step cover request into the model-layer contract."""
|
|
2
|
+
|
|
3
|
+
from .._views.cover_params import CoverParams
|
|
4
|
+
from .._views.cover_request import CoverRequest
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def resolve_cover_params(
|
|
8
|
+
req: CoverRequest, *, variant: str, source_file_id: str, src_audio: str
|
|
9
|
+
) -> CoverParams:
|
|
10
|
+
return CoverParams(
|
|
11
|
+
model=variant,
|
|
12
|
+
src=source_file_id,
|
|
13
|
+
src_audio=src_audio,
|
|
14
|
+
prompt=req.prompt,
|
|
15
|
+
strength=req.strength,
|
|
16
|
+
duration=req.duration,
|
|
17
|
+
seed=req.seed,
|
|
18
|
+
inference_steps=req.inference_steps,
|
|
19
|
+
guidance_scale=req.guidance_scale,
|
|
20
|
+
shift=req.shift,
|
|
21
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from kiapi.core.app import AppContext
|
|
4
|
+
from kiapi.core.model import ModelSpec, model_registry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def resolve_engine(ctx: AppContext, model: str) -> tuple[ModelSpec, Any, object]:
|
|
8
|
+
spec = model_registry.resolve("acestep", model)
|
|
9
|
+
ctx.ensure_model_ready(spec)
|
|
10
|
+
return spec, spec.module, ctx.memory_manager.acquire(spec)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Merge an ACE-Step extract request into one stem's model-layer contract."""
|
|
2
|
+
|
|
3
|
+
from .._views.extract_params import ExtractParams
|
|
4
|
+
from .._views.extract_request import ExtractRequest
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def resolve_extract_params(
|
|
8
|
+
req: ExtractRequest,
|
|
9
|
+
*,
|
|
10
|
+
variant: str,
|
|
11
|
+
source_file_id: str,
|
|
12
|
+
src_audio: str,
|
|
13
|
+
target: str,
|
|
14
|
+
) -> ExtractParams:
|
|
15
|
+
return ExtractParams(
|
|
16
|
+
model=variant,
|
|
17
|
+
src=source_file_id,
|
|
18
|
+
src_audio=src_audio,
|
|
19
|
+
target=target,
|
|
20
|
+
seed=req.seed,
|
|
21
|
+
inference_steps=req.inference_steps,
|
|
22
|
+
guidance_scale=req.guidance_scale,
|
|
23
|
+
shift=req.shift,
|
|
24
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Merge an ACE-Step generate request into the model-layer contract."""
|
|
2
|
+
|
|
3
|
+
from .._views.generate_params import GenerateParams
|
|
4
|
+
from .._views.generate_request import GenerateRequest
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def resolve_generate_params(req: GenerateRequest, *, variant: str) -> GenerateParams:
|
|
8
|
+
return GenerateParams(
|
|
9
|
+
model=variant,
|
|
10
|
+
prompt=req.prompt,
|
|
11
|
+
lyrics=req.lyrics,
|
|
12
|
+
duration=req.duration,
|
|
13
|
+
lang=req.lang,
|
|
14
|
+
seed=req.seed,
|
|
15
|
+
inference_steps=req.inference_steps,
|
|
16
|
+
guidance_scale=req.guidance_scale,
|
|
17
|
+
shift=req.shift,
|
|
18
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Merge an ACE-Step repaint request into the model-layer contract."""
|
|
2
|
+
|
|
3
|
+
from .._views.repaint_params import RepaintParams
|
|
4
|
+
from .._views.repaint_request import RepaintRequest
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def resolve_repaint_params(
|
|
8
|
+
req: RepaintRequest, *, variant: str, source_file_id: str, src_audio: str
|
|
9
|
+
) -> RepaintParams:
|
|
10
|
+
return RepaintParams(
|
|
11
|
+
model=variant,
|
|
12
|
+
src=source_file_id,
|
|
13
|
+
src_audio=src_audio,
|
|
14
|
+
prompt=req.prompt,
|
|
15
|
+
start=req.start,
|
|
16
|
+
end=req.end,
|
|
17
|
+
strength=req.strength,
|
|
18
|
+
seed=req.seed,
|
|
19
|
+
inference_steps=req.inference_steps,
|
|
20
|
+
guidance_scale=req.guidance_scale,
|
|
21
|
+
shift=req.shift,
|
|
22
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AceStepPaths(BaseModel):
|
|
7
|
+
"""Resolved local paths used by the ACE-Step subprocess and setup resources."""
|
|
8
|
+
|
|
9
|
+
model_config = ConfigDict(frozen=True)
|
|
10
|
+
|
|
11
|
+
python_path: str
|
|
12
|
+
venv_path: str
|
|
13
|
+
project_root: str
|
|
14
|
+
checkpoint_dir: str
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_paths(
|
|
18
|
+
cls,
|
|
19
|
+
*,
|
|
20
|
+
python_path: Path,
|
|
21
|
+
project_root: Path,
|
|
22
|
+
checkpoint_dir: Path,
|
|
23
|
+
) -> "AceStepPaths":
|
|
24
|
+
return cls(
|
|
25
|
+
python_path=str(python_path),
|
|
26
|
+
venv_path=str(python_path.parent.parent),
|
|
27
|
+
project_root=str(project_root),
|
|
28
|
+
checkpoint_dir=str(checkpoint_dir),
|
|
29
|
+
)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""kiapi-side proxy for the ace-step worker subprocess.
|
|
2
|
+
|
|
3
|
+
An :class:`AceStepEngine` owns one long-lived subprocess (launched from the
|
|
4
|
+
ace-step venv) holding the LLM + one preset's DiT resident. It is the ``payload``
|
|
5
|
+
the memory manager keeps for an ace-step spec; ``release()`` (called on eviction /
|
|
6
|
+
TTL / shutdown) terminates the subprocess and frees its memory.
|
|
7
|
+
|
|
8
|
+
Only ever used from the single worker thread (single-flight), so the simple
|
|
9
|
+
request/response over pipes needs no concurrency beyond a guard lock.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import subprocess
|
|
14
|
+
import threading
|
|
15
|
+
import time
|
|
16
|
+
from collections.abc import Callable
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
from .._exceptions.ace_step_engine_error import AceStepEngineError
|
|
20
|
+
|
|
21
|
+
SENTINEL = "@@KIAPI@@"
|
|
22
|
+
_WORKER = str(Path(__file__).parents[1] / "worker_subprocess.py")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AceStepEngine:
|
|
26
|
+
def __init__(self, proc: subprocess.Popen) -> None:
|
|
27
|
+
self.proc = proc
|
|
28
|
+
self._lock = threading.Lock()
|
|
29
|
+
self._counter = 0
|
|
30
|
+
|
|
31
|
+
# -- lifecycle ------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def spawn(
|
|
35
|
+
cls,
|
|
36
|
+
*,
|
|
37
|
+
python_path: str,
|
|
38
|
+
preset_name: str,
|
|
39
|
+
project_root: str,
|
|
40
|
+
checkpoint_dir: str,
|
|
41
|
+
llm_model: str,
|
|
42
|
+
ready_timeout_s: float,
|
|
43
|
+
) -> "AceStepEngine":
|
|
44
|
+
proc = subprocess.Popen(
|
|
45
|
+
[
|
|
46
|
+
python_path,
|
|
47
|
+
_WORKER,
|
|
48
|
+
"--preset-name",
|
|
49
|
+
preset_name,
|
|
50
|
+
"--project-root",
|
|
51
|
+
project_root,
|
|
52
|
+
"--checkpoint-dir",
|
|
53
|
+
checkpoint_dir,
|
|
54
|
+
"--llm-model",
|
|
55
|
+
llm_model,
|
|
56
|
+
],
|
|
57
|
+
stdin=subprocess.PIPE,
|
|
58
|
+
stdout=subprocess.PIPE,
|
|
59
|
+
stderr=None, # inherit: ace-step logs stream to kiapi's stderr
|
|
60
|
+
text=True,
|
|
61
|
+
bufsize=1,
|
|
62
|
+
)
|
|
63
|
+
engine = cls(proc)
|
|
64
|
+
engine._await_event("ready", timeout_s=ready_timeout_s)
|
|
65
|
+
return engine
|
|
66
|
+
|
|
67
|
+
def release(self) -> None:
|
|
68
|
+
proc = self.proc
|
|
69
|
+
if proc.poll() is None:
|
|
70
|
+
try:
|
|
71
|
+
proc.terminate()
|
|
72
|
+
proc.wait(timeout=10)
|
|
73
|
+
except Exception:
|
|
74
|
+
proc.kill()
|
|
75
|
+
for stream in (proc.stdin, proc.stdout):
|
|
76
|
+
try:
|
|
77
|
+
if stream is not None:
|
|
78
|
+
stream.close()
|
|
79
|
+
except Exception:
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
# -- protocol -------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
def _read_proto(self, timeout_s: float | None = None) -> dict:
|
|
85
|
+
"""Read the next ``@@KIAPI@@`` protocol line, skipping any other noise."""
|
|
86
|
+
deadline = (time.monotonic() + timeout_s) if timeout_s else None
|
|
87
|
+
assert self.proc.stdout is not None
|
|
88
|
+
for line in self.proc.stdout: # blocks; ace-step noise on fd1 is skipped
|
|
89
|
+
line = line.rstrip("\n")
|
|
90
|
+
if line.startswith(SENTINEL):
|
|
91
|
+
return json.loads(line[len(SENTINEL) :]) # type: ignore
|
|
92
|
+
if deadline is not None and time.monotonic() > deadline:
|
|
93
|
+
break
|
|
94
|
+
if self.proc.poll() is not None:
|
|
95
|
+
raise AceStepEngineError(
|
|
96
|
+
f"ace-step worker exited (code {self.proc.returncode}) before replying"
|
|
97
|
+
)
|
|
98
|
+
raise AceStepEngineError("ace-step worker produced no protocol output")
|
|
99
|
+
|
|
100
|
+
def _await_event(self, event: str, *, timeout_s: float) -> dict:
|
|
101
|
+
msg = self._read_proto(timeout_s=timeout_s)
|
|
102
|
+
if msg.get("event") == "error":
|
|
103
|
+
raise AceStepEngineError(msg.get("error", "worker init error"))
|
|
104
|
+
if msg.get("event") != event:
|
|
105
|
+
raise AceStepEngineError(f"expected event {event!r}, got {msg!r}")
|
|
106
|
+
return msg
|
|
107
|
+
|
|
108
|
+
def generate(
|
|
109
|
+
self,
|
|
110
|
+
task: str,
|
|
111
|
+
params: dict,
|
|
112
|
+
save_dir: str,
|
|
113
|
+
*,
|
|
114
|
+
timeout_s: float,
|
|
115
|
+
on_progress: Callable[[float, str | None], None] | None = None,
|
|
116
|
+
) -> str:
|
|
117
|
+
with self._lock:
|
|
118
|
+
self._counter += 1
|
|
119
|
+
rid = str(self._counter)
|
|
120
|
+
req = {"id": rid, "task": task, "params": params, "save_dir": save_dir}
|
|
121
|
+
if self.proc.stdin is None or self.proc.poll() is not None:
|
|
122
|
+
raise AceStepEngineError("ace-step worker is not running")
|
|
123
|
+
self.proc.stdin.write(json.dumps(req, ensure_ascii=False) + "\n")
|
|
124
|
+
self.proc.stdin.flush()
|
|
125
|
+
|
|
126
|
+
deadline = time.monotonic() + timeout_s
|
|
127
|
+
while True:
|
|
128
|
+
remaining = deadline - time.monotonic()
|
|
129
|
+
if remaining <= 0:
|
|
130
|
+
raise AceStepEngineError("ace-step worker timed out")
|
|
131
|
+
msg = self._read_proto(timeout_s=remaining)
|
|
132
|
+
|
|
133
|
+
if msg.get("event") == "progress":
|
|
134
|
+
# Forward only our own progress; ignore any stray/stale line.
|
|
135
|
+
if on_progress is not None and msg.get("id") == rid:
|
|
136
|
+
on_progress(float(msg.get("fraction", 0.0)), msg.get("label"))
|
|
137
|
+
continue
|
|
138
|
+
|
|
139
|
+
if msg.get("id") != rid:
|
|
140
|
+
raise AceStepEngineError(f"reply id mismatch: {msg!r}")
|
|
141
|
+
if not msg.get("ok"):
|
|
142
|
+
raise AceStepEngineError(msg.get("error", "generation failed"))
|
|
143
|
+
return msg["path"] # type: ignore
|