mmar-mapi 1.0.7__tar.gz → 1.0.9__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.7
3
+ Version: 1.0.9
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.7"
4
+ version = "1.0.9"
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"
@@ -242,6 +242,16 @@ class Chat(Base):
242
242
  def rfind_in_messages(self, func: Callable[[ChatMessage], T | None]) -> T | None:
243
243
  return find_in_messages(self.messages[::-1], func)
244
244
 
245
+ def get_last_user_message(self) -> HumanMessage | None:
246
+ messages = self.messages
247
+ if not messages:
248
+ return []
249
+ message = messages[-1]
250
+ return message if isinstance(message, HumanMessage) else None
251
+
252
+ def count_messages(self, func: Callable[[ChatMessage], bool]) -> int:
253
+ return sum(map(func, self.messages))
254
+
245
255
 
246
256
  def make_content(
247
257
  text: str | None = None,
@@ -26,9 +26,17 @@ class Widget(BaseModel):
26
26
  def make_inline_buttons(ibuttons: dict[str, str], by=1) -> "Widget":
27
27
  return _make_inline_buttons(ibuttons=ibuttons, by=by)
28
28
 
29
+ @staticmethod
30
+ def make_buttons(buttons: list[str], by=1) -> "Widget":
31
+ return _make_buttons(buttons=buttons, by=1)
32
+
29
33
 
30
34
  def _make_inline_buttons(ibuttons: dict[str, str], by=1) -> "Widget":
31
35
  ibs0 = [f"{key}:{val}" for key, val in ibuttons.items()]
32
- ibs = list(chunked(ibs0, n=by))
33
- res = Widget(ibuttons=ibs)
36
+ res = Widget(ibuttons=list(chunked(ibs0, n=by)))
37
+ return res
38
+
39
+
40
+ def _make_buttons(buttons: list[str], by=1) -> "Widget":
41
+ res = Widget(buttons=list(chunked(buttons, n=by)))
34
42
  return res
File without changes
File without changes