ommlds 0.0.0.dev460__py3-none-any.whl → 0.0.0.dev461__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 ommlds might be problematic. Click here for more details.

@@ -1,6 +1,7 @@
1
1
  import abc
2
2
  import typing as ta
3
3
 
4
+ from omdev.tui import rich
4
5
  from omlish import check
5
6
  from omlish import lang
6
7
  from omlish.formats import json
@@ -8,11 +9,6 @@ from omlish.formats import json
8
9
  from .... import minichain as mc
9
10
 
10
11
 
11
- with lang.auto_proxy_import(globals()):
12
- from rich import console as rich_console
13
- from rich import markdown as rich_markdown
14
-
15
-
16
12
  ##
17
13
 
18
14
 
@@ -22,7 +18,7 @@ class ChatSessionPrinter(lang.Abstract):
22
18
  raise NotImplementedError
23
19
 
24
20
 
25
- ##
21
+ #
26
22
 
27
23
 
28
24
  class StringChatSessionPrinter(ChatSessionPrinter, lang.Abstract):
@@ -59,7 +55,7 @@ class StringChatSessionPrinter(ChatSessionPrinter, lang.Abstract):
59
55
  raise TypeError(obj)
60
56
 
61
57
 
62
- ##
58
+ #
63
59
 
64
60
 
65
61
  class SimpleStringChatSessionPrinter(StringChatSessionPrinter):
@@ -82,7 +78,7 @@ class SimpleStringChatSessionPrinter(StringChatSessionPrinter):
82
78
  self._str_printer(s)
83
79
 
84
80
 
85
- ##
81
+ #
86
82
 
87
83
 
88
84
  class MarkdownStringChatSessionPrinter(StringChatSessionPrinter):
@@ -91,4 +87,40 @@ class MarkdownStringChatSessionPrinter(StringChatSessionPrinter):
91
87
  if not s:
92
88
  return
93
89
 
94
- rich_console.Console().print(rich_markdown.Markdown(s))
90
+ rich.Console().print(rich.Markdown(s))
91
+
92
+
93
+ ##
94
+
95
+
96
+ class StreamPrinter(lang.ExitStacked, lang.Abstract):
97
+ @abc.abstractmethod
98
+ def feed(self, s: str) -> None:
99
+ raise NotImplementedError
100
+
101
+
102
+ #
103
+
104
+
105
+ class SimpleStreamPrinter(StreamPrinter):
106
+ def feed(self, s: str) -> None:
107
+ print(s, end='', flush=True)
108
+
109
+ def _exit_contexts(self) -> None:
110
+ super()._exit_contexts()
111
+ print(flush=True)
112
+
113
+
114
+ #
115
+
116
+
117
+ class MarkdownStreamPrinter(StreamPrinter):
118
+ def __init__(self) -> None:
119
+ super().__init__()
120
+
121
+ def _enter_contexts(self) -> None:
122
+ super()._enter_contexts()
123
+ self._ir: rich.MarkdownLiveStream = self._enter_context(rich.IncrementalMarkdownLiveStream())
124
+
125
+ def feed(self, s: str) -> None:
126
+ self._ir.feed(s)
@@ -9,6 +9,9 @@ from .base import DEFAULT_CHAT_MODEL_BACKEND
9
9
  from .base import ChatOptions
10
10
  from .base import ChatSession
11
11
  from .printing import ChatSessionPrinter
12
+ from .printing import MarkdownStreamPrinter
13
+ from .printing import SimpleStreamPrinter
14
+ from .printing import StreamPrinter
12
15
  from .state import ChatStateManager
13
16
  from .tools import ToolUseExecutor
14
17
 
@@ -81,13 +84,20 @@ class PromptChatSession(ChatSession['PromptChatSession.Config']):
81
84
  (self._chat_options or []),
82
85
  ))).v as st_resp:
83
86
  lst: list[str] = []
84
- async for o in st_resp:
85
- if o:
86
- c = check.isinstance(check.single(check.single(o.choices).deltas), mc.ContentAiChoiceDelta).c
87
- if c is not None:
88
- print(check.isinstance(c, str), end='', flush=True)
89
- lst.append(check.isinstance(c, str))
90
- print()
87
+
88
+ sp_cls: type[StreamPrinter]
89
+ if self._config.markdown:
90
+ sp_cls = MarkdownStreamPrinter
91
+ else:
92
+ sp_cls = SimpleStreamPrinter
93
+ with sp_cls() as sp:
94
+ async for o in st_resp:
95
+ if o:
96
+ c = check.isinstance(check.single(check.single(o.choices).deltas), mc.ContentAiChoiceDelta).c # noqa
97
+ if c is not None:
98
+ s = check.isinstance(c, str)
99
+ sp.feed(s)
100
+ lst.append(s)
91
101
 
