mmar-mapi 1.0.25__py3-none-any.whl → 1.0.26__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/models/chat.py CHANGED
@@ -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
- ContentBase = str | Widget | StrDict
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['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 ''
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),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmar-mapi
3
- Version: 1.0.25
3
+ Version: 1.0.26
4
4
  Summary: Common pure/IO utilities for multi-modal architectures team
5
5
  Keywords:
6
6
  Author: Eugene Tagin
@@ -4,7 +4,7 @@ mmar_mapi/decorators_maybe_lru_cache.py,sha256=eO2I6t1fHLUNRABClK1c8EZzHAmCeSK6O
4
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=GP5XzOEtLjXUZRvKms8Fa874JOkfeu3vgiqitdoXj10,15724
7
+ mmar_mapi/models/chat.py,sha256=DCSHpCfF5EXA4KgDpcUdgeTwUMt7ErkQVOxE1y7tY3c,16070
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.25.dist-info/licenses/LICENSE,sha256=2A90w8WjhOgQXnFuUijKJYazaqZ4_NTokYb9Po4y-9k,1061
17
- mmar_mapi-1.0.25.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
18
- mmar_mapi-1.0.25.dist-info/METADATA,sha256=Jc4gOROtsYCnECtEltlL_OJfEFJkUSc1kvgiOOPlAPg,944
19
- mmar_mapi-1.0.25.dist-info/RECORD,,
16
+ mmar_mapi-1.0.26.dist-info/licenses/LICENSE,sha256=2A90w8WjhOgQXnFuUijKJYazaqZ4_NTokYb9Po4y-9k,1061
17
+ mmar_mapi-1.0.26.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
18
+ mmar_mapi-1.0.26.dist-info/METADATA,sha256=BckDmA6Sx8euBUG0FGEzlDmXT65406N3VZzwPjZ6za0,944
19
+ mmar_mapi-1.0.26.dist-info/RECORD,,