digitalkin 0.2.11__py3-none-any.whl → 0.2.13__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.
Files changed (41) hide show
  1. digitalkin/__version__.py +1 -1
  2. digitalkin/grpc_servers/_base_server.py +15 -17
  3. digitalkin/grpc_servers/module_server.py +9 -10
  4. digitalkin/grpc_servers/module_servicer.py +108 -85
  5. digitalkin/grpc_servers/registry_server.py +3 -6
  6. digitalkin/grpc_servers/registry_servicer.py +18 -19
  7. digitalkin/grpc_servers/utils/grpc_client_wrapper.py +3 -5
  8. digitalkin/logger.py +45 -1
  9. digitalkin/models/module/module.py +1 -0
  10. digitalkin/modules/_base_module.py +47 -6
  11. digitalkin/modules/job_manager/base_job_manager.py +139 -0
  12. digitalkin/modules/job_manager/job_manager_models.py +44 -0
  13. digitalkin/modules/job_manager/single_job_manager.py +218 -0
  14. digitalkin/modules/job_manager/taskiq_broker.py +173 -0
  15. digitalkin/modules/job_manager/taskiq_job_manager.py +213 -0
  16. digitalkin/services/base_strategy.py +3 -1
  17. digitalkin/services/cost/cost_strategy.py +64 -16
  18. digitalkin/services/cost/default_cost.py +95 -12
  19. digitalkin/services/cost/grpc_cost.py +149 -60
  20. digitalkin/services/filesystem/default_filesystem.py +5 -6
  21. digitalkin/services/filesystem/filesystem_strategy.py +3 -2
  22. digitalkin/services/filesystem/grpc_filesystem.py +31 -26
  23. digitalkin/services/services_config.py +6 -5
  24. digitalkin/services/setup/__init__.py +1 -0
  25. digitalkin/services/setup/default_setup.py +10 -12
  26. digitalkin/services/setup/grpc_setup.py +8 -10
  27. digitalkin/services/storage/default_storage.py +13 -6
  28. digitalkin/services/storage/grpc_storage.py +25 -9
  29. digitalkin/services/storage/storage_strategy.py +3 -2
  30. digitalkin/utils/arg_parser.py +5 -48
  31. digitalkin/utils/development_mode_action.py +51 -0
  32. {digitalkin-0.2.11.dist-info → digitalkin-0.2.13.dist-info}/METADATA +43 -12
  33. {digitalkin-0.2.11.dist-info → digitalkin-0.2.13.dist-info}/RECORD +40 -33
  34. {digitalkin-0.2.11.dist-info → digitalkin-0.2.13.dist-info}/WHEEL +1 -1
  35. modules/cpu_intensive_module.py +271 -0
  36. modules/minimal_llm_module.py +200 -56
  37. modules/storage_module.py +5 -6
  38. modules/text_transform_module.py +1 -1
  39. digitalkin/modules/job_manager.py +0 -176
  40. {digitalkin-0.2.11.dist-info → digitalkin-0.2.13.dist-info}/licenses/LICENSE +0 -0
  41. {digitalkin-0.2.11.dist-info → digitalkin-0.2.13.dist-info}/top_level.txt +0 -0
@@ -7,73 +7,80 @@ base_server/mock/__init__.py,sha256=YZFT-F1l_TpvJYuIPX-7kTeE1CfOjhx9YmNRXVoi-jQ,
7
7
  base_server/mock/mock_pb2.py,sha256=sETakcS3PAAm4E-hTCV1jIVaQTPEAIoVVHupB8Z_k7Y,1843
8
8
  base_server/mock/mock_pb2_grpc.py,sha256=BbOT70H6q3laKgkHfOx1QdfmCS_HxCY4wCOX84YAdG4,3180
9
9
  digitalkin/__init__.py,sha256=7LLBAba0th-3SGqcpqFO-lopWdUkVLKzLZiMtB-mW3M,162
