mmar-mapi 1.0.10__tar.gz → 1.0.12__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.
Potentially problematic release.
This version of mmar-mapi might be problematic. Click here for more details.
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/PKG-INFO +2 -1
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/pyproject.toml +2 -1
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/__init__.py +2 -1
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/chat.py +2 -0
- mmar_mapi-1.0.12/src/mmar_mapi/utils_import.py +46 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/LICENSE +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/README.md +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/api.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/file_storage.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/__init__.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/base.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/chat_item.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/enums.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/tracks.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/models/widget.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/type_union.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/utils.py +0 -0
- {mmar_mapi-1.0.10 → mmar_mapi-1.0.12}/src/mmar_mapi/xml_parser.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mmar-mapi
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.12
|
|
4
4
|
Summary: Common pure/IO utilities for multi-modal architectures team
|
|
5
5
|
Keywords:
|
|
6
6
|
Author: Eugene Tagin
|
|
@@ -20,6 +20,7 @@ Classifier: Topic :: Software Development
|
|
|
20
20
|
Classifier: Topic :: Utilities
|
|
21
21
|
Classifier: Typing :: Typed
|
|
22
22
|
Requires-Dist: pydantic~=2.11.7
|
|
23
|
+
Requires-Dist: loguru~=0.7.3
|
|
23
24
|
Requires-Python: >=3.12
|
|
24
25
|
Description-Content-Type: text/markdown
|
|
25
26
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mmar-mapi"
|
|
3
3
|
# dynamic version is not supported yet on uv_build
|
|
4
|
-
version = "1.0.
|
|
4
|
+
version = "1.0.12"
|
|
5
5
|
description = "Common pure/IO utilities for multi-modal architectures team"
|
|
6
6
|
authors = [{name = "Eugene Tagin", email = "tagin@airi.net"}]
|
|
7
7
|
license = "MIT"
|
|
@@ -25,6 +25,7 @@ classifiers = [
|
|
|
25
25
|
]
|
|
26
26
|
dependencies = [
|
|
27
27
|
"pydantic~=2.11.7",
|
|
28
|
+
"loguru~=0.7.3",
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
[build-system]
|
|
@@ -17,7 +17,7 @@ from .models.tracks import TrackInfo, DomainInfo
|
|
|
17
17
|
from .models.widget import Widget
|
|
18
18
|
from .utils import make_session_id, chunked
|
|
19
19
|
from .xml_parser import XMLParser
|
|
20
|
-
|
|
20
|
+
from .utils_import import load_main_objects
|
|
21
21
|
|
|
22
22
|
__all__ = [
|
|
23
23
|
"AIMessage",
|
|
@@ -44,6 +44,7 @@ __all__ = [
|
|
|
44
44
|
"Widget",
|
|
45
45
|
"XMLParser",
|
|
46
46
|
"chunked",
|
|
47
|
+
"load_main_objects",
|
|
47
48
|
"make_content",
|
|
48
49
|
"make_session_id",
|
|
49
50
|
]
|
|
@@ -185,6 +185,8 @@ class AIMessage(BaseMessage):
|
|
|
185
185
|
def action(self) -> str:
|
|
186
186
|
return (self.extra or {}).get("action", "")
|
|
187
187
|
|
|
188
|
+
def with_state(self, state: str) -> "AIMessage":
|
|
189
|
+
return self.model_copy(update=dict(state=state))
|
|
188
190
|
|
|
189
191
|
class MiscMessage(BaseMessage):
|
|
190
192
|
type: Literal["misc"] = "misc"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from pkgutil import iter_modules
|
|
2
|
+
from importlib import import_module
|
|
3
|
+
from types import ModuleType
|
|
4
|
+
|
|
5
|
+
from loguru import logger
|
|
6
|
+
|
|
7
|
+
def convert_snake_to_pascal(name: str) -> str:
|
|
8
|
+
""" snake_to_pascal -> SnakeToPascal """
|
|
9
|
+
return "".join(map(str.capitalize, name.split("_")))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_main_object_name(module: type[ModuleType]) -> str:
|
|
13
|
+
module_name = module.__name__.rsplit(".", 1)[-1]
|
|
14
|
+
main_object_name = convert_snake_to_pascal(module_name)
|
|
15
|
+
return main_object_name
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_main_object(module: type[ModuleType], obj_type):
|
|
19
|
+
"""tries to find SomeObject in object src.some_object"""
|
|
20
|
+
main_object_name = get_main_object_name(module)
|
|
21
|
+
try:
|
|
22
|
+
res = getattr(module, main_object_name)
|
|
23
|
+
if not isinstance(res, obj_type) and not issubclass(res, obj_type):
|
|
24
|
+
logger.error(f"Failed to load {module}.{main_object_name}: expected {obj_type} but found {type(res)}")
|
|
25
|
+
return None
|
|
26
|
+
return res
|
|
27
|
+
except AttributeError as ex:
|
|
28
|
+
logger.error(f"Failed to load {module}.{main_object_name}: {ex}")
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def load_modules(package_name: str) -> list[type[ModuleType]]:
|
|
33
|
+
try:
|
|
34
|
+
package = import_module(package_name)
|
|
35
|
+
except ModuleNotFoundError:
|
|
36
|
+
logger.error(f"Not found module: {package_name}")
|
|
37
|
+
return []
|
|
38
|
+
res = [import_module(module_name) for _, module_name, _ in iter_modules(package.__path__, package_name + ".")]
|
|
39
|
+
return res
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def load_main_objects(package_name: str, obj_type: type) -> dict[str, object]:
|
|
43
|
+
modules = load_modules(package_name)
|
|
44
|
+
main_objects = [get_main_object(m, obj_type) for m in modules]
|
|
45
|
+
res = {obj.__name__: obj for obj in main_objects}
|
|
46
|
+
return res
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|