ommlds 0.0.0.dev495__py3-none-any.whl → 0.0.0.dev496__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.
- ommlds/cli/backends/inject.py +2 -4
- ommlds/cli/content/messages.py +1 -1
- ommlds/cli/sessions/chat/drivers/user/inject.py +3 -2
- ommlds/minichain/__init__.py +67 -31
- ommlds/minichain/_dataclasses.py +2234 -1118
- ommlds/minichain/backends/impls/anthropic/protocol.py +2 -2
- ommlds/minichain/backends/impls/cerebras/protocol.py +2 -2
- ommlds/minichain/backends/impls/google/tools.py +2 -2
- ommlds/minichain/backends/impls/groq/protocol.py +2 -2
- ommlds/minichain/backends/impls/ollama/protocol.py +2 -2
- ommlds/minichain/backends/impls/openai/format.py +2 -2
- ommlds/minichain/chat/messages.py +22 -25
- ommlds/minichain/chat/templating.py +1 -1
- ommlds/minichain/content/__init__.py +9 -2
- ommlds/minichain/content/_marshal.py +159 -48
- ommlds/minichain/content/code.py +17 -0
- ommlds/minichain/content/dynamic.py +12 -0
- ommlds/minichain/content/images.py +3 -2
- ommlds/minichain/content/json.py +3 -2
- ommlds/minichain/content/namespaces.py +9 -0
- ommlds/minichain/content/placeholders.py +11 -9
- ommlds/minichain/content/quote.py +17 -0
- ommlds/minichain/content/raw.py +49 -0
- ommlds/minichain/content/section.py +14 -0
- ommlds/minichain/content/sequence.py +9 -4
- ommlds/minichain/content/{simple.py → standard.py} +3 -13
- ommlds/minichain/content/tag.py +4 -4
- ommlds/minichain/content/templates.py +14 -0
- ommlds/minichain/content/text.py +3 -2
- ommlds/minichain/content/transform/base.py +63 -0
- ommlds/minichain/content/transform/interleave.py +68 -0
- ommlds/minichain/content/transform/materialize.py +110 -0
- ommlds/minichain/content/{prepare.py → transform/prepare.py} +10 -11
- ommlds/minichain/content/transform/squeeze.py +59 -0
- ommlds/minichain/content/{transforms → transform}/stringify.py +0 -6
- ommlds/minichain/content/types.py +5 -17
- ommlds/minichain/lib/todo/tools/write.py +2 -1
- ommlds/minichain/tools/execution/errorhandling.py +2 -2
- ommlds/minichain/tools/execution/errors.py +2 -2
- ommlds/minichain/tools/jsonschema.py +2 -2
- ommlds/minichain/tools/reflect.py +3 -3
- ommlds/minichain/tools/types.py +11 -14
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/METADATA +4 -4
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/RECORD +50 -46
- ommlds/cli/sessions/chat/interfaces/bare/user.py +0 -31
- ommlds/minichain/content/cancontent.py +0 -32
- ommlds/minichain/content/materialize.py +0 -173
- ommlds/minichain/content/transforms/base.py +0 -46
- ommlds/minichain/content/transforms/interleave.py +0 -77
- ommlds/minichain/content/transforms/squeeze.py +0 -72
- /ommlds/minichain/content/{transforms → transform}/__init__.py +0 -0
- /ommlds/minichain/content/{transforms → transform}/strings.py +0 -0
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/top_level.txt +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import typing as ta
|
|
2
|
-
|
|
3
|
-
from omlish import dataclasses as dc
|
|
4
|
-
from omlish import dispatch
|
|
5
|
-
from omlish import lang
|
|
6
|
-
|
|
7
|
-
from ..cancontent import CanContent
|
|
8
|
-
from ..sequence import BlockContent
|
|
9
|
-
from ..sequence import InlineContent
|
|
10
|
-
from ..types import Content
|
|
11
|
-
from ..types import ExtendedContent
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ContentInterleaver:
|
|
18
|
-
def __init__(
|
|
19
|
-
self,
|
|
20
|
-
*,
|
|
21
|
-
separator: Content | None = None,
|
|
22
|
-
sequence_separator: Content | None = None,
|
|
23
|
-
inline_separator: Content | None = None,
|
|
24
|
-
block_separator: Content | None = None,
|
|
25
|
-
) -> None:
|
|
26
|
-
super().__init__()
|
|
27
|
-
|
|
28
|
-
self._sequence_separator = sequence_separator if sequence_separator is not None else separator
|
|
29
|
-
self._inline_separator = inline_separator if inline_separator is not None else separator
|
|
30
|
-
self._block_separator = block_separator if block_separator is not None else separator
|
|
31
|
-
|
|
32
|
-
def _interleave(self, l: ta.Iterable[CanContent], separator: Content | None) -> ta.Sequence[Content]:
|
|
33
|
-
cs: ta.Iterable[Content] = map(self.interleave, l)
|
|
34
|
-
if separator is not None:
|
|
35
|
-
cs = lang.interleave(cs, separator)
|
|
36
|
-
return list(cs)
|
|
37
|
-
|
|
38
|
-
@dispatch.method()
|
|
39
|
-
def interleave(self, c: CanContent) -> Content:
|
|
40
|
-
raise TypeError(c)
|
|
41
|
-
|
|
42
|
-
@interleave.register
|
|
43
|
-
def interleave_str(self, c: str) -> Content:
|
|
44
|
-
return c
|
|
45
|
-
|
|
46
|
-
@interleave.register
|
|
47
|
-
def interleave_sequence(self, c: ta.Sequence) -> Content:
|
|
48
|
-
return self._interleave(c, self._sequence_separator)
|
|
49
|
-
|
|
50
|
-
@interleave.register
|
|
51
|
-
def interleave_extended_content(self, c: ExtendedContent) -> Content:
|
|
52
|
-
# FIXME:
|
|
53
|
-
return c
|
|
54
|
-
|
|
55
|
-
@interleave.register
|
|
56
|
-
def interleave_inline_content(self, c: InlineContent) -> Content:
|
|
57
|
-
return dc.replace(c, l=self._interleave(c.l, self._inline_separator))
|
|
58
|
-
|
|
59
|
-
@interleave.register
|
|
60
|
-
def interleave_block_content(self, c: BlockContent) -> Content:
|
|
61
|
-
return dc.replace(c, l=self._interleave(c.l, self._block_separator))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def interleave_content(
|
|
65
|
-
c: Content,
|
|
66
|
-
*,
|
|
67
|
-
separator: Content | None = None,
|
|
68
|
-
sequence_separator: Content | None = None,
|
|
69
|
-
inline_separator: Content | None = None,
|
|
70
|
-
block_separator: Content | None = None,
|
|
71
|
-
) -> Content:
|
|
72
|
-
return ContentInterleaver(
|
|
73
|
-
separator=separator,
|
|
74
|
-
sequence_separator=sequence_separator,
|
|
75
|
-
inline_separator=inline_separator,
|
|
76
|
-
block_separator=block_separator,
|
|
77
|
-
).interleave(c)
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import typing as ta
|
|
2
|
-
|
|
3
|
-
from omlish import dataclasses as dc
|
|
4
|
-
from omlish import dispatch
|
|
5
|
-
|
|
6
|
-
from ..sequence import SequenceContent
|
|
7
|
-
from ..text import TextContent
|
|
8
|
-
from ..types import Content
|
|
9
|
-
from ..types import SingleContent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class ContentSqueezer:
|
|
16
|
-
def __init__(
|
|
17
|
-
self,
|
|
18
|
-
*,
|
|
19
|
-
strip_strings: bool = False,
|
|
20
|
-
) -> None:
|
|
21
|
-
super().__init__()
|
|
22
|
-
|
|
23
|
-
self._strip_strings = strip_strings
|
|
24
|
-
|
|
25
|
-
@dispatch.method()
|
|
26
|
-
def squeeze(self, c: Content) -> ta.Iterable[SingleContent]:
|
|
27
|
-
raise TypeError(c)
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
@squeeze.register
|
|
32
|
-
def squeeze_str(self, c: str) -> ta.Iterable[SingleContent]:
|
|
33
|
-
if self._strip_strings:
|
|
34
|
-
c = c.strip()
|
|
35
|
-
|
|
36
|
-
if c:
|
|
37
|
-
yield c
|
|
38
|
-
|
|
39
|
-
@squeeze.register
|
|
40
|
-
def squeeze_sequence(self, c: ta.Sequence) -> ta.Iterable[SingleContent]:
|
|
41
|
-
for e in c:
|
|
42
|
-
yield from self.squeeze(e)
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
@squeeze.register
|
|
47
|
-
def squeeze_single_content(self, c: SingleContent) -> ta.Iterable[SingleContent]:
|
|
48
|
-
return [c]
|
|
49
|
-
|
|
50
|
-
@squeeze.register
|
|
51
|
-
def squeeze_text_content(self, c: TextContent) -> ta.Iterable[SingleContent]:
|
|
52
|
-
if self._strip_strings:
|
|
53
|
-
if (ss := c.s.strip()) != c.s:
|
|
54
|
-
c = dc.replace(c, s=ss)
|
|
55
|
-
|
|
56
|
-
if c.s:
|
|
57
|
-
yield c.s
|
|
58
|
-
|
|
59
|
-
@squeeze.register
|
|
60
|
-
def squeeze_sequence_content(self, c: SequenceContent) -> ta.Iterable[SingleContent]:
|
|
61
|
-
for e in c.l:
|
|
62
|
-
yield from self.squeeze(e)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def squeeze_content(
|
|
66
|
-
c: Content,
|
|
67
|
-
*,
|
|
68
|
-
strip_strings: bool = False,
|
|
69
|
-
) -> ta.Sequence[SingleContent]:
|
|
70
|
-
return list(ContentSqueezer(
|
|
71
|
-
strip_strings=strip_strings,
|
|
72
|
-
).squeeze(c))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|