10
- digitalkin/__version__.py,sha256=ZjUNrl-BQaGTOQ-VGGgY11bESdYZm1yHJD2fcpVNx2Q,191
11
- digitalkin/logger.py,sha256=9cDgyJV2QXXT8F--xRODFlZyDgjuTTXNdpCU3GdqCsk,382
10
+ digitalkin/__version__.py,sha256=FYm4fUSZE0epsu7qiHq0IkVIvAs5ZzTEDWDQWZeryGs,191
11
+ digitalkin/logger.py,sha256=cFbIAZHOFx3nddOssRNYLXyqUPzR4CgDR_c-5wmB-og,1685
12
12
  digitalkin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  digitalkin/grpc_servers/__init__.py,sha256=0cJBlwipSmFdXkyH3T0i6OJ1WpAtNsZgYX7JaSnkbtg,804
14
- digitalkin/grpc_servers/_base_server.py,sha256=ec4xmgAuOMVg45a63O_PEa2T7mI4tJ6boxcXauFyZ5g,18649
15
- digitalkin/grpc_servers/module_server.py,sha256=0jC5MN-H4MGA9O9J87gnlM8EHcbrkb0chuCm8yZh7gI,10232
16
- digitalkin/grpc_servers/module_servicer.py,sha256=gm1dhmHhBGqY2xlhAp5i15O6waOA1mDHbFJxsT2RUT8,13662
17
- digitalkin/grpc_servers/registry_server.py,sha256=PmWaH4Xmg5Sj7NtFVLBNTOzkOfqo7dw_qyVBnaW4jy4,2238
18
- digitalkin/grpc_servers/registry_servicer.py,sha256=mCAjNhdMq5DozZMEPsJK__DIxePEYxSWV-gAq-Xctk4,16469
14
+ digitalkin/grpc_servers/_base_server.py,sha256=NXnnZPjJqUDWoumhEbb7EOEWB7d8XYwpQs-l97NTe4k,18647
15
+ digitalkin/grpc_servers/module_server.py,sha256=tc4n8fu7bcMkwCI3CKkAKR4cZqyP_JTEW0lGtqsc5hs,10283
16
+ digitalkin/grpc_servers/module_servicer.py,sha256=I6S8qDhKOwDD1tofoUhAfhN8VH6A7hAM5UAlwu91_Is,14747
17
+ digitalkin/grpc_servers/registry_server.py,sha256=StY18DKYoPKQIU1SIzgito6D4_QA1aMVddZ8O2WGlHY,2223
18
+ digitalkin/grpc_servers/registry_servicer.py,sha256=dqsKGHZ0LnaIvGt4ipaAuigd37sbJBndT4MAT029GsY,16471
19
19
  digitalkin/grpc_servers/utils/exceptions.py,sha256=I00OM8p8up20He4dU1fiHsvdLj1DymjR_UmoeUm2MSA,785
20
20
  digitalkin/grpc_servers/utils/factory.py,sha256=jm6rFjiqmtSv7BIHNAOxsG9xXtSvWpx9TfzSQiX97MQ,5899
21
- digitalkin/grpc_servers/utils/grpc_client_wrapper.py,sha256=6gj98T2_siZNlsamfz2Qkg89ebv4rS8Gm_X2FpE6Iow,2613
21
+ digitalkin/grpc_servers/utils/grpc_client_wrapper.py,sha256=GXRqCTCufwWd8sVMoClnl-JpeBjgmdlSCD0a3YMU9D0,2594
22
22
  digitalkin/grpc_servers/utils/models.py,sha256=80F5oHiv8MOqMoDZJBXmJSRoVYJRyhaVcijQ2LinAig,8428
23
23
  digitalkin/grpc_servers/utils/types.py,sha256=rQ78s4nAet2jy-NIDj_PUWriT0kuGHr_w6ELjmjgBao,539
24
24
  digitalkin/models/__init__.py,sha256=hDHtUfswaNh8wo4NZaBItg9JqC0uNSRqXArNWSrGynY,163
