mmar-mapi 1.0.22__py3-none-any.whl → 1.0.24__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.

Potentially problematic release.


This version of mmar-mapi might be problematic. Click here for more details.

mmar_mapi/api.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from typing import Annotated
2
+ from typing import Annotated, Any
3
3
 
4
4
  from pydantic import AfterValidator, BaseModel
5
5
 
@@ -40,11 +40,38 @@ class ContentInterpreterRemoteAPI:
40
40
  raise NotImplementedError
41
41
 
42
42
 
43
- class ClassifierAPI:
44
- def get_values(self) -> list[Value]:
43
+ class BinaryClassifiersAPI:
44
+ def get_classifiers(self) -> list[str]:
45
45
  raise NotImplementedError
46
46
 
47
- def evaluate(self, *, chat: Chat) -> Value:
47
+ def evaluate(self, *, classifier: str, text: str) -> bool:
48
+ raise NotImplementedError
49
+
50
+
51
+ class LLMAccessorAPI:
52
+ def get_entrypoint_keys(self) -> list[str]:
53
+ raise NotImplementedError
54
+
55
+ def get_response(self, *, prompt: str, entrypoint_key: str | None = None, max_retries: int = 1) -> str:
56
+ raise NotImplementedError
57
+
58
+ def get_response_by_payload(self, *, payload: dict[str, Any], entrypoint_key: str | None = None, max_retries: int = 1) -> str:
59
+ raise NotImplementedError
60
+
61
+ def get_embedding(self, *, prompt: str, entrypoint_key: str | None = None, max_retries: int = 1) -> list[float]:
62
+ raise NotImplementedError
63
+
64
+ def get_image_response(
65
+ self, *, prompt: str, resource_id: ResourceId, entrypoint_key: str | None = None, max_retries: int = 1
66
+ ) -> str:
67
+ raise NotImplementedError
68
+
69
+
70
+ class TranslatorAPI:
71
+ def get_lang_codes(self) -> list[str]:
72
+ raise NotImplementedError
73
+
74
+ def translate(self, *, text: str, lang_code_from: str | None, lang_code_to: str) -> str:
48
75
  raise NotImplementedError
49
76
 
50
77
 
@@ -132,6 +159,7 @@ class ExtractedImageMetadata(BaseModel):
132
159
 
133
160
 
134
161
  class ExtractedPicture(ExtractedImage, ExtractedImageMetadata):
162
+ " Image of part of page "
135
163
  pass
136
164
 
137
165
 
@@ -140,6 +168,7 @@ class ExtractedTable(ExtractedImage, ExtractedImageMetadata):
140
168
 
141
169
 
142
170
  class ExtractedPageImage(ExtractedImage):
171
+ " Image of all page "
143
172
  pass
144
173
 
145
174
 
mmar_mapi/file_storage.py CHANGED
@@ -78,7 +78,7 @@ class FileStorage:
78
78
 
79
79
  def upload_dir(self, resource_ids: list[ResourceId]) -> ResourceId:
80
80
  content = "\n".join(resource_ids)
81
- res = self.upload(content, "dir")
81
+ res = self.upload(content=content, fname=".dir")
82
82
  return res
83
83
 
84
84
  def download(self, resource_id: ResourceId) -> bytes:
mmar_mapi/models/chat.py CHANGED
@@ -244,8 +244,8 @@ class Chat(Base):
244
244
  def parse(chat_obj: str | dict | ChatItem) -> "Chat":
245
245
  return _parse_chat_compat(chat_obj)
246
246
 
247
- def to_chat_item(self) -> ChatItem:
248
- return convert_chat_to_chat_item(self)
247
+ def to_chat_item(self, failsafe: bool=False) -> ChatItem:
248
+ return convert_chat_to_chat_item(self, failsafe)
249
249
 
250
250
  def add_message(self, message: ChatMessage):
251
251
  self.messages.append(message)
@@ -392,19 +392,24 @@ def convert_chat_item_to_chat(chat_item: ChatItem) -> Chat:
392
392
  return res
393
393
 
394
394
 
395
- def convert_context_to_outer_context(context: Context) -> OuterContextItem:
395
+ def convert_context_to_outer_context(context: Context, failsafe: bool=False) -> OuterContextItem:
396
396
  # legacy: eliminate after migration
397
397
  extra = context.extra or {}
398
+ if failsafe:
399
+ extra['sex'] = extra.get('sex') or True
400
+ extra['age'] = extra.get('age') or 42
401
+ extra['language_code'] = extra.get('language_code') or ''
402
+ extra['entrypoint_key'] = extra.get('entrypoint_key') or ''
398
403
  return OuterContextItem(
399
404
  client_id=context.client_id,
400
405
  user_id=context.user_id,
401
406
  session_id=context.session_id,
402
407
  track_id=context.track_id,
403
- sex=extra.get("sex"),
404
- age=extra.get("age"),
408
+ sex=extra["sex"],
409
+ age=extra["age"],
410
+ entrypoint_key=extra["entrypoint_key"],
411
+ language_code=extra["language_code"],
405
412
  parent_session_id=extra.get("parent_session_id"),
406
- entrypoint_key=extra.get("entrypoint_key"),
407
- language_code=extra.get("language_code"),
408
413
  )
