mmar-mapi 1.0.23__tar.gz → 1.0.24__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmar-mapi
3
- Version: 1.0.23
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,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.23"
4
+ version = "1.0.24"
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"
@@ -159,6 +159,7 @@ class ExtractedImageMetadata(BaseModel):
159
159
 
160
160
 
161
161
  class ExtractedPicture(ExtractedImage, ExtractedImageMetadata):
162
+ " Image of part of page "
162
163
  pass
163
164
 
164
165
 
@@ -167,6 +168,7 @@ class ExtractedTable(ExtractedImage, ExtractedImageMetadata):
167
168
 
168
169
 
169
170
  class ExtractedPageImage(ExtractedImage):
171
+ " Image of all page "
170
172
  pass
171
173
 
172
174
 
@@ -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:
@@ -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
File without changes
File without changes