25
25
  digitalkin/models/module/__init__.py,sha256=ihvRlemJuFvU4armZIL-Vq-zaJx9UrjDoJAVPbEG8jw,345
26
- digitalkin/models/module/module.py,sha256=vlIeWmH61NVEiJpRx0Crk4iB8hAUV4mG30likSyRFP4,686
26
+ digitalkin/models/module/module.py,sha256=NWOwCeD_NH0NL89AF_NJ0SwE7G1n-HTcRalodLCDmpM,749
27
27
  digitalkin/models/module/module_types.py,sha256=SxwzfDDnkyuQe50glVrxN6VPuJCkbB313FRyVZugIMw,312
28
28
  digitalkin/models/services/__init__.py,sha256=HsW7MUGFPvH7Ri28WN4BHHBfEQk5dzU_9FOWAc-0lSE,56
29
29
  digitalkin/models/services/cost.py,sha256=QTEuFD6xz62nob0z4ksE-INJWcZ-iFiuNW5mvXhpFes,1599
30
30
  digitalkin/models/services/storage.py,sha256=cYTVIriGKiprF9OerhSxmc_jM6fUTVwmeon1yQCinkE,143
31
31
  digitalkin/modules/__init__.py,sha256=ppYARmhvdVi55ofC0QZerIempSlcJYDeCXhcl4qXObw,278
32
- digitalkin/modules/_base_module.py,sha256=WU2oUW4-FjFtieuyRfXv3R3P4N1xT78zzMWrSTdhmAg,9090
32
+ digitalkin/modules/_base_module.py,sha256=EwfCCIy3N1eBdBUj6KAdx0WzNRFJsyQDVCdA8Lwvtn4,10463
33
33
  digitalkin/modules/archetype_module.py,sha256=T2Ehj7EpAC2MO9WQbJv39hqRw7rh3exhVZTEL3JPM8U,421
34
- digitalkin/modules/job_manager.py,sha256=QHcrm3F99I9tlNzXefkyhkkwPITf_H1bEb_obMDbUic,6177
35
34
  digitalkin/modules/tool_module.py,sha256=86g0M1wHZ1ReIc7AkKfyjnlGN2QYJBGxrEQpKVlyrZI,421
36
35
  digitalkin/modules/trigger_module.py,sha256=kVoI4Gdkw7WWUP5T6hSCNqw5FxibTxL6Tpq9KP7gg78,379
36
+ digitalkin/modules/job_manager/base_job_manager.py,sha256=I3bduyGDjCJ6RsbwQvLp_NA6ucP8MJJVoIKpEbaP9ss,4706
37
+ digitalkin/modules/job_manager/job_manager_models.py,sha256=onHy-DfInLZQveniMIWIKwTKSQjojz500JvHB54x93c,1129
38
+ digitalkin/modules/job_manager/single_job_manager.py,sha256=Dekcnn8wb4epqGrWFAZ86YvvII553Hw0xjipgAINl4A,7745
39
+ digitalkin/modules/job_manager/taskiq_broker.py,sha256=OnHZy-hAtVDU5FU4W9folZZKCrDrUk16VfHlfoECuiQ,5930
40
+ digitalkin/modules/job_manager/taskiq_job_manager.py,sha256=ODqC7Snf-Flo0ugotqicrTgjFu4wgll6bUu7CM3l7ZE,7459
37
41
  digitalkin/services/__init__.py,sha256=LqGk_5DJy8Bzz62ajIq9jCeYNKQUIgtSCpafZk15FLc,910
38
- digitalkin/services/base_strategy.py,sha256=U7J09LkNvTaj4bkX-gF86iU_FcUeHK6AKp4zyUPx6eI,470
39
- digitalkin/services/services_config.py,sha256=6mNYtw07ZNZbk2b4e3xKEpYfozD_NUZyUY3iiein_10,7256
42
+ digitalkin/services/base_strategy.py,sha256=QAQnJw1BbqcYMSzwlFyhHP5juBH2WKrZzWxqDr_sDHI,638
43
+ digitalkin/services/services_config.py,sha256=4hc7-rHgSigoS3SuV0V9FReD2Dz7XoMXcD6iMBP2KKM,7391
40
44
  digitalkin/services/services_models.py,sha256=5zXkWcfKnXGwQi9sN4OAL3XrgqOcmsTl8ai5Mi4RPsw,1668