409
414
 
410
415
 
@@ -436,10 +441,10 @@ def convert_message_to_replica_item(message: ChatMessage) -> ReplicaItem | None:
436
441
  return ReplicaItem(**kwargs)
437
442
 
438
443
 
439
- def convert_chat_to_chat_item(chat: Chat) -> ChatItem:
444
+ def convert_chat_to_chat_item(chat: Chat, failsafe: bool=False) -> ChatItem:
440
445
  # legacy: eliminate after migration
441
446
  res = ChatItem(
442
- outer_context=convert_context_to_outer_context(chat.context),
447
+ outer_context=convert_context_to_outer_context(chat.context, failsafe=failsafe),
443
448
  inner_context=dict(replicas=list(map(convert_message_to_replica_item, chat.messages))),
444
449
  )
445
450
  return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmar-mapi
3
- Version: 1.0.22
3
+ Version: 1.0.24
4
4
  Summary: Common pure/IO utilities for multi-modal architectures team
5
5
  Keywords:
6
6
  Author: Eugene Tagin
@@ -1,10 +1,10 @@
1
1
  mmar_mapi/__init__.py,sha256=9Q5xsrj26uUnn7ZWvvJUvdVIuzC2oCIeNB4dEoqjF-o,1256
2
- mmar_mapi/api.py,sha256=tRX7XhfiHD73W7MdMnWHUZ9IsMpLtRl7PdT3OwyU0Mo,4895
2
+ mmar_mapi/api.py,sha256=CmxwKSNxupzTmHXHG2FEi88RoJa9L9NyEC729MMDsK4,5964
3
3
  mmar_mapi/decorators_maybe_lru_cache.py,sha256=eO2I6t1fHLUNRABClK1c8EZzHAmCeSK6O-hbJGb2c9E,444
4
- mmar_mapi/file_storage.py,sha256=xJU59HmXFsfc53XALdx53IwyqV_k4218AzzXq1Q65Js,5052
4
+ mmar_mapi/file_storage.py,sha256=km4xA0h-GU07kBc6v3cG2fd9gDF75OfwBJiy0WOmtn4,5067
5
5
  mmar_mapi/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  mmar_mapi/models/base.py,sha256=mKtXV2x51XVj7W-et9tjGcPMDUUUMelW-BywMgFc2p0,411
7
- mmar_mapi/models/chat.py,sha256=-XilkiderIOFG1oSKRDG9NDOEN21sBpbTPHUrqVPjc4,15400
7
+ mmar_mapi/models/chat.py,sha256=GP5XzOEtLjXUZRvKms8Fa874JOkfeu3vgiqitdoXj10,15724
8
8
  mmar_mapi/models/chat_item.py,sha256=TRuV5qn7pi3eOvSG7GUqtTHEaq4b7fPoCCZtW-TyEIU,5702
9
9
  mmar_mapi/models/enums.py,sha256=J-GNpql9MCnKnWiV9aJRQGI-pAybvV86923RZs99grA,1006
10
10
  mmar_mapi/models/tracks.py,sha256=HKDp-BX1p7AlDfSEKfOKCu0TRSK9cD4Dmq1vJt8oRjw,307
@@ -13,7 +13,7 @@ mmar_mapi/type_union.py,sha256=diwmzcnbqkpGFckPHNw9o8zyQ955mOGNvhTlcBJ0RMI,1905
13
13
  mmar_mapi/utils.py,sha256=FlW9n-84xz2zSHsahHzJ3Y4Wu5mjpFer6t9z6PF6lS0,488
14
14
  mmar_mapi/utils_import.py,sha256=pUyMFd8SItTxBKI-GO9JhRmy43jG_OQlUPr8QCBOSwg,1682
15
15
  mmar_mapi/xml_parser.py,sha256=VvLIX_XCZao9i0qqpTVx8nx0vbFXSe8pEbdJdXnj97g,568
16
- mmar_mapi-1.0.22.dist-info/licenses/LICENSE,sha256=2A90w8WjhOgQXnFuUijKJYazaqZ4_NTokYb9Po4y-9k,1061
17
- mmar_mapi-1.0.22.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
18
- mmar_mapi-1.0.22.dist-info/METADATA,sha256=296uDSncFFxzt5-QPExV8vJmRKOMSDoGNYB7IaCGoj8,944
19
- mmar_mapi-1.0.22.dist-info/RECORD,,
16
+ mmar_mapi-1.0.24.dist-info/licenses/LICENSE,sha256=2A90w8WjhOgQXnFuUijKJYazaqZ4_NTokYb9Po4y-9k,1061
17
+ mmar_mapi-1.0.24.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
18
+ mmar_mapi-1.0.24.dist-info/METADATA,sha256=ZsqNUY0BG2ZMJC3orkx7AlOVEDGt-AQb7GScEMot4vE,944
19
+ mmar_mapi-1.0.24.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.8.22
2
+ Generator: uv 0.8.24
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any