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.
Files changed (56) hide show
  1. ommlds/cli/backends/inject.py +2 -4
  2. ommlds/cli/content/messages.py +1 -1
  3. ommlds/cli/sessions/chat/drivers/user/inject.py +3 -2
  4. ommlds/minichain/__init__.py +67 -31
  5. ommlds/minichain/_dataclasses.py +2234 -1118
  6. ommlds/minichain/backends/impls/anthropic/protocol.py +2 -2
  7. ommlds/minichain/backends/impls/cerebras/protocol.py +2 -2
  8. ommlds/minichain/backends/impls/google/tools.py +2 -2
  9. ommlds/minichain/backends/impls/groq/protocol.py +2 -2
  10. ommlds/minichain/backends/impls/ollama/protocol.py +2 -2
  11. ommlds/minichain/backends/impls/openai/format.py +2 -2
  12. ommlds/minichain/chat/messages.py +22 -25
  13. ommlds/minichain/chat/templating.py +1 -1
  14. ommlds/minichain/content/__init__.py +9 -2
  15. ommlds/minichain/content/_marshal.py +159 -48
  16. ommlds/minichain/content/code.py +17 -0
  17. ommlds/minichain/content/dynamic.py +12 -0
  18. ommlds/minichain/content/images.py +3 -2
  19. ommlds/minichain/content/json.py +3 -2
  20. ommlds/minichain/content/namespaces.py +9 -0
  21. ommlds/minichain/content/placeholders.py +11 -9
  22. ommlds/minichain/content/quote.py +17 -0
  23. ommlds/minichain/content/raw.py +49 -0
  24. ommlds/minichain/content/section.py +14 -0
  25. ommlds/minichain/content/sequence.py +9 -4
  26. ommlds/minichain/content/{simple.py → standard.py} +3 -13
  27. ommlds/minichain/content/tag.py +4 -4
  28. ommlds/minichain/content/templates.py +14 -0
  29. ommlds/minichain/content/text.py +3 -2
  30. ommlds/minichain/content/transform/base.py +63 -0
  31. ommlds/minichain/content/transform/interleave.py +68 -0
  32. ommlds/minichain/content/transform/materialize.py +110 -0
  33. ommlds/minichain/content/{prepare.py → transform/prepare.py} +10 -11
  34. ommlds/minichain/content/transform/squeeze.py +59 -0
  35. ommlds/minichain/content/{transforms → transform}/stringify.py +0 -6
  36. ommlds/minichain/content/types.py +5 -17
  37. ommlds/minichain/lib/todo/tools/write.py +2 -1
  38. ommlds/minichain/tools/execution/errorhandling.py +2 -2
  39. ommlds/minichain/tools/execution/errors.py +2 -2
  40. ommlds/minichain/tools/jsonschema.py +2 -2
  41. ommlds/minichain/tools/reflect.py +3 -3
  42. ommlds/minichain/tools/types.py +11 -14
  43. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/METADATA +4 -4
  44. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/RECORD +50 -46
  45. ommlds/cli/sessions/chat/interfaces/bare/user.py +0 -31
  46. ommlds/minichain/content/cancontent.py +0 -32
  47. ommlds/minichain/content/materialize.py +0 -173
  48. ommlds/minichain/content/transforms/base.py +0 -46
  49. ommlds/minichain/content/transforms/interleave.py +0 -77
  50. ommlds/minichain/content/transforms/squeeze.py +0 -72
  51. /ommlds/minichain/content/{transforms → transform}/__init__.py +0 -0
  52. /ommlds/minichain/content/{transforms → transform}/strings.py +0 -0
  53. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/WHEEL +0 -0
  54. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/entry_points.txt +0 -0
  55. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/licenses/LICENSE +0 -0
  56. {ommlds-0.0.0.dev495.dist-info → ommlds-0.0.0.dev496.dist-info}/top_level.txt +0 -0
@@ -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
  ])
@@ -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 is not None:
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)),
@@ -227,8 +227,40 @@ with _lang.auto_proxy_init(
227
227
 
228
228
  ##
229
229
 
230
- from .content.cancontent import ( # noqa
231
- CanContent,
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
- ContentPlaceholderMarker,
258
- content_placeholder,
286
+ PlaceholderContentKey,
287
+ PlaceholderContent,
259
288
  )
260
289
 
261
- from .content.prepare import ( # noqa
262
- ContentPreparer,
263
- ContentStrPreparer,
290
+ from .content.quote import ( # noqa
291
+ QuoteContent,
292
+ )
264
293
 
265
- DefaultContentPreparer,
266
- DefaultContentStrPreparer,
294
+ from .content.raw import ( # noqa
295
+ NonStrSingleRawContent,
296
+ NON_STR_SINGLE_RAW_CONTENT_TYPES,
267
297
 
268
- default_content_preparer,
269
- default_content_str_preparer,
270
- prepare_content,
271
- prepare_content_str,
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.text import ( # noqa
285
- TextContent,
324
+ from .content.templates import ( # noqa
325
+ TemplateContent,
286
326
  )
287
327
 
288
- from .content.transforms.base import ( # noqa
289
- ContentTransform,
328
+ from .content.text import ( # noqa
329
+ TextContent,
290
330
  )
291
331
 
292
332
  from .content.types import ( # noqa
293
- Content,
294
- ExtendedContent,
295
- SingleContent,
296
- SingleExtendedContent,
297
- )
333
+ BaseContent,
334
+ LeafContent,
298
335
 
299
- from .content.transforms.strings import ( # noqa
300
- StringFnContentTransform,
301
- transform_content_strings,
336
+ Content,
337
+ CONTENT_TYPES,
302
338
  )
303
339
 
304
340
  ##