41
45
  digitalkin/services/agent/__init__.py,sha256=vJc8JN0pdtA8ecypLBeHrwAUIW6H2C8NyW-dk24rTpk,244
42
46
  digitalkin/services/agent/agent_strategy.py,sha256=42Q9RciHX6tg3CgDQkbrlIx4h_TX0WIuSpLmCjitVmA,492
43
47
  digitalkin/services/agent/default_agent.py,sha256=4N_E_eQxJGOx1KVUUg5jNOje-3ncMxF3ePB-uDuGrJc,345
44
48
  digitalkin/services/cost/__init__.py,sha256=Wi9ZB4LSXFsUYgkX-V1UJQkVXYDNDpp8q2dXccR2uRM,303
45
- digitalkin/services/cost/cost_strategy.py,sha256=KkVLT8X2EY58ul-27Gj6lFx7dsk1SZgg-UunBC0D8Ks,986
46
- digitalkin/services/cost/default_cost.py,sha256=LaTOBIdGOwh4-9vDlnefm8eKDvSWglJOS7BFLOT_G9Q,811
47
- digitalkin/services/cost/grpc_cost.py,sha256=k0Df_41dwrowBjtz11eqYQyWCMIjY-wEPEytbo2j4gE,3215
49
+ digitalkin/services/cost/cost_strategy.py,sha256=VhHeqi9WnE1yoDBBVp5qmqwIt5tTZHU6_Z_jld8CVeE,2535
50
+ digitalkin/services/cost/default_cost.py,sha256=mEd0VL_tMcGU41q0f9MFeBYeKZBenv0mIHuwgXlQ7uQ,3869
51
+ digitalkin/services/cost/grpc_cost.py,sha256=p_5mG72N7e4bxwBOD9DNokvLtinBILiqCfllmkqpmhw,6253
48
52
  digitalkin/services/filesystem/__init__.py,sha256=BhwMl_BUvM0d65fmglkp0SVwn3RfYiUOKJgIMnOCaGM,381
49
- digitalkin/services/filesystem/default_filesystem.py,sha256=tTOsBt0MSjexKgWm657y8BLppMYJtmJIVdqzsSRRaYk,7264
50
- digitalkin/services/filesystem/filesystem_strategy.py,sha256=VH93jkijFtyVA6XaH_rsfdSyeEpkqea54NAvHFLJDjM,2216
51
- digitalkin/services/filesystem/grpc_filesystem.py,sha256=KifdA_1evYA19rib5ZR5WMIrm9_jzr3PF5Sq3s2uI3Q,8180
53
+ digitalkin/services/filesystem/default_filesystem.py,sha256=8pRO80GtJ3n7StNllvwsgM6vMurJso1Xj4bWBt_zbjw,7381
54
+ digitalkin/services/filesystem/filesystem_strategy.py,sha256=g5duep7Trc_NWq9WNtCrnheVxfMUvX6vJyx4W0hwwiY,2348
55
+ digitalkin/services/filesystem/grpc_filesystem.py,sha256=IN2HX05lzUzsE9BZdp_nhEKYV2GNLJRQLduzFh1JN-w,8326
52
56
  digitalkin/services/identity/__init__.py,sha256=InkeyLgFYYwItx8mePA8HpfacOMWZwwuc0G4pWtKq9s,270
53
57
  digitalkin/services/identity/default_identity.py,sha256=Y2auZHrGSZTIN5D8HyjLvLcNbYFM1CNUE23x7p5VIGw,386
54
58
  digitalkin/services/identity/identity_strategy.py,sha256=skappBbds1_qa0Gr24FGrNX1N0_OYhYT1Lh7dUaAirE,429
