model-compose 0.2.8__tar.gz → 0.2.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {model_compose-0.2.8/src/model_compose.egg-info → model_compose-0.2.10}/PKG-INFO +3 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/pyproject.toml +4 -2
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/__init__.py +1 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/http_server.py +8 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/mcp_client.py +1 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/mcp_server.py +9 -1
- model_compose-0.2.10/src/mindor/core/component/services/model/__init__.py +1 -0
- model_compose-0.2.10/src/mindor/core/component/services/model/base.py +28 -0
- model_compose-0.2.10/src/mindor/core/component/services/model/model.py +37 -0
- model_compose-0.2.10/src/mindor/core/component/services/model/tasks/__init__.py +2 -0
- model_compose-0.2.10/src/mindor/core/component/services/model/tasks/text_embedding.py +83 -0
- model_compose-0.2.10/src/mindor/core/component/services/model/tasks/text_generation.py +63 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/webui/gradio.py +2 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/webui/webui.py +1 -2
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/services/console.py +2 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/time.py +10 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/impl/action.py +3 -3
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/impl/delay.py +5 -7
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/workflow.py +8 -5
- model_compose-0.2.10/src/mindor/dsl/schema/action/action.py +13 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/__init__.py +1 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/mcp_server.py +1 -2
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/__init__.py +1 -0
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/impl/__init__.py +3 -0
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/impl/common.py +11 -0
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/impl/text_embedding.py +14 -0
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/impl/text_generation.py +15 -0
- model_compose-0.2.10/src/mindor/dsl/schema/action/impl/model/model.py +8 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/component.py +1 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/__init__.py +1 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/__init__.py +1 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/impl/__init__.py +3 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/impl/common.py +23 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/impl/text_embedding.py +7 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/impl/text_generation.py +7 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/impl/types.py +5 -0
- model_compose-0.2.10/src/mindor/dsl/schema/component/impl/model/model.py +11 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/types.py +1 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/workflow.py +1 -1
- {model_compose-0.2.8 → model_compose-0.2.10/src/model_compose.egg-info}/PKG-INFO +3 -1
- {model_compose-0.2.8 → model_compose-0.2.10}/src/model_compose.egg-info/SOURCES.txt +21 -2
- {model_compose-0.2.8 → model_compose-0.2.10}/src/model_compose.egg-info/requires.txt +2 -0
- model_compose-0.2.8/src/mindor/dsl/schema/action/action.py +0 -15
- {model_compose-0.2.8 → model_compose-0.2.10}/LICENSE +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/README.md +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/setup.cfg +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/cli/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/cli/compose.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/component.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/context.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/http_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/shell.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/workflow.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/compose/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/compose/compose.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/compose/manager.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/controller.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/runner/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/runner/client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/runner/http_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/runner/mcp_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/runner/runner.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/services/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/services/http_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/services/mcp_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/controller/webui/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/gateway.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/services/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/services/http_tunnel.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/gateway/services/ssh_tunnel.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/listener/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/listener/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/listener/listener.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/listener/services/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/listener/services/http_callback.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/logger.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/logging.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/services/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/logger/services/file.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/runtime/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/runtime/env.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/services/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/services/async_service.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/expiring.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/http_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/http_request.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/http_status.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/image.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/mcp_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/renderer.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/ssh_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/streaming.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/utils/workqueue.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/context.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/base.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/job/job.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/workflow/schema.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/loader.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/http_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/http_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/mcp_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/shell.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/action/impl/workflow.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/http_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/http_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/mcp_client.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/mcp_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/shell.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/component/impl/workflow.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/compose.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/controller.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/http_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/mcp_server.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/controller/impl/webui.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/gateway.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/impl/http_tunnel.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/impl/ssh_tunnel.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/gateway/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/impl/action.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/impl/delay.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/job/job.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/impl/http_callback.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/listener/listener.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/impl/console.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/impl/file.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/logger/logger.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/impl/__init__.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/impl/common.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/impl/docker.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/impl/types.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/dsl/schema/runtime/runtime.py +0 -0
- {model_compose-0.2.8/src/mindor/dsl/schema → model_compose-0.2.10/src/mindor/dsl}/utils/__init__.py +0 -0
- {model_compose-0.2.8/src/mindor/dsl/schema → model_compose-0.2.10/src/mindor/dsl}/utils/annotation.py +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/model_compose.egg-info/dependency_links.txt +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/model_compose.egg-info/entry_points.txt +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/src/model_compose.egg-info/top_level.txt +0 -0
- {model_compose-0.2.8 → model_compose-0.2.10}/tests/test_cli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model-compose
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: model-compose: Declarative AI Model and Workflow Orchestrator
|
|
5
5
|
Author-email: Hanyeol Cho <hanyeol.cho@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,6 +20,8 @@ Requires-Dist: pyngrok
|
|
|
20
20
|
Requires-Dist: ulid
|
|
21
21
|
Requires-Dist: gradio
|
|
22
22
|
Requires-Dist: Pillow
|
|
23
|
+
Requires-Dist: transformers
|
|
24
|
+
Requires-Dist: torch
|
|
23
25
|
Dynamic: license-file
|
|
24
26
|
|
|
25
27
|
# model-compose: Declarative AI Model and Workflow Orchestrator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "model-compose"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.10"
|
|
4
4
|
description = "model-compose: Declarative AI Model and Workflow Orchestrator"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Hanyeol Cho", email = "hanyeol.cho@gmail.com" }
|
|
@@ -20,7 +20,9 @@ dependencies = [
|
|
|
20
20
|
"pyngrok",
|
|
21
21
|
"ulid",
|
|
22
22
|
"gradio",
|
|
23
|
-
"Pillow"
|
|
23
|
+
"Pillow",
|
|
24
|
+
"transformers",
|
|
25
|
+
"torch"
|
|
24
26
|
]
|
|
25
27
|
|
|
26
28
|
[project.scripts]
|
{model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/http_server.py
RENAMED
|
@@ -4,6 +4,13 @@ from mindor.dsl.schema.action import ActionConfig, HttpServerActionConfig
|
|
|
4
4
|
from ..base import ComponentService, ComponentType, ComponentGlobalConfigs, register_component
|
|
5
5
|
from ..context import ComponentActionContext
|
|
6
6
|
|
|
7
|
+
class HttpServerAction:
|
|
8
|
+
def __init__(self, config: HttpServerActionConfig):
|
|
9
|
+
self.config: HttpServerActionConfig = config
|
|
10
|
+
|
|
11
|
+
async def run(self, context: ComponentActionContext) -> Any:
|
|
12
|
+
pass
|
|
13
|
+
|
|
7
14
|
@register_component(ComponentType.HTTP_SERVER)
|
|
8
15
|
class HttpServerComponent(ComponentService):
|
|
9
16
|
def __init__(self, id: str, config: HttpServerComponentConfig, global_configs: ComponentGlobalConfigs, daemon: bool):
|
|
@@ -16,4 +23,4 @@ class HttpServerComponent(ComponentService):
|
|
|
16
23
|
pass
|
|
17
24
|
|
|
18
25
|
async def _run(self, action: ActionConfig, context: ComponentActionContext) -> Any:
|
|
19
|
-
return
|
|
26
|
+
return await HttpServerAction(action).run(context)
|
{model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/mcp_client.py
RENAMED
|
@@ -5,7 +5,7 @@ from mindor.core.utils.mcp_client import McpClient, ContentBlock, TextContent, I
|
|
|
5
5
|
from ..base import ComponentService, ComponentType, ComponentGlobalConfigs, register_component
|
|
6
6
|
from ..context import ComponentActionContext
|
|
7
7
|
|
|
8
|
-
class McpClientAction
|
|
8
|
+
class McpClientAction:
|
|
9
9
|
def __init__(self, config: McpClientActionConfig):
|
|
10
10
|
self.config: McpClientActionConfig = config
|
|
11
11
|
|
{model_compose-0.2.8 → model_compose-0.2.10}/src/mindor/core/component/services/mcp_server.py
RENAMED
|
@@ -4,6 +4,13 @@ from mindor.dsl.schema.action import ActionConfig, McpServerActionConfig
|
|
|
4
4
|
from ..base import ComponentService, ComponentType, ComponentGlobalConfigs, register_component
|
|
5
5
|
from ..context import ComponentActionContext
|
|
6
6
|
|
|
7
|
+
class McpServerAction:
|
|
8
|
+
def __init__(self, config: McpServerActionConfig):
|
|
9
|
+
self.config: McpServerActionConfig = config
|
|
10
|
+
|
|
11
|
+
async def run(self, context: ComponentActionContext) -> Any:
|
|
12
|
+
pass
|
|
13
|
+
|
|
7
14
|
@register_component(ComponentType.MCP_SERVER)
|
|
8
15
|
class McpServerComponent(ComponentService):
|
|
9
16
|
def __init__(self, id: str, config: McpServerComponentConfig, global_configs: ComponentGlobalConfigs, daemon: bool):
|
|
@@ -16,4 +23,5 @@ class McpServerComponent(ComponentService):
|
|
|
16
23
|
pass
|
|
17
24
|
|
|
18
25
|
async def _run(self, action: ActionConfig, context: ComponentActionContext) -> Any:
|
|
19
|
-
return
|
|
26
|
+
return await McpServerAction(action).run(context)
|
|
27
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .model import *
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Callable, Any
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from mindor.dsl.schema.component import ModelComponentConfig, ModelTaskType
|
|
4
|
+
from mindor.dsl.schema.action import ModelActionConfig
|
|
5
|
+
from mindor.core.services import AsyncService
|
|
6
|
+
from ...context import ComponentActionContext
|
|
7
|
+
|
|
8
|
+
class ModelTaskService(AsyncService):
|
|
9
|
+
def __init__(self, id: str, config: ModelComponentConfig, daemon: bool):
|
|
10
|
+
super().__init__(daemon)
|
|
11
|
+
|
|
12
|
+
self.id: str = id
|
|
13
|
+
self.config: ModelComponentConfig = config
|
|
14
|
+
|
|
15
|
+
async def run(self, action: ModelActionConfig, context: ComponentActionContext) -> Any:
|
|
16
|
+
return await self._run(action, context)
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
async def _run(self, action: ModelActionConfig, context: ComponentActionContext) -> Any:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
def register_model_task_service(type: ModelTaskType):
|
|
23
|
+
def decorator(cls: Type[ModelTaskService]) -> Type[ModelTaskService]:
|
|
24
|
+
ModelTaskServiceRegistry[type] = cls
|
|
25
|
+
return cls
|
|
26
|
+
return decorator
|
|
27
|
+
|
|
28
|
+
ModelTaskServiceRegistry: Dict[ModelTaskType, Type[ModelTaskService]] = {}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, AsyncIterator, Any
|
|
2
|
+
from mindor.dsl.schema.component import ModelComponentConfig, ModelTaskType
|
|
3
|
+
from mindor.dsl.schema.action import ActionConfig, ModelActionConfig
|
|
4
|
+
from ...base import ComponentService, ComponentType, ComponentGlobalConfigs, register_component
|
|
5
|
+
from ...context import ComponentActionContext
|
|
6
|
+
from .base import ModelTaskService, ModelTaskServiceRegistry
|
|
7
|
+
|
|
8
|
+
class ModelAction:
|
|
9
|
+
def __init__(self, config: ModelActionConfig):
|
|
10
|
+
self.config: ModelActionConfig = config
|
|
11
|
+
|
|
12
|
+
async def run(self, context: ComponentActionContext, task_service: ModelTaskService) -> Any:
|
|
13
|
+
return await task_service.run(self.config, context)
|
|
14
|
+
|
|
15
|
+
@register_component(ComponentType.MODEL)
|
|
16
|
+
class ModelComponent(ComponentService):
|
|
17
|
+
def __init__(self, id: str, config: ModelComponentConfig, global_configs: ComponentGlobalConfigs, daemon: bool):
|
|
18
|
+
super().__init__(id, config, global_configs, daemon)
|
|
19
|
+
|
|
20
|
+
self.task_service = self._create_task_service(self.config.task)
|
|
21
|
+
|
|
22
|
+
def _create_task_service(self, type: ModelTaskType) -> ModelTaskService:
|
|
23
|
+
try:
|
|
24
|
+
if not ModelTaskServiceRegistry:
|
|
25
|
+
from . import tasks
|
|
26
|
+
return ModelTaskServiceRegistry[type](self.id, self.config, self.daemon)
|
|
27
|
+
except KeyError:
|
|
28
|
+
raise ValueError(f"Unsupported component type: {type}")
|
|
29
|
+
|
|
30
|
+
async def _serve(self) -> None:
|
|
31
|
+
await self.task_service.start()
|
|
32
|
+
|
|
33
|
+
async def _shutdown(self) -> None:
|
|
34
|
+
await self.task_service.stop()
|
|
35
|
+
|
|
36
|
+
async def _run(self, action: ActionConfig, context: ComponentActionContext) -> Any:
|
|
37
|
+
return await ModelAction(action).run(context, self.task_service)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from mindor.dsl.schema.component import ModelComponentConfig
|
|
3
|
+
from mindor.dsl.schema.action import ModelActionConfig, TextEmbeddingModelActionConfig
|
|
4
|
+
from ..base import ModelTaskService, ModelTaskType, register_model_task_service
|
|
5
|
+
from ..base import ComponentActionContext
|
|
6
|
+
from transformers import AutoModel, AutoTokenizer, PreTrainedModel, PreTrainedTokenizer
|
|
7
|
+
from transformers.modeling_outputs import BaseModelOutput
|
|
8
|
+
from torch import Tensor
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
class TextEmbeddingTaskAction:
|
|
12
|
+
def __init__(self, config: TextEmbeddingModelActionConfig, model: PreTrainedModel, tokenizer: PreTrainedTokenizer):
|
|
13
|
+
self.config: TextEmbeddingModelActionConfig = config
|
|
14
|
+
self.model: PreTrainedModel = model
|
|
15
|
+
self.tokenizer: PreTrainedTokenizer = tokenizer
|
|
16
|
+
|
|
17
|
+
async def run(self, context: ComponentActionContext) -> Any:
|
|
18
|
+
text = await context.render_variable(self.config.text)
|
|
19
|
+
|
|
20
|
+
# Model parameters
|
|
21
|
+
max_length = await context.render_variable(self.config.params.max_length)
|
|
22
|
+
pooling = await context.render_variable(self.config.params.pooling)
|
|
23
|
+
normalize = await context.render_variable(self.config.params.normalize)
|
|
24
|
+
|
|
25
|
+
# Tokenizing
|
|
26
|
+
inputs = self.tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=max_length).to(self.model.device)
|
|
27
|
+
attention_mask: Tensor = inputs.get("attention_mask", None)
|
|
28
|
+
|
|
29
|
+
# Forward pass through the model
|
|
30
|
+
with torch.no_grad():
|
|
31
|
+
outputs: BaseModelOutput = self.model(**inputs)
|
|
32
|
+
last_hidden_state = outputs.last_hidden_state # (batch_size, seq_len, hidden_size)
|
|
33
|
+
|
|
34
|
+
# Apply pooling strategy (mean, cls, max)
|
|
35
|
+
embedding = self._pool_hidden_state(last_hidden_state, attention_mask, pooling)
|
|
36
|
+
|
|
37
|
+
if normalize:
|
|
38
|
+
embedding = torch.nn.functional.normalize(embedding, p=2, dim=1)
|
|
39
|
+
|
|
40
|
+
result = embedding.squeeze().tolist()
|
|
41
|
+
context.register_source("result", result)
|
|
42
|
+
|
|
43
|
+
return (await context.render_variable(self.config.output, ignore_files=True)) if self.config.output else result
|
|
44
|
+
|
|
45
|
+
def _pool_hidden_state(self, last_hidden_state: Tensor, attention_mask: Optional[Tensor], pooling: str) -> Tensor:
|
|
46
|
+
if pooling == "mean":
|
|
47
|
+
if attention_mask is not None:
|
|
48
|
+
mask = attention_mask.unsqueeze(-1).expand(last_hidden_state.size())
|
|
49
|
+
summed = torch.sum(last_hidden_state * mask, dim=1)
|
|
50
|
+
count = torch.clamp(mask.sum(dim=1), min=1e-9)
|
|
51
|
+
return summed / count
|
|
52
|
+
else:
|
|
53
|
+
return torch.mean(last_hidden_state, dim=1)
|
|
54
|
+
|
|
55
|
+
if pooling == "cls":
|
|
56
|
+
return last_hidden_state[:, 0]
|
|
57
|
+
|
|
58
|
+
if pooling == "max":
|
|
59
|
+
if attention_mask is not None:
|
|
60
|
+
mask = attention_mask.unsqueeze(-1).expand(last_hidden_state.size())
|
|
61
|
+
last_hidden_state = last_hidden_state.masked_fill(mask == 0, -1e9)
|
|
62
|
+
return torch.max(last_hidden_state, dim=1).values
|
|
63
|
+
|
|
64
|
+
raise ValueError(f"Unsupported pooling type: {pooling}")
|
|
65
|
+
|
|
66
|
+
@register_model_task_service(ModelTaskType.TEXT_EMBEDDING)
|
|
67
|
+
class TextEmbeddingTaskService(ModelTaskService):
|
|
68
|
+
def __init__(self, id: str, config: ModelComponentConfig, daemon: bool):
|
|
69
|
+
super().__init__(id, config, daemon)
|
|
70
|
+
|
|
71
|
+
self.model: Optional[PreTrainedModel] = None
|
|
72
|
+
self.tokenizer: Optional[PreTrainedTokenizer] = None
|
|
73
|
+
|
|
74
|
+
async def _serve(self) -> None:
|
|
75
|
+
self.model = AutoModel.from_pretrained(self.config.model).to(torch.device(self.config.device))
|
|
76
|
+
self.tokenizer = AutoTokenizer.from_pretrained(self.config.model)
|
|
77
|
+
|
|
78
|
+
async def _shutdown(self) -> None:
|
|
79
|
+
self.model = None
|
|
80
|
+
self.tokenizer = None
|
|
81
|
+
|
|
82
|
+
async def _run(self, action: ModelActionConfig, context: ComponentActionContext) -> Any:
|
|
83
|
+
return await TextEmbeddingTaskAction(action, self.model, self.tokenizer).run(context)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from mindor.dsl.schema.component import ModelComponentConfig
|
|
3
|
+
from mindor.dsl.schema.action import ModelActionConfig, TextGenerationModelActionConfig
|
|
4
|
+
from ..base import ModelTaskService, ModelTaskType, register_model_task_service
|
|
5
|
+
from ..base import ComponentActionContext
|
|
6
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedModel, PreTrainedTokenizer, GenerationMixin
|
|
7
|
+
import torch
|
|
8
|
+
|
|
9
|
+
class TextGenerationTaskAction:
|
|
10
|
+
def __init__(self, config: TextGenerationModelActionConfig, model: Union[PreTrainedModel, GenerationMixin], tokenizer: PreTrainedTokenizer):
|
|
11
|
+
self.config: TextGenerationModelActionConfig = config
|
|
12
|
+
self.model: Union[PreTrainedModel, GenerationMixin] = model
|
|
13
|
+
self.tokenizer: PreTrainedTokenizer = tokenizer
|
|
14
|
+
|
|
15
|
+
async def run(self, context: ComponentActionContext) -> Any:
|
|
16
|
+
prompt: str = await context.render_variable(self.config.prompt)
|
|
17
|
+
|
|
18
|
+
# Model parameters
|
|
19
|
+
max_length = await context.render_variable(self.config.params.max_length)
|
|
20
|
+
num_return_sequences = await context.render_variable(self.config.params.num_return_sequences)
|
|
21
|
+
temperature = await context.render_variable(self.config.params.temperature)
|
|
22
|
+
top_k = await context.render_variable(self.config.params.top_k)
|
|
23
|
+
top_p = await context.render_variable(self.config.params.top_p)
|
|
24
|
+
|
|
25
|
+
# Tokenizing
|
|
26
|
+
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
|
|
27
|
+
|
|
28
|
+
# Text generation
|
|
29
|
+
with torch.no_grad():
|
|
30
|
+
outputs = self.model.generate(
|
|
31
|
+
**inputs,
|
|
32
|
+
max_length=max_length,
|
|
33
|
+
num_return_sequences=num_return_sequences,
|
|
34
|
+
temperature=temperature,
|
|
35
|
+
top_k=top_k,
|
|
36
|
+
top_p=top_p,
|
|
37
|
+
do_sample=True
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Decoding output
|
|
41
|
+
result = self.tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
42
|
+
context.register_source("result", result)
|
|
43
|
+
|
|
44
|
+
return (await context.render_variable(self.config.output, ignore_files=True)) if self.config.output else result
|
|
45
|
+
|
|
46
|
+
@register_model_task_service(ModelTaskType.TEXT_GENERATION)
|
|
47
|
+
class TextGenerationTaskService(ModelTaskService):
|
|
48
|
+
def __init__(self, id: str, config: ModelComponentConfig, daemon: bool):
|
|
49
|
+
super().__init__(id, config, daemon)
|
|
50
|
+
|
|
51
|
+
self.model: Optional[Union[PreTrainedModel, GenerationMixin]] = None
|
|
52
|
+
self.tokenizer: Optional[PreTrainedTokenizer] = None
|
|
53
|
+
|
|
54
|
+
async def _serve(self) -> None:
|
|
55
|
+
self.model = AutoModelForCausalLM.from_pretrained(self.config.model).to(torch.device(self.config.device))
|
|
56
|
+
self.tokenizer = AutoTokenizer.from_pretrained(self.config.model)
|
|
57
|
+
|
|
58
|
+
async def _shutdown(self) -> None:
|
|
59
|
+
self.model = None
|
|
60
|
+
self.tokenizer = None
|
|
61
|
+
|
|
62
|
+
async def _run(self, action: ModelActionConfig, context: ComponentActionContext) -> Any:
|
|
63
|
+
return await TextGenerationTaskAction(action, self.model, self.tokenizer).run(context)
|
|
@@ -49,7 +49,8 @@ class GradioWebUIBuilder:
|
|
|
49
49
|
async def _run_workflow(*args):
|
|
50
50
|
input = await self._build_input_value(args, workflow.input)
|
|
51
51
|
output = await runner(input)
|
|
52
|
-
|
|
52
|
+
if workflow.output:
|
|
53
|
+
output = await self._flatten_output_value(output, workflow.output)
|
|
53
54
|
return output[0] if len(output) == 1 else output
|
|
54
55
|
|
|
55
56
|
run_button.click(
|
|
@@ -6,9 +6,8 @@ from mindor.core.controller.runner import ControllerRunner
|
|
|
6
6
|
from mindor.core.workflow.schema import create_workflow_schema
|
|
7
7
|
from mindor.core.services import AsyncService
|
|
8
8
|
from .gradio import GradioWebUIBuilder
|
|
9
|
-
|
|
10
|
-
from fastapi import FastAPI
|
|
11
9
|
from gradio import mount_gradio_app
|
|
10
|
+
from fastapi import FastAPI
|
|
12
11
|
import uvicorn, gradio
|
|
13
12
|
|
|
14
13
|
class ControllerWebUI(AsyncService):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Callable, Iterator, Any
|
|
2
2
|
from mindor.dsl.schema.logger import ConsoleLoggerConfig
|
|
3
3
|
from ..base import LoggerService, LoggerType, LoggingLevel, register_logger
|
|
4
|
+
from uvicorn.logging import ColourizedFormatter
|
|
4
5
|
import logging
|
|
5
6
|
|
|
6
7
|
_level_map = {
|
|
@@ -17,7 +18,7 @@ class ConsoleLogger(LoggerService):
|
|
|
17
18
|
super().__init__(id, config, daemon)
|
|
18
19
|
|
|
19
20
|
self.logger: logging.Logger = logging.getLogger(id)
|
|
20
|
-
self.formatter: logging.Formatter =
|
|
21
|
+
self.formatter: logging.Formatter = ColourizedFormatter("%(levelprefix)s %(message)s")
|
|
21
22
|
self.handler: logging.StreamHandler = None
|
|
22
23
|
|
|
23
24
|
self._configure_logger()
|
|
@@ -2,6 +2,16 @@ from typing import Union, Optional
|
|
|
2
2
|
from datetime import timedelta, datetime
|
|
3
3
|
import zoneinfo
|
|
4
4
|
|
|
5
|
+
class TimeTracker:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self._start = datetime.now()
|
|
8
|
+
|
|
9
|
+
def elapsed(self) -> float:
|
|
10
|
+
return (datetime.now() - self._start).total_seconds()
|
|
11
|
+
|
|
12
|
+
def reset(self) -> None:
|
|
13
|
+
self._start = datetime.now()
|
|
14
|
+
|
|
5
15
|
def parse_duration(value: Union[str, float, int]) -> timedelta:
|
|
6
16
|
if isinstance(value, (float, int)):
|
|
7
17
|
return timedelta(seconds=value)
|
|
@@ -2,6 +2,7 @@ from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annot
|
|
|
2
2
|
from mindor.dsl.schema.job import ActionJobConfig, JobType
|
|
3
3
|
from mindor.dsl.schema.component import ComponentConfig
|
|
4
4
|
from mindor.core.component import ComponentService, ComponentGlobalConfigs, ComponentResolver, create_component
|
|
5
|
+
from mindor.core.utils.time import TimeTracker
|
|
5
6
|
from mindor.core.logger import logging
|
|
6
7
|
from ..base import Job, JobType, WorkflowContext, register_job
|
|
7
8
|
from datetime import datetime
|
|
@@ -24,14 +25,13 @@ class ActionJob(Job):
|
|
|
24
25
|
async def _run_once():
|
|
25
26
|
run_id: str = ulid.ulid()
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
job_time_tracker = TimeTracker()
|
|
28
29
|
logging.debug("[task-%s] Action 'run-%s' started for job '%s'", context.task_id, run_id, self.id)
|
|
29
30
|
|
|
30
31
|
output = await component.run(await context.render_variable(self.config.action), run_id, input)
|
|
31
32
|
context.register_source("output", output)
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
logging.debug("[task-%s] Action 'run-%s' completed in %.2f seconds.", context.task_id, run_id, elapsed)
|
|
34
|
+
logging.debug("[task-%s] Action 'run-%s' completed in %.2f seconds.", context.task_id, run_id, job_time_tracker.elapsed())
|
|
35
35
|
|
|
36
36
|
output = (await context.render_variable(self.config.output, ignore_files=True)) if self.config.output else output
|
|
37
37
|
outputs.append(output)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Callable, Any
|
|
2
2
|
from mindor.dsl.schema.job import DelayJobConfig, DelayJobMode
|
|
3
3
|
from mindor.dsl.schema.component import ComponentConfig
|
|
4
|
-
from mindor.core.utils.time import parse_duration, parse_datetime
|
|
4
|
+
from mindor.core.utils.time import parse_duration, parse_datetime, TimeTracker
|
|
5
5
|
from mindor.core.logger import logging
|
|
6
6
|
from ..base import Job, JobType, WorkflowContext, register_job
|
|
7
7
|
from datetime import datetime, timedelta
|
|
@@ -25,14 +25,13 @@ class DelayJob(Job):
|
|
|
25
25
|
duration = parse_duration((await context.render_variable(self.config.duration)) or 0.0)
|
|
26
26
|
duration = duration.total_seconds()
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
job_time_tracker = TimeTracker()
|
|
29
29
|
logging.debug("[task-%s] Delay started for time interval: %d seconds.", context.task_id, int(duration))
|
|
30
30
|
|
|
31
31
|
if duration > 0.0:
|
|
32
32
|
await asyncio.sleep(duration)
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
logging.debug("[task-%s] Delay completed in %.2f seconds.", context.task_id, elapsed)
|
|
34
|
+
logging.debug("[task-%s] Delay completed in %.2f seconds.", context.task_id, job_time_tracker.elapsed())
|
|
36
35
|
|
|
37
36
|
return None
|
|
38
37
|
|
|
@@ -43,13 +42,12 @@ class DelayJob(Job):
|
|
|
43
42
|
now = datetime.now(tz=time.tzinfo)
|
|
44
43
|
duration = max((time - now).total_seconds(), 0.0)
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
job_time_tracker = TimeTracker()
|
|
47
46
|
logging.debug("[task-%s] Delay started, waiting until %s", context.task_id, time)
|
|
48
47
|
|
|
49
48
|
if duration > 0.0:
|
|
50
49
|
await asyncio.sleep(duration)
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
logging.debug("[task-%s] Delay completed in %.2f seconds.", context.task_id, elapsed)
|
|
51
|
+
logging.debug("[task-%s] Delay completed in %.2f seconds.", context.task_id, job_time_tracker.elapsed())
|
|
54
52
|
|
|
55
53
|
return None
|
|
@@ -2,6 +2,7 @@ from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annot
|
|
|
2
2
|
from mindor.dsl.schema.workflow import WorkflowConfig, JobConfig
|
|
3
3
|
from mindor.dsl.schema.component import ComponentConfig
|
|
4
4
|
from mindor.core.component import ComponentGlobalConfigs
|
|
5
|
+
from mindor.core.utils.time import TimeTracker
|
|
5
6
|
from mindor.core.logger import logging
|
|
6
7
|
from .context import WorkflowContext
|
|
7
8
|
from .job import Job, create_job
|
|
@@ -86,9 +87,10 @@ class WorkflowRunner:
|
|
|
86
87
|
running_job_ids: Set[str] = set()
|
|
87
88
|
completed_job_ids: Set[str] = set()
|
|
88
89
|
scheduled_job_tasks: Dict[str, asyncio.Task] = {}
|
|
90
|
+
job_time_trackers: Dict[str, TimeTracker] = {}
|
|
89
91
|
output: Any = None
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
workflow_time_tracker = TimeTracker()
|
|
92
94
|
logging.info("[task-%s] Workflow '%s' started.", context.task_id, self.id)
|
|
93
95
|
|
|
94
96
|
while pending_jobs:
|
|
@@ -96,10 +98,12 @@ class WorkflowRunner:
|
|
|
96
98
|
|
|
97
99
|
for job in runnable_jobs:
|
|
98
100
|
if job.id not in scheduled_job_tasks:
|
|
99
|
-
logging.debug("[task-%s] Scheduling job: '%s'", context.task_id, job.id)
|
|
100
101
|
scheduled_job_tasks[job.id] = asyncio.create_task(job.run(context))
|
|
101
102
|
running_job_ids.add(job.id)
|
|
102
103
|
|
|
104
|
+
job_time_trackers[job.id] = TimeTracker()
|
|
105
|
+
logging.info("[task-%s] Job '%s' started.", context.task_id, job.id)
|
|
106
|
+
|
|
103
107
|
if not scheduled_job_tasks:
|
|
104
108
|
raise RuntimeError("No runnable jobs but pending jobs remain.")
|
|
105
109
|
|
|
@@ -111,7 +115,7 @@ class WorkflowRunner:
|
|
|
111
115
|
completed_job_output = await completed_job_task
|
|
112
116
|
context.complete_job(completed_job_id, completed_job_output)
|
|
113
117
|
|
|
114
|
-
logging.info("[task-%s] Job '%s' completed.", context.task_id, completed_job_id)
|
|
118
|
+
logging.info("[task-%s] Job '%s' completed in %.2f seconds.", context.task_id, completed_job_id, job_time_trackers[completed_job_id].elapsed())
|
|
115
119
|
|
|
116
120
|
if self._is_terminal_job(completed_job_id):
|
|
117
121
|
if isinstance(output, dict) and isinstance(completed_job_output, dict):
|
|
@@ -124,8 +128,7 @@ class WorkflowRunner:
|
|
|
124
128
|
del pending_jobs[completed_job_id]
|
|
125
129
|
del scheduled_job_tasks[completed_job_id]
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
logging.info("[task-%s] Workflow '%s' completed in %.2f seconds.", context.task_id, self.id, elapsed)
|
|
131
|
+
logging.info("[task-%s] Workflow '%s' completed in %.2f seconds.", context.task_id, self.id, workflow_time_tracker.elapsed())
|
|
129
132
|
|
|
130
133
|
return output
|
|
131
134
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from .impl import *
|
|
4
|
+
|
|
5
|
+
ActionConfig = Union[
|
|
6
|
+
HttpServerActionConfig,
|
|
7
|
+
HttpClientActionConfig,
|
|
8
|
+
McpServerActionConfig,
|
|
9
|
+
McpClientActionConfig,
|
|
10
|
+
ModelActionConfig,
|
|
11
|
+
WorkflowActionConfig,
|
|
12
|
+
ShellActionConfig
|
|
13
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .model import *
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
from ...common import CommonActionConfig
|
|
5
|
+
|
|
6
|
+
class ModelTaskMode(str, Enum):
|
|
7
|
+
INFERENCE = "inference"
|
|
8
|
+
TRAINING = "training"
|
|
9
|
+
|
|
10
|
+
class CommonModelActionConfig(CommonActionConfig):
|
|
11
|
+
mode: ModelTaskMode = Field(default=ModelTaskMode.INFERENCE, description="")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from pydantic import model_validator
|
|
4
|
+
from .common import CommonModelActionConfig
|
|
5
|
+
|
|
6
|
+
class TextEmbeddingParamsConfig(BaseModel):
|
|
7
|
+
pooling: Literal[ "mean", "cls", "max" ] = Field(default="mean", description="Pooling strategy used to aggregate token embeddings.")
|
|
8
|
+
normalize: bool = Field(default=True, description="Whether to apply L2 normalization to the output embeddings.")
|
|
9
|
+
batch_size: int = Field(default=1, description="Number of input texts to process in a single batch.")
|
|
10
|
+
max_length: int = Field(default=512, description="Maximum number of tokens per input text.")
|
|
11
|
+
|
|
12
|
+
class TextEmbeddingModelActionConfig(CommonModelActionConfig):
|
|
13
|
+
text: str = Field(..., description="Input text to be embedded.")
|
|
14
|
+
params: TextEmbeddingParamsConfig = Field(default_factory=TextEmbeddingParamsConfig, description="Configuration parameters for embedding generation.")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from pydantic import model_validator
|
|
4
|
+
from .common import CommonModelActionConfig
|
|
5
|
+
|
|
6
|
+
class TextGenerationParamsConfig(BaseModel):
|
|
7
|
+
max_length: int = Field(default=128, description="")
|
|
8
|
+
num_return_sequences: int = Field(default=1, description="")
|
|
9
|
+
temperature: float = Field(default=1.0, description="")
|
|
10
|
+
top_k: int = Field(default=50, description="")
|
|
11
|
+
top_p: float = Field(default=1.0, description="")
|
|
12
|
+
|
|
13
|
+
class TextGenerationModelActionConfig(CommonModelActionConfig):
|
|
14
|
+
prompt: str = Field(..., description="")
|
|
15
|
+
params: TextGenerationParamsConfig = Field(default_factory=TextGenerationParamsConfig, description="Text generation configuration parameters.")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .model import *
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import Type, Union, Literal, Optional, Dict, List, Tuple, Set, Annotated, Any
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from pydantic import model_validator
|
|
4
|
+
from mindor.dsl.schema.action import ModelActionConfig
|
|
5
|
+
from mindor.dsl.utils.annotation import get_model_union_keys
|
|
6
|
+
from ...common import CommonComponentConfig, ComponentType
|
|
7
|
+
from .types import ModelTaskType
|
|
8
|
+
|
|
9
|
+
class CommonModelComponentConfig(CommonComponentConfig):
|
|
10
|
+
type: Literal[ComponentType.MODEL]
|
|
11
|
+
task: ModelTaskType = Field(..., description="")
|
|
12
|
+
model: str = Field(..., description="")
|
|
13
|
+
device: str = Field(default="cpu", description="Computation device to use.")
|
|
14
|
+
cache_dir: Optional[str] = Field(default=None, description="")
|
|
15
|
+
actions: Dict[str, ModelActionConfig] = Field(default_factory=dict)
|
|
16
|
+
|
|
17
|
+
@model_validator(mode="before")
|
|
18
|
+
def inflate_single_action(cls, values: Dict[str, Any]):
|
|
19
|
+
if "actions" not in values:
|
|
20
|
+
action_keys = set(get_model_union_keys(ModelActionConfig))
|
|
21
|
+
if any(k in values for k in action_keys):
|
|
22
|
+
values["actions"] = { "__default__": { k: values.pop(k) for k in action_keys if k in values } }
|
|
23
|
+
return values
|