naas-abi-core 1.0.2__py3-none-any.whl → 1.0.3.dev1__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.
- naas_abi_core/module/Module.py +15 -8
- naas_abi_core/utils/Expose.py +4 -2
- {naas_abi_core-1.0.2.dist-info → naas_abi_core-1.0.3.dev1.dist-info}/METADATA +1 -1
- {naas_abi_core-1.0.2.dist-info → naas_abi_core-1.0.3.dev1.dist-info}/RECORD +6 -6
- {naas_abi_core-1.0.2.dist-info → naas_abi_core-1.0.3.dev1.dist-info}/WHEEL +0 -0
- {naas_abi_core-1.0.2.dist-info → naas_abi_core-1.0.3.dev1.dist-info}/entry_points.txt +0 -0
naas_abi_core/module/Module.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import glob
|
|
4
4
|
import os
|
|
5
|
-
from typing import Dict, List
|
|
5
|
+
from typing import Dict, List, cast
|
|
6
6
|
|
|
7
7
|
from naas_abi_core import logger
|
|
8
8
|
from naas_abi_core.engine.engine_configuration.EngineConfiguration import GlobalConfig
|
|
@@ -13,6 +13,7 @@ from naas_abi_core.pipeline.pipeline import Pipeline
|
|
|
13
13
|
from naas_abi_core.services.agent.Agent import Agent
|
|
14
14
|
from naas_abi_core.workflow.workflow import Workflow
|
|
15
15
|
from pydantic import BaseModel, ConfigDict
|
|
16
|
+
from typing_extensions import Generic, Self, TypeVar
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class ModuleDependencies:
|
|
@@ -46,13 +47,16 @@ class ModuleConfiguration(BaseModel):
|
|
|
46
47
|
global_config: GlobalConfig
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
TConfig = TypeVar("TConfig", bound=ModuleConfiguration)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class BaseModule(Generic[TConfig]):
|
|
50
54
|
"""Base interface class for ABI modules."""
|
|
51
55
|
|
|
52
|
-
_instances: Dict[type,
|
|
56
|
+
_instances: Dict[type, Self] = {}
|
|
53
57
|
|
|
54
58
|
_engine: EngineProxy
|
|
55
|
-
_configuration:
|
|
59
|
+
_configuration: TConfig
|
|
56
60
|
dependencies: ModuleDependencies = ModuleDependencies(modules=[], services=[])
|
|
57
61
|
|
|
58
62
|
__ontologies: List[str] = []
|
|
@@ -61,7 +65,7 @@ class BaseModule:
|
|
|
61
65
|
__workflows: List[Workflow] = []
|
|
62
66
|
__pipelines: List[Pipeline] = []
|
|
63
67
|
|
|
64
|
-
def __init__(self, engine: EngineProxy, configuration:
|
|
68
|
+
def __init__(self, engine: EngineProxy, configuration: TConfig):
|
|
65
69
|
assert isinstance(configuration, ModuleConfiguration), (
|
|
66
70
|
"configuration must be an instance of ModuleConfiguration"
|
|
67
71
|
)
|
|
@@ -76,7 +80,9 @@ class BaseModule:
|
|
|
76
80
|
"BaseModule.Configuration must be a subclass of ModuleConfiguration"
|
|
77
81
|
)
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
self_instance: Self = cast(Self, self)
|
|
84
|
+
|
|
85
|
+
self._instances[self.__class__] = self_instance
|
|
80
86
|
|
|
81
87
|
@classmethod
|
|
82
88
|
def get_dependencies(cls) -> List[str]:
|
|
@@ -84,7 +90,7 @@ class BaseModule:
|
|
|
84
90
|
return getattr(cls, "dependencies", [])
|
|
85
91
|
|
|
86
92
|
@classmethod
|
|
87
|
-
def get_instance(cls) ->
|
|
93
|
+
def get_instance(cls) -> Self:
|
|
88
94
|
if cls not in cls._instances:
|
|
89
95
|
raise ValueError(f"Module {cls} not initialized")
|
|
90
96
|
return cls._instances[cls]
|
|
@@ -94,7 +100,7 @@ class BaseModule:
|
|
|
94
100
|
return self._engine
|
|
95
101
|
|
|
96
102
|
@property
|
|
97
|
-
def configuration(self) ->
|
|
103
|
+
def configuration(self) -> TConfig:
|
|
98
104
|
return self._configuration
|
|
99
105
|
|
|
100
106
|
@property
|
|
@@ -243,3 +249,4 @@ class BaseModule:
|
|
|
243
249
|
# def on_initialized(self):
|
|
244
250
|
# if hasattr(self.imported_module, "on_initialized"):
|
|
245
251
|
# self.imported_module.on_initialized()
|
|
252
|
+
# self.imported_module.on_initialized()
|
naas_abi_core/utils/Expose.py
CHANGED
|
@@ -4,8 +4,9 @@ from abc import ABC, abstractmethod
|
|
|
4
4
|
from enum import Enum
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
from fastapi import APIRouter
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
9
10
|
from langchain_core.tools import BaseTool
|
|
10
11
|
|
|
11
12
|
|
|
@@ -51,3 +52,4 @@ class Expose(ABC):
|
|
|
51
52
|
NotImplementedError: If the concrete class does not implement this method
|
|
52
53
|
"""
|
|
53
54
|
raise NotImplementedError()
|
|
55
|
+
raise NotImplementedError()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: naas-abi-core
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3.dev1
|
|
4
4
|
Summary: Abi framework allowing you to build your AI system.
|
|
5
5
|
Author-email: Maxime Jublou <maxime@naas.ai>, Florent Ravenel <florent@naas.ai>, Jeremy Ravenel <jeremy@naas.ai>
|
|
6
6
|
Requires-Python: <4,>=3.10
|
|
@@ -37,7 +37,7 @@ naas_abi_core/integration/integration.py,sha256=tbdAV63Uisml9G8diZl20_JDlgJVFuLQ
|
|
|
37
37
|
naas_abi_core/models/Model.py,sha256=s1Aj8Mcy113uhgYR4-lSfoyLnucOzOlnxKu6QKSwfeY,8223
|
|
38
38
|
naas_abi_core/models/OpenRouter.py,sha256=6bvn_Dl4mQB1J-XTMoF1rD8F4FNszLAA0358fzJDBxs,485
|
|
39
39
|
naas_abi_core/models/OpenRouter_test.py,sha256=nLlVdBaBan0mkdbnF3vrWGJYr8zQAC7Fl3wLUc37Mvw,1168
|
|
40
|
-
naas_abi_core/module/Module.py,sha256=
|
|
40
|
+
naas_abi_core/module/Module.py,sha256=UGNXZkwgD0xv7HrxTHH9eRXYPv8kuxqfMGAHgfgQJlM,9096
|
|
41
41
|
naas_abi_core/module/ModuleAgentLoader.py,sha256=Tc2KYODt8cGeK__QLk7h0J5QZ0EM-ZsQZTDeCJ4ip38,1965
|
|
42
42
|
naas_abi_core/module/ModuleUtils.py,sha256=6wUHpbdl0y_16xvz7W-NSOaRyLW9N9zx2Lg_Jkg0eMM,707
|
|
43
43
|
naas_abi_core/modules/templatablesparqlquery/README.md,sha256=Cpz3FPMc1q-P5HmQ7848er5_MRTHLDLqYqq0nFrs7Dw,6991
|
|
@@ -99,7 +99,7 @@ naas_abi_core/services/vector_store/VectorStoreService_test.py,sha256=LKGdUJoayV
|
|
|
99
99
|
naas_abi_core/services/vector_store/__init__.py,sha256=tuRLebTOVhH5UF8JRke3rVTze1V3WK1DFT4k9ZYHqeA,407
|
|
100
100
|
naas_abi_core/services/vector_store/adapters/QdrantAdapter.py,sha256=rlgjwbPXxFU1sAiNX8_57ia-5svN3e5kAkE6p42kJRI,7981
|
|
101
101
|
naas_abi_core/services/vector_store/adapters/QdrantAdapter_test.py,sha256=JyKNfx-e4M7VybWViWrGWG8KiAnBa0oOwT-W_Yg23Uw,1891
|
|
102
|
-
naas_abi_core/utils/Expose.py,sha256=
|
|
102
|
+
naas_abi_core/utils/Expose.py,sha256=ycxiz2tOXkRco_fiNM281e85RWHWi2xUT82PEE_Hdjk,1746
|
|
103
103
|
naas_abi_core/utils/Graph.py,sha256=FoBuiTrcLw4dzhROnd7JHp-LMxMuwJISFbtdrwpoM24,6288
|
|
104
104
|
naas_abi_core/utils/JSON.py,sha256=onIs-E3GWz4fvRuWBQpyb9qRNXCOJPf9x1yV1-jDlqU,1687
|
|
105
105
|
naas_abi_core/utils/LazyLoader.py,sha256=rWrnFVuKCK1WrtNgeiegT_i7AkxGy9qK2hfhsXV4dCY,1120
|
|
@@ -119,7 +119,7 @@ naas_abi_core/utils/onto2py/onto2py.py,sha256=_wn9qrrsWd8gO-BY4_jQJVfY87e9MJ2Er2
|
|
|
119
119
|
naas_abi_core/utils/onto2py/tests/ttl2py_test.py,sha256=5OZqSxPffjJYiX9T4rT1mV0PT1Qhf6goqEYT_mAPnaI,8055
|
|
120
120
|
naas_abi_core/workflow/__init__.py,sha256=hZD58mCB1PApxITqftP_xgjxL7NeLvOfI-rJENg1ENs,250
|
|
121
121
|
naas_abi_core/workflow/workflow.py,sha256=ZufSS073JztVl0OQRTqNyK7FepFvv7gXlc4j5FAEZCI,1216
|
|
122
|
-
naas_abi_core-1.0.
|
|
123
|
-
naas_abi_core-1.0.
|
|
124
|
-
naas_abi_core-1.0.
|
|
125
|
-
naas_abi_core-1.0.
|
|
122
|
+
naas_abi_core-1.0.3.dev1.dist-info/METADATA,sha256=UOS_Na1xUMnzwS_H_NeIhLs7sojsmA5YlDRuU31jqMY,3197
|
|
123
|
+
naas_abi_core-1.0.3.dev1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
124
|
+
naas_abi_core-1.0.3.dev1.dist-info/entry_points.txt,sha256=R6N3E2Hh92nTrji34JIwBgc6c-wVpfBYBTwkU0xe64E,79
|
|
125
|
+
naas_abi_core-1.0.3.dev1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|