55
59
  digitalkin/services/registry/__init__.py,sha256=Zl4QAkCe9tOmmKGBWVuLQVFepdZiL0ec3VDj27IeyYM,270
56
60
  digitalkin/services/registry/default_registry.py,sha256=VnWkF6nHpFxUKuUbZLPqzXqdA6oXmyV_ySpeuOCf_ko,277
57
61
  digitalkin/services/registry/registry_strategy.py,sha256=uBXgZIv25jeXbeVO8vWvlNPxxNYu7_KiCw2PoE6AWr8,423
58
- digitalkin/services/setup/default_setup.py,sha256=x1J6trXhyLC7V2OTe5pRY5mIFkQ4oyi3-aG50a1G1U4,8253
59
- digitalkin/services/setup/grpc_setup.py,sha256=4rLra3Ao0cwVX1L380VYwmGactoIk8gmcNHGlkrpEo8,12449
62
+ digitalkin/services/setup/__init__.py,sha256=t6xcvEWqTbcRZstBFK9cESEqaZKvpW14VtYygxIqfYQ,65
63
+ digitalkin/services/setup/default_setup.py,sha256=9VM3KwsuQcFQQ08RoOHWOE_-9BsRW0YGRtDWYTbQGdA,8246
64
+ digitalkin/services/setup/grpc_setup.py,sha256=jLw9tfHMFhdVYXCIGC2ffx2HUgyNpgMi9G265nvkvMg,12440
60
65
  digitalkin/services/setup/setup_strategy.py,sha256=ZnJ_HwWCkHCPrqKekSD5L9y3p8wMwfjQ8sj2hLZq6go,4004
61
66
  digitalkin/services/snapshot/__init__.py,sha256=Uzlnzo0CYlSpVsdiI37hW7xQk8hu3YA1fOI6O6MSzB0,270
62
67
  digitalkin/services/snapshot/default_snapshot.py,sha256=Mb8QwWRsHh9I_tN0ln_ZiFa1QCZxOVWmuVLemQOTWpc,1058
63
68
  digitalkin/services/snapshot/snapshot_strategy.py,sha256=B1TU3V_k9A-OdqBkdyc41-ihnrW5Btcwd1KyQdHT46A,898
64
69
  digitalkin/services/storage/__init__.py,sha256=T-ocYLLphudkQgzvG47jBOm5GQsRFRIGA88y7Ur4akg,341
65
- digitalkin/services/storage/default_storage.py,sha256=qzLPrND92NR9hB7Ok6BF3Yxot14Efa_CHIvVte6kLsU,7817
66
- digitalkin/services/storage/grpc_storage.py,sha256=RWlTvcvKv5x-wQd4AsePeAeD4BYmXkJEpKsDWh6-ULA,6937
67
- digitalkin/services/storage/storage_strategy.py,sha256=EQQVMR0_NLwF7XmLCTDnV7AbJKgef_-_WKMD-os99-o,8635
70
+ digitalkin/services/storage/default_storage.py,sha256=m53sLOx0JVbua4weD_4GQBKK3c0UDf9HC5BnvSJAkvg,7933
71
+ digitalkin/services/storage/grpc_storage.py,sha256=EU2gcT2bOCSqOsnLwQcu3VOeOvdBlP1g0ALfBb07JxY,7172
72
+ digitalkin/services/storage/storage_strategy.py,sha256=vZWPk49AyJs7RwhSfUwDiTG1A7C4Ccd8y-VVPslyf0w,8734
68
73
  digitalkin/utils/__init__.py,sha256=sJnY-ZUgsjMfojAjONC1VN14mhgIDnzyOlGkw21rRnM,28
