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,144 @@
|
|
|
1
|
+
"""Handler for Depth Pro image → depth map via mflux."""
|
|
2
|
+
|
|
3
|
+
import gc
|
|
4
|
+
import time
|
|
5
|
+
from types import SimpleNamespace
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
from PIL import Image
|
|
10
|
+
|
|
11
|
+
from kiapi.core.file import FileStore
|
|
12
|
+
from kiapi.core.model import ModelSpec
|
|
13
|
+
from kiapi.core.workdir import create_work_dir
|
|
14
|
+
|
|
15
|
+
from .._views.estimate_params import EstimateParams
|
|
16
|
+
|
|
17
|
+
FEATURES = {"image", "depth"}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def build_model(*, quantize: int | None) -> Any:
|
|
21
|
+
from mflux.models.depth_pro.model.depth_pro import DepthPro # type: ignore
|
|
22
|
+
|
|
23
|
+
return DepthPro(quantize=quantize)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load(spec: ModelSpec) -> SimpleNamespace:
|
|
27
|
+
from .._settings import settings_manager
|
|
28
|
+
|
|
29
|
+
quantize = settings_manager.get_settings().default_quantize
|
|
30
|
+
model = build_model(quantize=quantize)
|
|
31
|
+
return SimpleNamespace(model=model, spec=spec, quantize=quantize)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _store_depth_image(
|
|
35
|
+
result: Any,
|
|
36
|
+
*,
|
|
37
|
+
files: FileStore,
|
|
38
|
+
meta: dict[str, Any],
|
|
39
|
+
) -> dict[str, Any]:
|
|
40
|
+
pil = result.depth_image
|
|
41
|
+
tmp_dir = create_work_dir("image/depthpro")
|
|
42
|
+
out_path = tmp_dir / "depth.png"
|
|
43
|
+
pil.save(out_path, format="PNG")
|
|
44
|
+
if not out_path.exists():
|
|
45
|
+
raise RuntimeError("depth estimation finished but no depth image was produced")
|
|
46
|
+
rec = files.put_path(
|
|
47
|
+
out_path,
|
|
48
|
+
filename=f"depthpro_{int(time.time())}.png",
|
|
49
|
+
content_type="image/png",
|
|
50
|
+
meta=meta | {"kind": "depth_image"},
|
|
51
|
+
move=True,
|
|
52
|
+
)
|
|
53
|
+
return {"depth_image_file_id": rec.file_id, "depth_image_bytes": rec.size}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _store_depth_data(
|
|
57
|
+
result: Any,
|
|
58
|
+
*,
|
|
59
|
+
files: FileStore,
|
|
60
|
+
meta: dict[str, Any],
|
|
61
|
+
) -> dict[str, Any]:
|
|
62
|
+
tmp_dir = create_work_dir("image/depthpro")
|
|
63
|
+
out_path = tmp_dir / "depth.npz"
|
|
64
|
+
np.savez_compressed(
|
|
65
|
+
out_path,
|
|
66
|
+
depth=np.asarray(result.depth_array),
|
|
67
|
+
min_depth=float(result.min_depth),
|
|
68
|
+
max_depth=float(result.max_depth),
|
|
69
|
+
)
|
|
70
|
+
if not out_path.exists():
|
|
71
|
+
raise RuntimeError(
|
|
72
|
+
"depth estimation finished but no depth data file was produced"
|
|
73
|
+
)
|
|
74
|
+
rec = files.put_path(
|
|
75
|
+
out_path,
|
|
76
|
+
filename=f"depthpro_{int(time.time())}.npz",
|
|
77
|
+
content_type="application/octet-stream",
|
|
78
|
+
meta=meta | {"kind": "depth_data", "format": "npz"},
|
|
79
|
+
move=True,
|
|
80
|
+
)
|
|
81
|
+
return {"depth_data_file_id": rec.file_id, "depth_data_bytes": rec.size}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _estimate(
|
|
85
|
+
model: Any,
|
|
86
|
+
spec: ModelSpec,
|
|
87
|
+
params: EstimateParams,
|
|
88
|
+
files: FileStore,
|
|
89
|
+
) -> dict[str, Any]:
|
|
90
|
+
with Image.open(params.image_path) as src:
|
|
91
|
+
input_size = src.size
|
|
92
|
+
input_mode = src.mode
|
|
93
|
+
|
|
94
|
+
t0 = time.time()
|
|
95
|
+
result = model.create_depth_map(params.image_path)
|
|
96
|
+
total_s = round(time.time() - t0, 2)
|
|
97
|
+
|
|
98
|
+
depth_array = np.asarray(result.depth_array)
|
|
99
|
+
meta = {
|
|
100
|
+
"model": spec.name,
|
|
101
|
+
"params": params.model_dump(exclude={"image_path"}),
|
|
102
|
+
"input_width": input_size[0],
|
|
103
|
+
"input_height": input_size[1],
|
|
104
|
+
"input_mode": input_mode,
|
|
105
|
+
"width": result.depth_image.width,
|
|
106
|
+
"height": result.depth_image.height,
|
|
107
|
+
"mode": result.depth_image.mode,
|
|
108
|
+
"array_shape": list(depth_array.shape),
|
|
109
|
+
"min_depth": round(float(result.min_depth), 6),
|
|
110
|
+
"max_depth": round(float(result.max_depth), 6),
|
|
111
|
+
"timings": {"total_s": total_s},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
stored = _store_depth_image(result, files=files, meta=meta)
|
|
115
|
+
if params.include_depth_data:
|
|
116
|
+
stored |= _store_depth_data(result, files=files, meta=meta)
|
|
117
|
+
else:
|
|
118
|
+
stored["depth_data_file_id"] = None
|
|
119
|
+
stored["depth_data_bytes"] = None
|
|
120
|
+
return {**stored, **meta}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def run(
|
|
124
|
+
payload: SimpleNamespace,
|
|
125
|
+
params: EstimateParams,
|
|
126
|
+
files: FileStore,
|
|
127
|
+
) -> dict[str, Any]:
|
|
128
|
+
return _estimate(payload.model, payload.spec, params, files)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def run_transient(
|
|
132
|
+
spec: ModelSpec,
|
|
133
|
+
params: EstimateParams,
|
|
134
|
+
files: FileStore,
|
|
135
|
+
) -> dict[str, Any]:
|
|
136
|
+
model = build_model(quantize=params.quantize)
|
|
137
|
+
try:
|
|
138
|
+
return _estimate(model, spec, params, files)
|
|
139
|
+
finally:
|
|
140
|
+
del model
|
|
141
|
+
gc.collect()
|
|
142
|
+
import mlx.core as mx
|
|
143
|
+
|
|
144
|
+
mx.clear_cache()
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Depth Pro service entry: resolve input image → run resident/transient model.
|
|
2
|
+
|
|
3
|
+
Body of the depthpro job's worker-thread thunk. Stores the depth PNG (and an
|
|
4
|
+
optional NPZ of the raw depth array) in the global file store; the job's
|
|
5
|
+
``artifacts`` is the produced file_id(s).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from kiapi.capabilities import resolve_file_ref
|
|
9
|
+
from kiapi.core.app import AppContext
|
|
10
|
+
from kiapi.core.file import FileID
|
|
11
|
+
from kiapi.core.job import JobResult, creep_progress
|
|
12
|
+
from kiapi.core.model import model_registry
|
|
13
|
+
|
|
14
|
+
from .._helpers.validate_estimate import validate_estimate
|
|
15
|
+
from .._settings import settings_manager
|
|
16
|
+
from .._views.estimate_request import EstimateRequest
|
|
17
|
+
from .is_quantize_override import is_quantize_override
|
|
18
|
+
from .resolve_estimate_params import resolve_estimate_params
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def handle_estimate(
|
|
22
|
+
ctx: AppContext, req: EstimateRequest
|
|
23
|
+
) -> tuple[JobResult, list[FileID]]:
|
|
24
|
+
settings = settings_manager.get_settings()
|
|
25
|
+
spec = model_registry.resolve("depthpro", req.model)
|
|
26
|
+
ctx.ensure_model_ready(spec)
|
|
27
|
+
image = resolve_file_ref(ctx.file_store, req.image, kind="image")
|
|
28
|
+
validate_estimate(req, image_path=image.path)
|
|
29
|
+
override = is_quantize_override(settings, req)
|
|
30
|
+
params = resolve_estimate_params(
|
|
31
|
+
settings,
|
|
32
|
+
req,
|
|
33
|
+
variant=spec.name,
|
|
34
|
+
image_file_id=image.file_id,
|
|
35
|
+
image_path=image.path,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if override:
|
|
39
|
+
ctx.memory_manager.reserve(spec.weight_gb + spec.peak_headroom_gb)
|
|
40
|
+
with creep_progress(eta_s=settings.progress_eta_s):
|
|
41
|
+
result = spec.module.run_transient(spec, params, ctx.file_store)
|
|
42
|
+
else:
|
|
43
|
+
payload = ctx.memory_manager.acquire(spec)
|
|
44
|
+
with creep_progress(eta_s=settings.progress_eta_s):
|
|
45
|
+
result = spec.module.run(payload, params, ctx.file_store)
|
|
46
|
+
|
|
47
|
+
artifacts = [result["depth_image_file_id"]]
|
|
48
|
+
if result.get("depth_data_file_id") is not None:
|
|
49
|
+
artifacts.append(result["depth_data_file_id"])
|
|
50
|
+
return result, artifacts
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Decide whether a request's quantize differs from the default.
|
|
2
|
+
|
|
3
|
+
A True result means the resident model (quantized at its default) can't serve the
|
|
4
|
+
request, so ``handle_estimate`` runs a one-off transient model instead.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .._settings import DepthProSettings
|
|
8
|
+
from .._views.estimate_request import EstimateRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_quantize_override(settings: DepthProSettings, req: EstimateRequest) -> bool:
|
|
12
|
+
return req.quantize is not None and req.quantize != settings.default_quantize
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Merge an estimate request with settings defaults into the complete EstimateParams."""
|
|
2
|
+
|
|
3
|
+
from .._settings import DepthProSettings
|
|
4
|
+
from .._views.estimate_params import EstimateParams
|
|
5
|
+
from .._views.estimate_request import EstimateRequest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def resolve_estimate_params(
|
|
9
|
+
settings: DepthProSettings,
|
|
10
|
+
req: EstimateRequest,
|
|
11
|
+
*,
|
|
12
|
+
variant: str,
|
|
13
|
+
image_file_id: str,
|
|
14
|
+
image_path: str,
|
|
15
|
+
) -> EstimateParams:
|
|
16
|
+
return EstimateParams(
|
|
17
|
+
model=variant,
|
|
18
|
+
image_file_id=image_file_id,
|
|
19
|
+
image_path=image_path,
|
|
20
|
+
quantize=req.quantize
|
|
21
|
+
if req.quantize is not None
|
|
22
|
+
else settings.default_quantize,
|
|
23
|
+
include_depth_data=req.include_depth_data,
|
|
24
|
+
)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Depth Pro capability defaults + caps, read from ``KIAPI_DEPTHPRO_`` env vars."""
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
5
|
+
from pydantic_settings_manager import SettingsManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DepthProSettings(BaseSettings):
|
|
9
|
+
"""Settings for Depth Pro quantization, input image limits, and progress display."""
|
|
10
|
+
|
|
11
|
+
model_config = SettingsConfigDict(
|
|
12
|
+
env_prefix="KIAPI_DEPTHPRO_",
|
|
13
|
+
extra="ignore",
|
|
14
|
+
protected_namespaces=(),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
default_quantize: int | None = Field(
|
|
18
|
+
default=8,
|
|
19
|
+
title="Default quantization bits",
|
|
20
|
+
description=(
|
|
21
|
+
"Default quantization bit count used when loading the Depth Pro model.\n"
|
|
22
|
+
"Use a bit count such as 8, or None to disable quantization."
|
|
23
|
+
),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
max_input_pixels: int = Field(
|
|
27
|
+
default=4096 * 4096,
|
|
28
|
+
title="Maximum input pixels",
|
|
29
|
+
description=(
|
|
30
|
+
"Maximum total pixel count for an input image passed to Depth Pro.\n"
|
|
31
|
+
"This protects the single worker queue from being blocked for a long "
|
|
32
|
+
"time by very large images."
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
progress_eta_s: float = Field(
|
|
37
|
+
default=8.0,
|
|
38
|
+
title="Progress ETA seconds",
|
|
39
|
+
description=(
|
|
40
|
+
"Expected processing seconds used to show synthetic progress while Depth Pro runs.\n"
|
|
41
|
+
"Set to 0 to keep progress at the coarse value until completion."
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
settings_manager = SettingsManager(DepthProSettings)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""The complete contract for one Depth Pro image → depth map run.
|
|
2
|
+
|
|
3
|
+
Built from settings + request by ``resolve_estimate_params``; the model needs
|
|
4
|
+
nothing else to produce the depth map and its metadata. ``image_path`` is the
|
|
5
|
+
locally resolved input file, kept out of the recorded metadata in favour of
|
|
6
|
+
``image_file_id``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class EstimateParams(BaseModel):
|
|
15
|
+
kind: Literal["estimate"] = "estimate"
|
|
16
|
+
model: str
|
|
17
|
+
|
|
18
|
+
image_file_id: str
|
|
19
|
+
image_path: str
|
|
20
|
+
quantize: int | None
|
|
21
|
+
include_depth_data: bool
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Depth Pro request model.
|
|
2
|
+
|
|
3
|
+
Image → depth map (Depth Pro). One endpoint serves both sync and async via
|
|
4
|
+
``mode``. The input image is referenced by ``image`` (FileRef). A ``quantize``
|
|
5
|
+
override runs a one-off transient model; otherwise the resident model is used.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Literal
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
11
|
+
|
|
12
|
+
from kiapi.core.file import FileRef
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class EstimateRequest(BaseModel):
|
|
16
|
+
model_config = ConfigDict(extra="allow")
|
|
17
|
+
|
|
18
|
+
model: str | None = Field(
|
|
19
|
+
default=None,
|
|
20
|
+
description=(
|
|
21
|
+
"Model variant (see GET /v1/image/depthpro/models). Omit for the "
|
|
22
|
+
"default `base`. Aliases `depthpro`, `depth-pro`, `DepthPro` are accepted."
|
|
23
|
+
),
|
|
24
|
+
)
|
|
25
|
+
mode: Literal["sync", "async"] = Field(
|
|
26
|
+
default="sync",
|
|
27
|
+
description=(
|
|
28
|
+
"`sync` waits for the depth map (504 on timeout); `async` returns 202 "
|
|
29
|
+
"with a job_id immediately — poll GET /v1/jobs/{job_id}."
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
image: FileRef = Field(
|
|
34
|
+
description=(
|
|
35
|
+
"Input image to estimate depth for, as a Files-API file id, http(s) "
|
|
36
|
+
"URL, or data URL. Must not exceed the configured input pixel cap."
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
quantize: int | None = Field(
|
|
40
|
+
default=None,
|
|
41
|
+
description=(
|
|
42
|
+
"Quantization bits, one of {3, 4, 5, 6, 8}. Omit to use the server "
|
|
43
|
+
"default (8). A value differing from the resident model's quantization "
|
|
44
|
+
"runs a one-off transient model (no resident reuse), so it is slower."
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
include_depth_data: bool = Field(
|
|
49
|
+
default=True,
|
|
50
|
+
description=(
|
|
51
|
+
"When true, also store a compressed NPZ with the raw float depth array "
|
|
52
|
+
"and min/max depth (`depth_data_file_id`) alongside the grayscale PNG. "
|
|
53
|
+
"When false, only the PNG is produced, so a sync call can return the raw "
|
|
54
|
+
"PNG bytes directly (single artifact, unless Accept: application/json)."
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def gen_params(self) -> dict:
|
|
59
|
+
return {
|
|
60
|
+
"image": self.image.model_dump(mode="json"),
|
|
61
|
+
"quantize": self.quantize,
|
|
62
|
+
"include_depth_data": self.include_depth_data,
|
|
63
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# embedding
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **日本語**
|
|
4
|
+
|
|
5
|
+
[mlx-embeddings](https://github.com/Blaizzy/mlx-embeddings) で、テキスト / 画像の埋め込み API を提供します。
|
|
6
|
+
|
|
7
|
+
- **text embedding**:
|
|
8
|
+
- Qwen3-Embedding-8B
|
|
9
|
+
- **multimodal embedding**:
|
|
10
|
+
- Qwen3-VL-Embedding-2B
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
| Endpoint | Name | Description |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `POST /v1/embedding` | 埋め込み | 1 アイテムをベクトル化。レスポンスは `{ model, embedding, dimension, usage, timings }`。 |
|
|
17
|
+
| `GET /v1/embedding/models` | モデル一覧 | 利用可能なモデルの一覧を返す。 |
|
|
18
|
+
| `GET /v1/embedding/openapi.json` | OpenAPI | 詳細な入出力仕様、使い方、TIPS を返す。 |
|
|
19
|
+
|
|
20
|
+
## API Docs
|
|
21
|
+
|
|
22
|
+
- [OpenAPI JSON](https://kiarina.github.io/kiapi/v1/embedding/openapi.json)
|
|
23
|
+
- [Swagger UI](https://kiarina.github.io/kiapi/v1/embedding/docs.html)
|
|
24
|
+
- [ReDoc](https://kiarina.github.io/kiapi/v1/embedding/redoc.html)
|
|
25
|
+
|
|
26
|
+
## Dependencies
|
|
27
|
+
|
|
28
|
+
| Package | License | Description |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| [mlx-embeddings](https://github.com/Blaizzy/mlx-embeddings) | MIT | Qwen3 / Qwen3-VL 埋め込みモデルを MLX 上で駆動。 |
|
|
31
|
+
|
|
32
|
+
## Models
|
|
33
|
+
|
|
34
|
+
| Model | License | Terms | Size | Description |
|
|
35
|
+
|---|---|---|---:|---|
|
|
36
|
+
| [mlx-community/Qwen3-Embedding-8B-mxfp8](https://huggingface.co/mlx-community/Qwen3-Embedding-8B-mxfp8) | Apache-2.0 | 不要 | 7.82 GB | `qwen3-embedding-8b`(デフォルト)。text 専用、4096 次元。alias: `text`, `qwen3-embedding`, `qwen3_embedding`。 |
|
|
37
|
+
| [mlx-community/Qwen3-VL-Embedding-2B-mxfp8](https://huggingface.co/mlx-community/Qwen3-VL-Embedding-2B-mxfp8) | Apache-2.0 | 不要 | 2.59 GB | `qwen3-vl-embedding-2b`。text + image、2048 次元。alias: `vl`, `qwen3-vl-embedding`, `qwen3_vl_embedding`。 |
|
|
38
|
+
|
|
39
|
+
- 選択したモデルが対応しないモダリティを送ると **HTTP 400**。
|
|
40
|
+
例: `qwen3-embedding-8b` に `image` を送るとエラー。
|
|
41
|
+
- VL モデルでは `text` と `image` を同時に送ると、1 つの結合アイテムとして
|
|
42
|
+
埋め込みます。
|
|
43
|
+
|
|
44
|
+
## Notes
|
|
45
|
+
|
|
46
|
+
- **レスポンス形式**:
|
|
47
|
+
`embedding` は float 配列、`dimension` はその長さです。
|
|
48
|
+
`usage` は `prompt_tokens` / `total_tokens` を返します。
|
|
49
|
+
現在、モデル実行経路によっては token 数は `0` のままです。
|
|
50
|
+
- **出力ベクトル**:
|
|
51
|
+
`mlx-embeddings` の出力を `_utils/to_vector.py` で Python の `list[float]` に変換します。
|
|
52
|
+
ヘルプでは L2 正規化・last-token pooling のベクトルとして扱います。
|
|
53
|
+
- **入力形式**:
|
|
54
|
+
`text` は文字列をそのまま渡します。
|
|
55
|
+
`image` は base64、data URL、http(s) URL を受け付け、
|
|
56
|
+
VL モデル実行前に一時ファイルへ materialize します。
|
|
57
|
+
- **max_length**:
|
|
58
|
+
tokenizer へ渡す最大長は `KIAPI_EMBEDDING_MAX_LENGTH` で設定します。
|
|
59
|
+
既定値は `512` です。
|
|
60
|
+
- **2 つの埋め込み経路**:
|
|
61
|
+
text モデルは `mlx_embeddings.generate(...)`、
|
|
62
|
+
VL モデルは `model.process([item], processor=...)` を使います。
|
|
63
|
+
同じ依存ライブラリ内でも経路が違うため、`mlx-embeddings` を更新したときは両方を検証してください。
|
|
64
|
+
- **VL processor の補正**:
|
|
65
|
+
MLX 変換版 Qwen3-VL processor は `chat_template` や image/video token-id 属性を欠くことがあります。
|
|
66
|
+
`_models/qwen3_vl.py` の `_patch_processor` が best-effort で補います。
|
|
67
|
+
依存更新時はこの補正がまだ必要か確認してください。
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
### text - デフォルトモデル
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
jq -n \
|
|
75
|
+
'{
|
|
76
|
+
text: "今日はいい天気ですね"
|
|
77
|
+
}' |
|
|
78
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
79
|
+
-H 'Content-Type: application/json' \
|
|
80
|
+
--data-binary @- |
|
|
81
|
+
jq '{model, dimension, head: .embedding[0:5], timings}'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### text - VL モデル
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
jq -n \
|
|
88
|
+
'{
|
|
89
|
+
model: "vl",
|
|
90
|
+
text: "a photo of a cat"
|
|
91
|
+
}' |
|
|
92
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
93
|
+
-H 'Content-Type: application/json' \
|
|
94
|
+
--data-binary @- |
|
|
95
|
+
jq '{model, dimension, timings}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### image - VL モデル
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
IMG=$(base64 -i your_image.png)
|
|
102
|
+
|
|
103
|
+
jq -n \
|
|
104
|
+
--arg image "$IMG" \
|
|
105
|
+
'{
|
|
106
|
+
model: "vl",
|
|
107
|
+
image: $image
|
|
108
|
+
}' |
|
|
109
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
110
|
+
-H 'Content-Type: application/json' \
|
|
111
|
+
--data-binary @- |
|
|
112
|
+
jq '{model, dimension, timings}'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### text + image - VL モデル
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
IMG=$(base64 -i your_image.png)
|
|
119
|
+
|
|
120
|
+
jq -n \
|
|
121
|
+
--arg image "$IMG" \
|
|
122
|
+
'{
|
|
123
|
+
model: "vl",
|
|
124
|
+
text: "a photo of a cat",
|
|
125
|
+
image: $image
|
|
126
|
+
}' |
|
|
127
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
128
|
+
-H 'Content-Type: application/json' \
|
|
129
|
+
--data-binary @- |
|
|
130
|
+
jq '{model, dimension, timings}'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### モデル一覧
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding/models | jq .
|
|
137
|
+
```
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# embedding
|
|
2
|
+
|
|
3
|
+
**English** | [日本語](README.ja.md)
|
|
4
|
+
|
|
5
|
+
[mlx-embeddings](https://github.com/Blaizzy/mlx-embeddings) provides a text/image embedding API.
|
|
6
|
+
|
|
7
|
+
- **text embedding**:
|
|
8
|
+
- Qwen3-Embedding-8B
|
|
9
|
+
- **multimodal embedding**:
|
|
10
|
+
- Qwen3-VL-Embedding-2B
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
| Endpoint | Name | Description |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `POST /v1/embedding` | Embed | 1 Vectorize item. The response is `{ model, embedding, dimension, usage, timings }`. |
|
|
17
|
+
| `GET /v1/embedding/models` | Model list | Returns a list of available models. |
|
|
18
|
+
| `GET /v1/embedding/openapi.json` | OpenAPI | Returns detailed input/output specifications, usage, and TIPS. |
|
|
19
|
+
|
|
20
|
+
## API Docs
|
|
21
|
+
|
|
22
|
+
- [OpenAPI JSON](https://kiarina.github.io/kiapi/v1/embedding/openapi.json)
|
|
23
|
+
- [Swagger UI](https://kiarina.github.io/kiapi/v1/embedding/docs.html)
|
|
24
|
+
- [ReDoc](https://kiarina.github.io/kiapi/v1/embedding/redoc.html)
|
|
25
|
+
|
|
26
|
+
## Dependencies
|
|
27
|
+
|
|
28
|
+
| Package | License | Description |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| [mlx-embeddings](https://github.com/Blaizzy/mlx-embeddings) | MIT | Drive Qwen3 / Qwen3-VL embedding models on MLX. |
|
|
31
|
+
|
|
32
|
+
## Models
|
|
33
|
+
|
|
34
|
+
| Model | License | Terms | Size | Description |
|
|
35
|
+
|---|---|---|---:|---|
|
|
36
|
+
| [mlx-community/Qwen3-Embedding-8B-mxfp8](https://huggingface.co/mlx-community/Qwen3-Embedding-8B-mxfp8) | Apache-2.0 | Not required | 7.82 GB | `qwen3-embedding-8b` (default). text only, 4096 dimensions. alias: `text`, `qwen3-embedding`, `qwen3_embedding`. |
|
|
37
|
+
| [mlx-community/Qwen3-VL-Embedding-2B-mxfp8](https://huggingface.co/mlx-community/Qwen3-VL-Embedding-2B-mxfp8) | Apache-2.0 | Not required | 2.59 GB | `qwen3-vl-embedding-2b`. text + image, 2048 dimensions. alias: `vl`, `qwen3-vl-embedding`, `qwen3_vl_embedding`. |
|
|
38
|
+
|
|
39
|
+
- **HTTP 400** when sending a modality that is not supported by the selected model.
|
|
40
|
+
Example: Error when sending `image` to `qwen3-embedding-8b`.
|
|
41
|
+
- In the VL model, if you send `text` and `image` at the same time, they will be sent as one combined item.
|
|
42
|
+
Embed.
|
|
43
|
+
|
|
44
|
+
## Notes
|
|
45
|
+
|
|
46
|
+
- **Response format**:
|
|
47
|
+
`embedding` is a float array and `dimension` is its length.
|
|
48
|
+
`usage` returns `prompt_tokens` / `total_tokens`.
|
|
49
|
+
Currently, the number of tokens remains `0` depending on the model execution path.
|
|
50
|
+
- **Output Vector**:
|
|
51
|
+
Convert the output of `mlx-embeddings` to a Python `list[float]` with `_utils/to_vector.py`.
|
|
52
|
+
In the help, it is treated as a vector for L2 normalization and last-token pooling.
|
|
53
|
+
- **Input format**:
|
|
54
|
+
`text` passes the string as is.
|
|
55
|
+
`image` accepts base64, data URLs, http(s) URLs,
|
|
56
|
+
Materialize to a temporary file before running the VL model.
|
|
57
|
+
- **max_length**:
|
|
58
|
+
The maximum length passed to the tokenizer is set with `KIAPI_EMBEDDING_MAX_LENGTH`.
|
|
59
|
+
Default value is `512`.
|
|
60
|
+
- **Two embedded paths**:
|
|
61
|
+
The text model is `mlx_embeddings.generate(...)`,
|
|
62
|
+
VL models use `model.process([item], processor=...)`.
|
|
63
|
+
The paths are different even within the same dependent library, so please verify both when updating `mlx-embeddings`.
|
|
64
|
+
- **VL processor correction**:
|
|
65
|
+
MLX converted Qwen3-VL processors may lack `chat_template` and image/video token-id attributes.
|
|
66
|
+
`_patch_processor` in `_models/qwen3_vl.py` compensates with best-effort.
|
|
67
|
+
When updating dependencies, please check whether this correction is still required.
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
### text - default model
|
|
72
|
+
```bash
|
|
73
|
+
jq -n \
|
|
74
|
+
'{
|
|
75
|
+
text: "今日はいい天気ですね"
|
|
76
|
+
}' |
|
|
77
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
78
|
+
-H 'Content-Type: application/json' \
|
|
79
|
+
--data-binary @- |
|
|
80
|
+
jq '{model, dimension, head: .embedding[0:5], timings}'
|
|
81
|
+
```
|
|
82
|
+
### text - VL model
|
|
83
|
+
```bash
|
|
84
|
+
jq -n \
|
|
85
|
+
'{
|
|
86
|
+
model: "vl",
|
|
87
|
+
text: "a photo of a cat"
|
|
88
|
+
}' |
|
|
89
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
90
|
+
-H 'Content-Type: application/json' \
|
|
91
|
+
--data-binary @- |
|
|
92
|
+
jq '{model, dimension, timings}'
|
|
93
|
+
```
|
|
94
|
+
### image - VL model
|
|
95
|
+
```bash
|
|
96
|
+
IMG=$(base64 -i your_image.png)
|
|
97
|
+
|
|
98
|
+
jq -n \
|
|
99
|
+
--arg image "$IMG" \
|
|
100
|
+
'{
|
|
101
|
+
model: "vl",
|
|
102
|
+
image: $image
|
|
103
|
+
}' |
|
|
104
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
105
|
+
-H 'Content-Type: application/json' \
|
|
106
|
+
--data-binary @- |
|
|
107
|
+
jq '{model, dimension, timings}'
|
|
108
|
+
```
|
|
109
|
+
### text + image - VL model
|
|
110
|
+
```bash
|
|
111
|
+
IMG=$(base64 -i your_image.png)
|
|
112
|
+
|
|
113
|
+
jq -n \
|
|
114
|
+
--arg image "$IMG" \
|
|
115
|
+
'{
|
|
116
|
+
model: "vl",
|
|
117
|
+
text: "a photo of a cat",
|
|
118
|
+
image: $image
|
|
119
|
+
}' |
|
|
120
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding \
|
|
121
|
+
-H 'Content-Type: application/json' \
|
|
122
|
+
--data-binary @- |
|
|
123
|
+
jq '{model, dimension, timings}'
|
|
124
|
+
```
|
|
125
|
+
### Model list
|
|
126
|
+
```bash
|
|
127
|
+
curl -sS http://localhost:${PORT:-8000}/v1/embedding/models | jq .
|
|
128
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Embedding capability — multi-model text/image embeddings via mlx-embeddings.
|
|
2
|
+
|
|
3
|
+
Integrates mlx-embedding-server: served from the shared single-flight worker
|
|
4
|
+
under the global memory budget. The `model` field selects which model answers;
|
|
5
|
+
one item per request with one field per modality. Sync only.
|
|
6
|
+
|
|
7
|
+
These are small models that agents call frequently, so they get a positive
|
|
8
|
+
``priority`` (higher = kept longer): they survive eviction churn from big chat /
|
|
9
|
+
generation models, which is exactly the intended use of priority.
|
|
10
|
+
``weight_gb`` / ``peak_headroom_gb`` are seeded from the original server's
|
|
11
|
+
estimates and reconciled with on-device measurement at load.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from ._helpers.register import register
|
|
15
|
+
from ._operations.handle_embed import handle_embed
|
|
16
|
+
from ._settings import settings_manager
|
|
17
|
+
from ._views.embed_request import EmbedRequest
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"EmbedRequest", # ._views
|
|
21
|
+
"handle_embed", # ._operations
|
|
22
|
+
"register", # ._helpers
|
|
23
|
+
"settings_manager", # ._settings
|
|
24
|
+
]
|