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
ommlds/cli/backends/inject.py
CHANGED
|
@@ -70,9 +70,8 @@ def bind_backends(cfg: BackendConfig = BackendConfig()) -> inj.Elements:
|
|
|
70
70
|
lst.extend([
|
|
71
71
|
inj.private(
|
|
72
72
|
inj.bind(_types.BackendName, to_const=ben),
|
|
73
|
-
inj.bind(ben_bp_key, to_ctor=bp_impl, singleton=True),
|
|
73
|
+
inj.bind(ben_bp_key, to_ctor=bp_impl, singleton=True, expose=True),
|
|
74
74
|
inj.bind(bp_iface, to_key=ben_bp_key),
|
|
75
|
-
inj.expose(ben_bp_key),
|
|
76
75
|
),
|
|
77
76
|
bp_stack.push_bind(to_key=ben_bp_key),
|
|
78
77
|
])
|
|
@@ -81,8 +80,7 @@ def bind_backends(cfg: BackendConfig = BackendConfig()) -> inj.Elements:
|
|
|
81
80
|
lst.extend([
|
|
82
81
|
inj.private(
|
|
83
82
|
inj.set_binder[_types.BackendProvider]().bind(bp_stack.top),
|
|
84
|
-
inj.bind(fiw_key, to_ctor=_meta.FirstInWinsBackendProvider, singleton=True),
|
|
85
|
-
inj.expose(fiw_key),
|
|
83
|
+
inj.bind(fiw_key, to_ctor=_meta.FirstInWinsBackendProvider, singleton=True, expose=True),
|
|
86
84
|
),
|
|
87
85
|
bp_stack.push_bind(to_key=fiw_key),
|
|
88
86
|
])
|
ommlds/cli/content/messages.py
CHANGED
|
@@ -19,7 +19,7 @@ class MessageContentExtractor(lang.Abstract):
|
|
|
19
19
|
class MessageContentExtractorImpl(MessageContentExtractor):
|
|
20
20
|
def extract_message_content(self, message: 'mc.Message') -> ta.Optional['mc.Content']:
|
|
21
21
|
if isinstance(message, (mc.SystemMessage, mc.UserMessage, mc.AiMessage)):
|
|
22
|
-
if message.c
|
|
22
|
+
if message.c:
|
|
23
23
|
return check.isinstance(message.c, str)
|
|
24
24
|
else:
|
|
25
25
|
return None
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from omlish import check
|
|
1
2
|
from omlish import inject as inj
|
|
2
3
|
from omlish import lang
|
|
3
4
|
|
|
@@ -21,7 +22,7 @@ def bind_user(cfg: UserConfig = UserConfig()) -> inj.Elements:
|
|
|
21
22
|
|
|
22
23
|
if cfg.initial_system_content is not None:
|
|
23
24
|
async def add_initial_system_content(cm: '_state.ChatStateManager') -> None:
|
|
24
|
-
await cm.extend_chat([mc.SystemMessage(cfg.initial_system_content)])
|
|
25
|
+
await cm.extend_chat([mc.SystemMessage(check.not_none(cfg.initial_system_content))])
|
|
25
26
|
|
|
26
27
|
els.append(phase_callbacks().bind_item(to_fn=inj.KwargsTarget.of(
|
|
27
28
|
lambda cm: ChatPhaseCallback(ChatPhase.STARTED, lambda: add_initial_system_content(cm)),
|
|
@@ -30,7 +31,7 @@ def bind_user(cfg: UserConfig = UserConfig()) -> inj.Elements:
|
|
|
30
31
|
|
|
31
32
|
if cfg.initial_user_content is not None:
|
|
32
33
|
async def add_initial_user_content(cdg: '_driver.ChatDriverGetter') -> None:
|
|
33
|
-
await (await cdg()).send_user_messages([mc.UserMessage(cfg.initial_user_content)])
|
|
34
|
+
await (await cdg()).send_user_messages([mc.UserMessage(check.not_none(cfg.initial_user_content))])
|
|
34
35
|
|
|
35
36
|
els.append(phase_callbacks().bind_item(to_fn=inj.KwargsTarget.of(
|
|
36
37
|
lambda cdg: ChatPhaseCallback(ChatPhase.STARTED, lambda: add_initial_user_content(cdg)),
|
ommlds/minichain/__init__.py
CHANGED
|
@@ -227,8 +227,40 @@ with _lang.auto_proxy_init(
|
|
|
227
227
|
|
|
228
228
|
##
|
|
229
229
|
|
|
230
|
-
from .content.
|
|
231
|
-
|
|
230
|
+
from .content.transform.base import ( # noqa
|
|
231
|
+
ContentTransform,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
from .content.transform.materialize import ( # noqa
|
|
235
|
+
materialize_content,
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
from .content.transform.prepare import ( # noqa
|
|
239
|
+
ContentPreparer,
|
|
240
|
+
ContentStrPreparer,
|
|
241
|
+
|
|
242
|
+
DefaultContentPreparer,
|
|
243
|
+
DefaultContentStrPreparer,
|
|
244
|
+
|
|
245
|
+
default_content_preparer,
|
|
246
|
+
default_content_str_preparer,
|
|
247
|
+
prepare_content,
|
|
248
|
+
prepare_content_str,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
from .content.transform.strings import ( # noqa
|
|
252
|
+
StringFnContentTransform,
|
|
253
|
+
transform_content_strings,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
##
|
|
257
|
+
|
|
258
|
+
from .content.code import ( # noqa
|
|
259
|
+
CodeContent,
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
from .content.dynamic import ( # noqa
|
|
263
|
+
DynamicContent,
|
|
232
264
|
)
|
|
233
265
|
|
|
234
266
|
from .content.images import ( # noqa
|
|
@@ -239,10 +271,6 @@ with _lang.auto_proxy_init(
|
|
|
239
271
|
JsonContent,
|
|
240
272
|
)
|
|
241
273
|
|
|
242
|
-
from .content.materialize import ( # noqa
|
|
243
|
-
materialize_content,
|
|
244
|
-
)
|
|
245
|
-
|
|
246
274
|
from .content.metadata import ( # noqa
|
|
247
275
|
ContentMetadata,
|
|
248
276
|
ContentMetadatas,
|
|
@@ -250,55 +278,63 @@ with _lang.auto_proxy_init(
|
|
|
250
278
|
|
|
251
279
|
from .content.namespaces import ( # noqa
|
|
252
280
|
ContentNamespace,
|
|
281
|
+
NamespaceContent,
|
|
253
282
|
)
|
|
254
283
|
|
|
255
284
|
from .content.placeholders import ( # noqa
|
|
256
285
|
ContentPlaceholder,
|
|
257
|
-
|
|
258
|
-
|
|
286
|
+
PlaceholderContentKey,
|
|
287
|
+
PlaceholderContent,
|
|
259
288
|
)
|
|
260
289
|
|
|
261
|
-
from .content.
|
|
262
|
-
|
|
263
|
-
|
|
290
|
+
from .content.quote import ( # noqa
|
|
291
|
+
QuoteContent,
|
|
292
|
+
)
|
|
264
293
|
|
|
265
|
-
|
|
266
|
-
|
|
294
|
+
from .content.raw import ( # noqa
|
|
295
|
+
NonStrSingleRawContent,
|
|
296
|
+
NON_STR_SINGLE_RAW_CONTENT_TYPES,
|
|
267
297
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
298
|
+
SingleRawContent,
|
|
299
|
+
SINGLE_RAW_CONTENT_TYPES,
|
|
300
|
+
|
|
301
|
+
RawContent,
|
|
302
|
+
RAW_CONTENT_TYPES,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
from .content.section import ( # noqa
|
|
306
|
+
SectionContent,
|
|
272
307
|
)
|
|
273
308
|
|
|
274
309
|
from .content.sequence import ( # noqa
|
|
275
|
-
BlockContent,
|
|
276
|
-
InlineContent,
|
|
277
310
|
SequenceContent,
|
|
311
|
+
InlineContent,
|
|
312
|
+
BlockContent,
|
|
313
|
+
ItemListContent,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
from .content.standard import ( # noqa
|
|
317
|
+
StandardContent,
|
|
278
318
|
)
|
|
279
319
|
|
|
280
320
|
from .content.tag import ( # noqa
|
|
281
321
|
TagContent,
|
|
282
322
|
)
|
|
283
323
|
|
|
284
|
-
from .content.
|
|
285
|
-
|
|
324
|
+
from .content.templates import ( # noqa
|
|
325
|
+
TemplateContent,
|
|
286
326
|
)
|
|
287
327
|
|
|
288
|
-
from .content.
|
|
289
|
-
|
|
328
|
+
from .content.text import ( # noqa
|
|
329
|
+
TextContent,
|
|
290
330
|
)
|
|
291
331
|
|
|
292
332
|
from .content.types import ( # noqa
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
SingleContent,
|
|
296
|
-
SingleExtendedContent,
|
|
297
|
-
)
|
|
333
|
+
BaseContent,
|
|
334
|
+
LeafContent,
|
|
298
335
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
transform_content_strings,
|
|
336
|
+
Content,
|
|
337
|
+
CONTENT_TYPES,
|
|
302
338
|
)
|
|
303
339
|
|
|
304
340
|
##
|