92
102
  resp_m = mc.AiMessage(''.join(lst))
93
103
  new_chat.append(resp_m)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ommlds
3
- Version: 0.0.0.dev460
3
+ Version: 0.0.0.dev461
4
4
  Summary: ommlds
5
5
  Author: wrmsr
6
6
  License-Expression: BSD-3-Clause
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Python: >=3.13
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
- Requires-Dist: omdev==0.0.0.dev460
18
- Requires-Dist: omlish==0.0.0.dev460
17
+ Requires-Dist: omdev==0.0.0.dev461
18
+ Requires-Dist: omlish==0.0.0.dev461
19
19
  Provides-Extra: all
20
20
  Requires-Dist: llama-cpp-python~=0.3; extra == "all"
21
21
  Requires-Dist: mlx~=0.29; extra == "all"
@@ -91,8 +91,8 @@ ommlds/cli/sessions/chat/base.py,sha256=GlDBXZ-KymSokNl1a7uwX1abswmRE67Q0zOIHjhZ
91
91
  ommlds/cli/sessions/chat/code.py,sha256=6hnjibVMTxSUciIIsDPsLHLGMlJNNUZtVQJxFkpi8sM,4269
92
92
  ommlds/cli/sessions/chat/inject.py,sha256=uF-QJvONu5sntXxaEu5KTYy2MUaSY8c5oJz0HpK3c7E,2621
93
93
  ommlds/cli/sessions/chat/interactive.py,sha256=gurYiDCQSY_5llcE75zvEbpVp77AbKSfgY243Z68bLw,2039
94
- ommlds/cli/sessions/chat/printing.py,sha256=b1HyripqYnRobLyTPgRidcDLvxIpyqPzgUMiXdklBGE,2327
95
- ommlds/cli/sessions/chat/prompt.py,sha256=T2h04r9LYA9urYKQZZldoT0Jon_jpKgcbQmtS9xquj8,4915
94
+ ommlds/cli/sessions/chat/printing.py,sha256=3f6icLamt7Wd7oiTshGVnIgC5YAsx_CBvZ4QH_7_mFs,2921
95
+ ommlds/cli/sessions/chat/prompt.py,sha256=tB8Wsy1FYXU6Gq-xOUTVpk8PVAu03mh7lcXf7xO7uJ4,5288
96
96
  ommlds/cli/sessions/chat/state.py,sha256=CjYkcpZ4fEBE0kPl1g101EDzq0MKy6S6E84dfDhwzcQ,2649
97
97
  ommlds/cli/sessions/chat/tools.py,sha256=dj6ADr6RIJnoIKH5wxRLGkgKAfZ_TtnqNLQ6uO-1Gfg,2325
98
98
  ommlds/cli/sessions/completion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -325,9 +325,9 @@ ommlds/wiki/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
325
325
  ommlds/wiki/utils/io.py,sha256=UKgDJGtmpnWvIqVd2mJc2QNPOqlToEY1GEveNp6_pMo,7088
326
326
  ommlds/wiki/utils/progress.py,sha256=EhvKcMFYtsarCQhIahlO6f0SboyAKP3UwUyrnVnP-Vk,3222
327
327
  ommlds/wiki/utils/xml.py,sha256=vVV8Ctn13aaRM9eYfs9Wd6rHn5WOCEUzQ44fIhOvJdg,3754
328
- ommlds-0.0.0.dev460.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
329
- ommlds-0.0.0.dev460.dist-info/METADATA,sha256=5845ATkqi5W-P5CrEj6n1JPkkp-cQ8CypPhcTMRzBfw,3224
330
- ommlds-0.0.0.dev460.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
331
- ommlds-0.0.0.dev460.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
332
- ommlds-0.0.0.dev460.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
333
- ommlds-0.0.0.dev460.dist-info/RECORD,,
328
+ ommlds-0.0.0.dev461.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
329
+ ommlds-0.0.0.dev461.dist-info/METADATA,sha256=ictJNO5iWFoU9TN6EDbf_r6HMeWvbLYsr-n0zf7-cSg,3224
330
+ ommlds-0.0.0.dev461.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
331
+ ommlds-0.0.0.dev461.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
332
+ ommlds-0.0.0.dev461.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
333
+ ommlds-0.0.0.dev461.dist-info/RECORD,,