mmar-mapi 1.0.24__tar.gz → 1.0.26__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.24 → mmar_mapi-1.0.26}/PKG-INFO +1 -1
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/pyproject.toml +1 -1
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/api.py +31 -13
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/chat.py +27 -9
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/LICENSE +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/README.md +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/__init__.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/decorators_maybe_lru_cache.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/file_storage.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/__init__.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/base.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/chat_item.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/enums.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/tracks.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/models/widget.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/type_union.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/utils.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/utils_import.py +0 -0
- {mmar_mapi-1.0.24 → mmar_mapi-1.0.26}/src/mmar_mapi/xml_parser.py +0 -0
|
@@ -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.26"
|
|
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"
|
|
@@ -44,7 +44,7 @@ class BinaryClassifiersAPI:
|
|
|
44
44
|
def get_classifiers(self) -> list[str]:
|
|
45
45
|
raise NotImplementedError
|
|
46
46
|
|
|
47
|
-
def evaluate(self, *, classifier: str, text: str) -> bool:
|
|
47
|
+
def evaluate(self, *, classifier: str | None = None, text: str) -> bool:
|
|
48
48
|
raise NotImplementedError
|
|
49
49
|
|
|
50
50
|
|
|
@@ -52,18 +52,34 @@ class LLMAccessorAPI:
|
|
|
52
52
|
def get_entrypoint_keys(self) -> list[str]:
|
|
53
53
|
raise NotImplementedError
|
|
54
54
|
|
|
55
|
-
def get_response(
|
|
55
|
+
def get_response(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
prompt: str,
|
|
59
|
+
resource_id: ResourceId | None = None,
|
|
60
|
+
entrypoint_key: str | None = None,
|
|
61
|
+
max_retries: int = 1,
|
|
62
|
+
) -> str:
|
|
56
63
|
raise NotImplementedError
|
|
57
64
|
|
|
58
|
-
def get_response_by_payload(
|
|
65
|
+
def get_response_by_payload(
|
|
66
|
+
self,
|
|
67
|
+
*,
|
|
68
|
+
payload: dict[str, Any],
|
|
69
|
+
resource_id: ResourceId | None = None,
|
|
70
|
+
entrypoint_key: str | None = None,
|
|
71
|
+
max_retries: int = 1,
|
|
72
|
+
) -> str:
|
|
59
73
|
raise NotImplementedError
|
|
60
74
|
|
|
61
|
-
def get_embedding(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
def get_embedding(
|
|
76
|
+
self,
|
|
77
|
+
*,
|
|
78
|
+
prompt: str,
|
|
79
|
+
resource_id: ResourceId | None = None,
|
|
80
|
+
entrypoint_key: str | None = None,
|
|
81
|
+
max_retries: int = 1,
|
|
82
|
+
) -> list[float]:
|
|
67
83
|
raise NotImplementedError
|
|
68
84
|
|
|
69
85
|
|
|
@@ -71,12 +87,12 @@ class TranslatorAPI:
|
|
|
71
87
|
def get_lang_codes(self) -> list[str]:
|
|
72
88
|
raise NotImplementedError
|
|
73
89
|
|
|
74
|
-
def translate(self, *, text: str, lang_code_from: str | None, lang_code_to: str) -> str:
|
|
90
|
+
def translate(self, *, text: str, lang_code_from: str | None = None, lang_code_to: str) -> str:
|
|
75
91
|
raise NotImplementedError
|
|
76
92
|
|
|
77
93
|
|
|
78
94
|
class CriticAPI:
|
|
79
|
-
def evaluate(self, *, text: str, chat: Chat | None = None) -> float:
|
|
95
|
+
def evaluate(self, *, text: str, chat: Chat | None = None) -> float: # TODO replace float with bool
|
|
80
96
|
raise NotImplementedError
|
|
81
97
|
|
|
82
98
|
|
|
@@ -159,7 +175,8 @@ class ExtractedImageMetadata(BaseModel):
|
|
|
159
175
|
|
|
160
176
|
|
|
161
177
|
class ExtractedPicture(ExtractedImage, ExtractedImageMetadata):
|
|
162
|
-
"
|
|
178
|
+
"Image of part of page"
|
|
179
|
+
|
|
163
180
|
pass
|
|
164
181
|
|
|
165
182
|
|
|
@@ -168,7 +185,8 @@ class ExtractedTable(ExtractedImage, ExtractedImageMetadata):
|
|
|
168
185
|
|
|
169
186
|
|
|
170
187
|
class ExtractedPageImage(ExtractedImage):
|
|
171
|
-
"
|
|
188
|
+
"Image of all page"
|
|
189
|
+
|
|
172
190
|
pass
|
|
173
191
|
|
|
174
192
|
|
|
@@ -2,7 +2,7 @@ import warnings
|
|
|
2
2
|
from collections.abc import Callable
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from typing import Any, Literal, TypeVar
|
|
5
|
+
from typing import Any, Literal, NotRequired, TypedDict, TypeVar
|
|
6
6
|
|
|
7
7
|
from pydantic import Field, ValidationError
|
|
8
8
|
|
|
@@ -15,7 +15,25 @@ from .base import Base
|
|
|
15
15
|
_DT_FORMAT: str = "%Y-%m-%d-%H-%M-%S"
|
|
16
16
|
_EXAMPLE_DT: str = datetime(year=1970, month=1, day=1).strftime(_DT_FORMAT)
|
|
17
17
|
StrDict = dict[str, Any]
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ResourceDict(TypedDict):
|
|
21
|
+
type: Literal["resource_id"]
|
|
22
|
+
resource_id: str
|
|
23
|
+
resource_name: NotRequired[str]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TextDict(TypedDict):
|
|
27
|
+
type: Literal["text"]
|
|
28
|
+
text: str
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class CommandDict(TypedDict):
|
|
32
|
+
type: Literal["command"]
|
|
33
|
+
command: StrDict
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
ContentBase = str | Widget | ResourceDict | CommandDict | TextDict | StrDict
|
|
19
37
|
Content = ContentBase | list[ContentBase]
|
|
20
38
|
T = TypeVar("T")
|
|
21
39
|
|
|
@@ -244,7 +262,7 @@ class Chat(Base):
|
|
|
244
262
|
def parse(chat_obj: str | dict | ChatItem) -> "Chat":
|
|
245
263
|
return _parse_chat_compat(chat_obj)
|
|
246
264
|
|
|
247
|
-
def to_chat_item(self, failsafe: bool=False) -> ChatItem:
|
|
265
|
+
def to_chat_item(self, failsafe: bool = False) -> ChatItem:
|
|
248
266
|
return convert_chat_to_chat_item(self, failsafe)
|
|
249
267
|
|
|
250
268
|
def add_message(self, message: ChatMessage):
|
|
@@ -392,14 +410,14 @@ def convert_chat_item_to_chat(chat_item: ChatItem) -> Chat:
|
|
|
392
410
|
return res
|
|
393
411
|
|
|
394
412
|
|
|
395
|
-
def convert_context_to_outer_context(context: Context, failsafe: bool=False) -> OuterContextItem:
|
|
413
|
+
def convert_context_to_outer_context(context: Context, failsafe: bool = False) -> OuterContextItem:
|
|
396
414
|
# legacy: eliminate after migration
|
|
397
415
|
extra = context.extra or {}
|
|
398
416
|
if failsafe:
|
|
399
|
-
extra[
|
|
400
|
-
extra[
|
|
401
|
-
extra[
|
|
402
|
-
extra[
|
|
417
|
+
extra["sex"] = extra.get("sex") or True
|
|
418
|
+
extra["age"] = extra.get("age") or 42
|
|
419
|
+
extra["language_code"] = extra.get("language_code") or ""
|
|
420
|
+
extra["entrypoint_key"] = extra.get("entrypoint_key") or ""
|
|
403
421
|
return OuterContextItem(
|
|
404
422
|
client_id=context.client_id,
|
|
405
423
|
user_id=context.user_id,
|
|
@@ -441,7 +459,7 @@ def convert_message_to_replica_item(message: ChatMessage) -> ReplicaItem | None:
|
|
|
441
459
|
return ReplicaItem(**kwargs)
|
|
442
460
|
|
|
443
461
|
|
|
444
|
-
def convert_chat_to_chat_item(chat: Chat, failsafe: bool=False) -> ChatItem:
|
|
462
|
+
def convert_chat_to_chat_item(chat: Chat, failsafe: bool = False) -> ChatItem:
|
|
445
463
|
# legacy: eliminate after migration
|
|
446
464
|
res = ChatItem(
|
|
447
465
|
outer_context=convert_context_to_outer_context(chat.context, failsafe=failsafe),
|
|
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
|
|
File without changes
|
|
File without changes
|