69
- digitalkin/utils/arg_parser.py,sha256=3YyI6oZhhrlTmPTrzlwpQzbCNWDFAT3pggcLxNtJoc0,4388
74
+ digitalkin/utils/arg_parser.py,sha256=nvjI1pKDY1HfS0oGcMQPtdTQcggXLtpxXMbnMxNEKRU,3109
75
+ digitalkin/utils/development_mode_action.py,sha256=TqRuAF_A7bDD4twRB4PnZcRoNeaiAnEdxM5kvy4aoaA,1511
70
76
  digitalkin/utils/llm_ready_schema.py,sha256=JjMug_lrQllqFoanaC091VgOqwAd-_YzcpqFlS7p778,2375
71
- digitalkin-0.2.11.dist-info/licenses/LICENSE,sha256=Ies4HFv2r2hzDRakJYxk3Y60uDFLiG-orIgeTpstnIo,20327
77
+ digitalkin-0.2.13.dist-info/licenses/LICENSE,sha256=Ies4HFv2r2hzDRakJYxk3Y60uDFLiG-orIgeTpstnIo,20327
72
78
  modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
- modules/minimal_llm_module.py,sha256=W-E3OrRbAsRJ6hvSeTU8pzmacdJC_PbcWfDapRv5A1A,5617
74
- modules/storage_module.py,sha256=U9zxEgNORR5SuunWOZvbVivzXOgMGljY-0h791bztVw,6388
75
- modules/text_transform_module.py,sha256=1KaA7abwxltKKtbmiW1rkkIK3BTYFPegUq54px0LOQs,7277
76
- digitalkin-0.2.11.dist-info/METADATA,sha256=8fN8MXo6oNdCRaIXedrYD0oipu9VsTzRqnjrLwug18U,29126
77
- digitalkin-0.2.11.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
78
- digitalkin-0.2.11.dist-info/top_level.txt,sha256=5_5e35inSM5YfWNZE21p5wGBojiVtQQML_WzbEk4BRU,31
79
- digitalkin-0.2.11.dist-info/RECORD,,
79
+ modules/cpu_intensive_module.py,sha256=LUfgd1qFJ0HfsWMapSXUivgf5KGDpANKPORbcQBUjc4,8089
80
+ modules/minimal_llm_module.py,sha256=6cygPliUb4mroOrUo5YirZfQQ1IeOT3xUHzPpDC_0Tc,10045
81
+ modules/storage_module.py,sha256=KJA75oxXDUxZrLfoY5KxeyI8Gm1b3DxFuFj7LGOkeaQ,6389
82
+ modules/text_transform_module.py,sha256=Db_WbJi7_gWyoNvQEVhHQf5VurDsU-jd9LMAalG0oZY,7277
83
+ digitalkin-0.2.13.dist-info/METADATA,sha256=CUpDclUxsamv7icPsWN-ImippAec3_EQZUGm1cQGHFQ,30577
84
+ digitalkin-0.2.13.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
85
+ digitalkin-0.2.13.dist-info/top_level.txt,sha256=5_5e35inSM5YfWNZE21p5wGBojiVtQQML_WzbEk4BRU,31
86
+ digitalkin-0.2.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,271 @@
1
+ """Simple module calling an LLM."""
2
+
3
+ import logging
4
+ from collections.abc import Callable
5
+ from typing import Any, ClassVar, Literal
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+ from digitalkin.grpc_servers.utils.models import ClientConfig, SecurityMode, ServerConfig, ServerMode
10
+ from digitalkin.modules._base_module import BaseModule
11
+ from digitalkin.services.services_models import ServicesStrategy
12
+ from digitalkin.services.setup.setup_strategy import SetupData
13
+
14
+ # Configure logging with clear formatting
15
+ logging.basicConfig(
16
+ level=logging.DEBUG,
17
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
18
+ )
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class MessageInputPayload(BaseModel):
23
+ """Message trigger model for the CPU Archetype module."""
24
+
25
+ payload_type: Literal["message"] = "message"
26
+ user_prompt: str = Field(
27
+ ...,
28
+ title="User Prompt",
29
+ description="The prompt provided by the user for processing.",
30
+ )
31
+
32
+
33
+ class InputFile(BaseModel):
34
+ """File model for the CPU Archetype module."""
35
+
36
+ name: str = Field(
37
+ ...,
38
+ title="File Name",
39
+ description="The name of the file to be processed.",
40
+ )
41
+ content: bytes = Field(
42
+ ...,
43
+ title="File Content",
44
+ description="The content of the file to be processed.",
45
+ )
46
+
47
+ file_type: str = Field(
48
+ ...,
49
+ title="File Type",
50
+ description="The type of the file to be processed.",
51
+ )
52
+
53
+
54
+ class FileInputPayload(BaseModel):
55
+ """File input model for the CPU Archetype module."""
56
+
57
+ payload_type: Literal["file"] = "file"
58
+ files: list[InputFile] = Field(
59
+ ...,
60
+ title="Files",
61
+ description="List of files to be processed.",
62
+ )
63
+
64
+
65
+ class CPUInput(BaseModel):
66
+ """Input model defining what data the module expects."""
67
+
68
+ payload: MessageInputPayload | FileInputPayload = Field(
69
+ ...,
70
+ discriminator="payload_type",
71
+ title="Payload",
72
+ description="Either a message or list of file input.",
73
+ )
74
+
75
+
76
+ class MessageOutputPayload(BaseModel):
77
+ """Message output model for the CPU Archetype module."""
78
+
79
+ payload_type: Literal["message"] = "message"
80
+ user_response: str = Field(
81
+ ...,
82
+ title="User Response",
83
+ description="The response generated by the assistant based on the user prompt.",
84
+ )
85
+
86
+
87
+ class OutputFile(BaseModel):
88
+ """File model for the CPU Archetype module."""
89
+
90
+ name: str = Field(
91
+ ...,
92
+ title="File Name",
93
+ description="The name of the file to be processed.",
94
+ )
95
+ url: str | None = Field(
96
+ ...,
97
+ title="File URL",
98
+ description="The URL of the file to be processed.",
99
+ )
100
+
101
+ message: str | None = Field(
102
+ None,
103
+ title="Message",
104
+ description="Optional message associated with the file.",
105
+ )
106
+
107
+
108
+ class FileOutputPayload(BaseModel):
109
+ """File output model for the CPU Archetype module."""
110
+
111
+ payload_type: Literal["file"] = "file"
112
+ files: list[OutputFile] = Field(
113
+ ...,
114
+ title="Files",
115
+ description="List of files generated by the assistant.",
116
+ )
117
+
118
+
119
+ class CPUOutput(BaseModel):
120
+ """Output model defining what data the module produces."""
121
+
122
+ payload: MessageOutputPayload | FileOutputPayload = Field(
123
+ ...,
124
+ discriminator="payload_type",
125
+ title="Payload",
126
+ description="Either a message or file response.",
127
+ )
128
+
129
+
130
+ class CPUSetup(BaseModel):
131
+ """Setup model defining module configuration parameters."""
132
+
133
+ model_name: str = Field(
134
+ ...,
135
+ title="Model Name",
136
+ description="The name of the CPU model to use for processing.",
137
+ )
138
+ developer_prompt: str = Field(
139
+ ...,
140
+ title="Developer Prompt",
141
+ description="The developer prompt new versions of system prompt, it defines the behavior of the assistant.",
142
+ )
143
+ temperature: float = Field(
144
+ 0.7,
145
+ title="Temperature",
146
+ description="Controls the randomness of the model's output. Higher values make output more random.",
147
+ )
148
+ max_tokens: int = Field(
149
+ 100,
150
+ title="Max Tokens",
151
+ description="The maximum number of tokens to generate in the response.",
152
+ )
153
+
154
+
155
+ class CPUToolSecret(BaseModel):
156
+ """Secret model defining module configuration parameters."""
157
+
158
+
159
+ server_config = ServerConfig(
160
+ host="[::]",
161
+ port=50151,
162
+ mode=ServerMode.ASYNC,
163
+ security=SecurityMode.INSECURE,
164
+ max_workers=10,
165
+ credentials=None,
166
+ )
167
+
168
+
169
+ client_config = ClientConfig(
170
+ host="[::]",
171
+ port=50151,
172
+ mode=ServerMode.ASYNC,
173
+ security=SecurityMode.INSECURE,
174
+ credentials=None,
175
+ )
176
+
177
+
178
+ class CPUIntensiveModule(BaseModule[CPUInput, CPUOutput, CPUSetup, CPUToolSecret]):
179
+ """A CPU endpoint tool module module."""
180
+
181
+ name = "CPUIntensiveModule"
182
+ description = "A module that interacts with CPU API to process text"
183
+
184
+ # Define the schema formats for the module
185
+ input_format = CPUInput
186
+ output_format = CPUOutput
187
+ setup_format = CPUSetup
188
+ secret_format = CPUToolSecret
189
+
190
+ # Define module metadata for discovery
191
+ metadata: ClassVar[dict[str, Any]] = {
192
+ "name": "CPUIntensiveModule",
193
+ "description": "Transforms input text using a streaming LLM response.",
194
+ "version": "1.0.0",
195
+ "tags": ["text", "transformation", "encryption", "streaming"],
196
+ }
197
+ # Define services_config_params with default values
198
+ services_config_strategies: ClassVar[dict[str, ServicesStrategy | None]] = {}
199
+ services_config_params: ClassVar[dict[str, dict[str, Any | None] | None]] = {
200
+ "storage": {
201
+ "config": {"chat_history": None},
202
+ "client_config": client_config,
203
+ },
204
+ "filesystem": {
205
+ "config": {},
206
+ "client_config": client_config,
207
+ },
208
+ "cost": {
209
+ "config": {},
210
+ "client_config": client_config,
211
+ },
212
+ }
213
+
214
+ async def initialize(self, setup_data: SetupData) -> None:
215
+ """Initialize the module capabilities.
216
+
217
+ This method is called when the module is loaded by the server.
218
+ Use it to set up module-specific resources or configurations.
219
+ """
220
+
221
+ async def run(
222
+ self,
223
+ input_data: CPUInput,
224
+ setup_data: CPUSetup,
225
+ callback: Callable,
226
+ ) -> None:
227
+ """Run the module.
228
+
229
+ Args:
230
+ input_data: Input data for the module
231
+ setup_data: Setup data for the module
232
+ callback: Callback function to report progress
233
+
234
+ Raises:
235
+ ValueError: If the payload type is unknown
236
+ """
237
+ # Validate the input data
238
+ input_model = self.input_format.model_validate(input_data)
239
+ self.setup_format.model_validate(setup_data)
240
+ logger.debug("Running with input data: %s", input_model)
241
+
242
+ if not hasattr(input_model, "payload"):
243
+ error_msg = "Input data is missing 'payload' field"
244
+ raise ValueError(error_msg)
245
+
246
+ if not hasattr(input_model.payload, "payload_type"):
247
+ error_msg = "Input payload is missing 'type' field"
248
+ raise ValueError(error_msg)
249
+
250
+ total = 0
251
+ input = MessageInputPayload.model_validate(input_model.payload).user_prompt
252
+
253
+ for i in range(int(input)):
254
+ total += i * i
255
+ if i % 100 == 0 or i == int(input) - 1:
256
+ message_output_payload = MessageOutputPayload(
257
+ payload_type="message",
258
+ user_response=f"result iteration {i}: {total}",
259
+ )
260
+ output_model = self.output_format.model_validate({"payload": message_output_payload})
261
+ await callback(output_data=output_model)
262
+ logger.info("Job %s completed", self.job_id)
263
+
264
+ async def cleanup(self) -> None:
265
+ """Clean up any resources when the module is stopped.
266
+
267
+ This method is called when the module is being shut down.
268
+ Use it to close connections, free resources, etc.
269
+ """
270
+ logger.info("Cleaning up module %s", self.metadata["name"])
271
+ # Release any resources here if needed.