ommlds 0.0.0.dev332__py3-none-any.whl → 0.0.0.dev334__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 (36) hide show
  1. ommlds/backends/tinygrad/models/llama3/__main__.py +1 -1
  2. ommlds/backends/tinygrad/models/llama3/attention.py +62 -27
  3. ommlds/backends/tinygrad/models/llama3/{repl.py → cli.py} +56 -22
  4. ommlds/backends/tinygrad/models/llama3/loading.py +25 -20
  5. ommlds/backends/tinygrad/models/llama3/transformer.py +5 -7
  6. ommlds/cli/main.py +1 -1
  7. ommlds/cli/sessions/chat.py +1 -2
  8. ommlds/cli/state.py +1 -1
  9. ommlds/minichain/__init__.py +91 -46
  10. ommlds/minichain/_typedvalues.py +93 -0
  11. ommlds/minichain/backends/tinygrad/chat.py +1 -1
  12. ommlds/minichain/backends/transformers/sentence.py +2 -2
  13. ommlds/minichain/chat/messages.py +44 -2
  14. ommlds/minichain/chat/metadata.py +16 -0
  15. ommlds/minichain/content/{marshal.py → _marshal.py} +17 -6
  16. ommlds/minichain/content/content.py +0 -6
  17. ommlds/minichain/content/images.py +2 -2
  18. ommlds/minichain/content/list.py +15 -0
  19. ommlds/minichain/content/metadata.py +16 -0
  20. ommlds/minichain/content/simple.py +38 -0
  21. ommlds/minichain/content/text.py +12 -0
  22. ommlds/minichain/content/transforms.py +16 -2
  23. ommlds/minichain/metadata.py +48 -0
  24. ommlds/minichain/services/_marshal.py +48 -6
  25. ommlds/minichain/services/_typedvalues.py +0 -33
  26. ommlds/minichain/services/requests.py +5 -2
  27. ommlds/minichain/services/responses.py +5 -2
  28. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/METADATA +3 -3
  29. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/RECORD +36 -29
  30. /ommlds/minichain/chat/{marshal.py → _marshal.py} +0 -0
  31. /ommlds/minichain/llms/{marshal.py → _marshal.py} +0 -0
  32. /ommlds/minichain/tools/{marshal.py → _marshal.py} +0 -0
  33. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/WHEEL +0 -0
  34. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/entry_points.txt +0 -0
  35. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/licenses/LICENSE +0 -0
  36. {ommlds-0.0.0.dev332.dist-info → ommlds-0.0.0.dev334.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,93 @@
1
+ import operator
2
+ import typing as ta
3
+
4
+ from omlish import check
5
+ from omlish import dataclasses as dc
6
+ from omlish import marshal as msh
7
+ from omlish import reflect as rfl
8
+ from omlish import typedvalues as tv
9
+ from omlish.funcs import match as mfs
10
+ from omlish.typedvalues.marshal import build_typed_values_marshaler
11
+ from omlish.typedvalues.marshal import build_typed_values_unmarshaler
12
+
13
+
14
+ ##
15
+
16
+
17
+ @dc.dataclass()
18
+ class _TypedValuesFieldMarshalerFactory(msh.MarshalerFactoryMatchClass):
19
+ tvs_rty: rfl.Type
20
+
21
+ @mfs.simple(lambda _, ctx, rty: True)
22
+ def _build(self, ctx: msh.MarshalContext, rty: rfl.Type) -> msh.Marshaler:
23
+ return build_typed_values_marshaler(ctx, self.tvs_rty)
24
+
25
+
26
+ @dc.dataclass()
27
+ class _TypedValuesFieldUnmarshalerFactory(msh.UnmarshalerFactoryMatchClass):
28
+ tvs_rty: rfl.Type
29
+
30
+ @mfs.simple(lambda _, ctx, rty: True)
31
+ def _build(self, ctx: msh.UnmarshalContext, rty: rfl.Type) -> msh.Unmarshaler:
32
+ return build_typed_values_unmarshaler(ctx, self.tvs_rty)
33
+
34
+
35
+ ##
36
+
37
+
38
+ def _tv_field_coercer(
39
+ tvc: type[tv.TypedValue] | tuple[type[tv.TypedValue], ...],
40
+ ) -> ta.Callable[[ta.Sequence], tv.TypedValues]:
41
+ if isinstance(tvc, tuple):
42
+ check.arg(all(issubclass(e, tv.TypedValue) for e in tvc))
43
+ else:
44
+ check.issubclass(tvc, tv.TypedValue)
45
+
46
+ def inner(seq):
47
+ return tv.TypedValues(*[
48
+ check.isinstance(e, tvc)
49
+ for e in check.isinstance(seq, ta.Sequence)
50
+ ])
51
+
52
+ return inner
53
+
54
+
55
+ def _tv_field_repr(tvs: tv.TypedValues) -> str | None:
56
+ if not tvs:
57
+ return None
58
+
59
+ return repr(list(tvs))
60
+
61
+
62
+ def _tv_field_metadata(
63
+ tvc: ta.Any,
64
+ *,
65
+ marshal_name: str | None = None,
66
+ ) -> ta.Mapping:
67
+ tvc_rty = rfl.type_(tvc)
68
+
69
+ ct: ta.Any
70
+ if isinstance(tvc_rty, type):
71
+ ct = check.issubclass(tvc, tv.TypedValue)
72
+ elif isinstance(tvc_rty, rfl.Union):
73
+ ct = tuple(check.issubclass(check.not_none(rfl.get_concrete_type(a)), tv.TypedValue) for a in tvc_rty.args)
74
+ else:
75
+ raise TypeError(tvc_rty)
76
+
77
+ tvs_rty = rfl.type_(tv.TypedValues[tvc])
78
+
79
+ return {
80
+ **dc.extra_field_params(
81
+ coerce=_tv_field_coercer(ct),
82
+ repr_fn=_tv_field_repr,
83
+ ),
84
+
85
+ msh.FieldMetadata: msh.FieldMetadata(
86
+ name=marshal_name,
87
+ options=msh.FieldOptions(
88
+ omit_if=operator.not_,
89
+ ),
90
+ marshaler_factory=_TypedValuesFieldMarshalerFactory(tvs_rty),
91
+ unmarshaler_factory=_TypedValuesFieldUnmarshalerFactory(tvs_rty),
92
+ ),
93
+ }
@@ -36,7 +36,7 @@ class TinygradLlama3ChatService(ChatService, lang.ExitStacked):
36
36
  def _load_model(self) -> tgl3.Llama3Llm:
37
37
  check.not_none(self._exit_stack)
38
38
 
39
- from ....backends.tinygrad.models.llama3.repl import fetch_model
39
+ from ....backends.tinygrad.models.llama3.fetch import fetch_model
40
40
  model = fetch_model(self._size)
41
41
 
42
42
  llm = tgl3.Llama3Llm(
@@ -4,7 +4,7 @@ import sentence_transformers as stfm
4
4
 
5
5
  from ...configs import Config
6
6
  from ...configs import consume_configs
7
- from ...content.images import Image
7
+ from ...content.images import ImageContent
8
8
  from ...standard import ModelPath
9
9
  from ...vectors.embeddings import EmbeddingRequest
10
10
  from ...vectors.embeddings import EmbeddingResponse
@@ -40,7 +40,7 @@ class SentenceTransformersEmbeddingService(EmbeddingService):
40
40
  v = request.v
41
41
  if isinstance(v, str):
42
42
  obj = v
43
- elif isinstance(v, Image):
43
+ elif isinstance(v, ImageContent):
44
44
  obj = v.i
45
45
  else:
46
46
  raise TypeError(v)
@@ -1,19 +1,48 @@
1
+ import operator
1
2
  import typing as ta
2
3
 
4
+ from omlish import check
3
5
  from omlish import dataclasses as dc
4
6
  from omlish import dispatch
5
7
  from omlish import lang
8
+ from omlish import marshal as msh
9
+ from omlish import typedvalues as tv
6
10
 
11
+ from .._typedvalues import _tv_field_metadata
7
12
  from ..content.content import Content
8
13
  from ..content.transforms import ContentTransform
14
+ from ..metadata import MetadataContainer
9
15
  from ..tools.types import ToolExecRequest
16
+ from .metadata import MessageMetadatas
10
17
 
11
18
 
12
19
  ##
13
20
 
14
21
 
15
- class Message(lang.Abstract, lang.Sealed):
16
- pass
22
+ @dc.dataclass(frozen=True)
23
+ class Message( # noqa
24
+ MetadataContainer[MessageMetadatas],
25
+ lang.Abstract,
26
+ lang.Sealed,
27
+ ):
28
+ _metadata: ta.Sequence[MessageMetadatas] = dc.field(
29
+ default=(),
30
+ kw_only=True,
31
+ metadata=_tv_field_metadata(
32
+ MessageMetadatas,
33
+ marshal_name='metadata',
34
+ ),
35
+ )
36
+
37
+ @property
38
+ def metadata(self) -> tv.TypedValues[MessageMetadatas]:
39
+ return check.isinstance(self._metadata, tv.TypedValues)
40
+
41
+ def with_metadata(self, *mds: MessageMetadatas, override: bool = False) -> ta.Self:
42
+ return dc.replace(self, _metadata=tv.TypedValues(*self._metadata, *mds, override=override))
43
+
44
+
45
+ #
17
46
 
18
47
 
19
48
  @dc.dataclass(frozen=True)
@@ -21,18 +50,31 @@ class SystemMessage(Message, lang.Final):
21
50
  s: str
22
51
 
23
52
 
53
+ #
54
+
55
+
24
56
  @dc.dataclass(frozen=True)
57
+ @msh.update_fields_metadata(['name'], omit_if=operator.not_)
25
58
  class UserMessage(Message, lang.Final):
26
59
  c: Content
60
+
27
61
  name: str | None = dc.xfield(None, repr_fn=dc.opt_repr)
28
62
 
29
63
 
64
+ #
65
+
66
+
30
67
  @dc.dataclass(frozen=True)
68
+ @msh.update_fields_metadata(['tool_exec_requests'], omit_if=operator.not_)
31
69
  class AiMessage(Message, lang.Final):
32
70
  s: str | None = dc.xfield(None, repr_fn=dc.opt_repr)
71
+
33
72
  tool_exec_requests: ta.Sequence['ToolExecRequest'] | None = dc.xfield(None, repr_fn=dc.opt_repr)
34
73
 
35
74
 
75
+ #
76
+
77
+
36
78
  @dc.dataclass(frozen=True)
37
79
  class ToolExecResultMessage(Message, lang.Final):
38
80
  id: str
@@ -0,0 +1,16 @@
1
+ import typing as ta
2
+
3
+ from omlish import lang
4
+
5
+ from ..metadata import CommonMetadata
6
+ from ..metadata import Metadata
7
+
8
+
9
+ ##
10
+
11
+
12
+ class MessageMetadata(Metadata, lang.Abstract):
13
+ pass
14
+
15
+
16
+ MessageMetadatas: ta.TypeAlias = MessageMetadata | CommonMetadata
@@ -10,7 +10,9 @@ from omlish.funcs import match as mfs
10
10
  from .content import Content
11
11
  from .content import ExtendedContent
12
12
  from .content import SingleContent
13
- from .images import Image
13
+ from .images import ImageContent # noqa
14
+ from .list import ListContent # noqa
15
+ from .text import TextContent # noqa
14
16
 
15
17
 
16
18
  ##
@@ -75,12 +77,12 @@ class _ContentUnmarshalerFactory(msh.UnmarshalerFactoryMatchClass):
75
77
  ##
76
78
 
77
79
 
78
- class _ImageMarshaler(msh.Marshaler):
80
+ class _ImageContentMarshaler(msh.Marshaler):
79
81
  def marshal(self, ctx: msh.MarshalContext, o: ta.Any) -> msh.Value:
80
82
  raise NotImplementedError
81
83
 
82
84
 
83
- class _ImageUnmarshaler(msh.Unmarshaler):
85
+ class _ImageContentUnmarshaler(msh.Unmarshaler):
84
86
  def unmarshal(self, ctx: msh.UnmarshalContext, v: msh.Value) -> ta.Any:
85
87
  raise NotImplementedError
86
88
 
@@ -90,15 +92,24 @@ class _ImageUnmarshaler(msh.Unmarshaler):
90
92
 
91
93
  @lang.static_init
92
94
  def _install_standard_marshalling() -> None:
93
- extended_content_poly = msh.polymorphism_from_subclasses(ExtendedContent, naming=msh.Naming.SNAKE)
95
+ extended_content_poly = msh.Polymorphism(
96
+ ExtendedContent,
97
+ [
98
+ msh.Impl(ImageContent, 'image'),
99
+ msh.Impl(ListContent, 'list'),
100
+ msh.Impl(TextContent, 'text'),
101
+ ],
102
+ )
103
+
94
104
  msh.install_standard_factories(
95
105
  msh.PolymorphismMarshalerFactory(extended_content_poly),
96
- msh.TypeMapMarshalerFactory({Image: _ImageMarshaler()}),
106
+ msh.TypeMapMarshalerFactory({ImageContent: _ImageContentMarshaler()}),
97
107
  _ContentMarshalerFactory(),
98
108
  )
109
+
99
110
  msh.install_standard_factories(
100
111
  msh.PolymorphismUnmarshalerFactory(extended_content_poly),
101
- msh.TypeMapUnmarshalerFactory({Image: _ImageUnmarshaler()}),
112
+ msh.TypeMapUnmarshalerFactory({ImageContent: _ImageContentUnmarshaler()}),
102
113
  _ContentUnmarshalerFactory(),
103
114
  )
104
115
 
@@ -1,9 +1,3 @@
1
- """
2
- TODO:
3
- - metadata?
4
- - ContentDetail, TypedValues as RequestOption
5
- - ListOfContent? what to name
6
- """
7
1
  import typing as ta
8
2
 
9
3
  from omlish import lang
@@ -8,7 +8,7 @@ import typing as ta
8
8
  from omlish import dataclasses as dc
9
9
  from omlish import lang
10
10
 
11
- from .content import ExtendedContent
11
+ from .simple import SimpleExtendedContent
12
12
 
13
13
 
14
14
  if ta.TYPE_CHECKING:
@@ -21,5 +21,5 @@ else:
21
21
 
22
22
 
23
23
  @dc.dataclass(frozen=True)
24
- class Image(ExtendedContent, lang.Final):
24
+ class ImageContent(SimpleExtendedContent, lang.Final):
25
25
  i: 'pimg.Image' = dc.field()
@@ -0,0 +1,15 @@
1
+ import typing as ta
2
+
3
+ from omlish import dataclasses as dc
4
+ from omlish import lang
5
+
6
+ from .content import Content
7
+ from .simple import SimpleExtendedContent
8
+
9
+
10
+ ##
11
+
12
+
13
+ @dc.dataclass(frozen=True)
14
+ class ListContent(SimpleExtendedContent, lang.Final):
15
+ l: ta.Sequence[Content]
@@ -0,0 +1,16 @@
1
+ import typing as ta
2
+
3
+ from omlish import lang
4
+
5
+ from ..metadata import CommonMetadata
6
+ from ..metadata import Metadata
7
+
8
+
9
+ ##
10
+
11
+
12
+ class ContentMetadata(Metadata, lang.Abstract):
13
+ pass
14
+
15
+
16
+ ContentMetadatas: ta.TypeAlias = ContentMetadata | CommonMetadata
@@ -0,0 +1,38 @@
1
+ import typing as ta
2
+
3
+ from omlish import check
4
+ from omlish import dataclasses as dc
5
+ from omlish import lang
6
+ from omlish import typedvalues as tv
7
+
8
+ from .._typedvalues import _tv_field_metadata
9
+ from ..metadata import MetadataContainer
10
+ from .content import ExtendedContent
11
+ from .metadata import ContentMetadatas
12
+
13
+
14
+ ##
15
+
16
+
17
+ @dc.dataclass(frozen=True)
18
+ class SimpleExtendedContent( # noqa
19
+ MetadataContainer[ContentMetadatas],
20
+ ExtendedContent,
21
+ lang.Abstract,
22
+ lang.PackageSealed,
23
+ ):
24
+ _metadata: ta.Sequence[ContentMetadatas] = dc.field(
25
+ default=(),
26
+ kw_only=True,
27
+ metadata=_tv_field_metadata(
28
+ ContentMetadatas,
29
+ marshal_name='metadata',
30
+ ),
31
+ )
32
+
33
+ @property
34
+ def metadata(self) -> tv.TypedValues[ContentMetadatas]:
35
+ return check.isinstance(self._metadata, tv.TypedValues)
36
+
37
+ def with_metadata(self, *mds: ContentMetadatas, override: bool = False) -> ta.Self:
38
+ return dc.replace(self, _metadata=tv.TypedValues(*self._metadata, *mds, override=override))
@@ -0,0 +1,12 @@
1
+ from omlish import dataclasses as dc
2
+ from omlish import lang
3
+
4
+ from .simple import SimpleExtendedContent
5
+
6
+
7
+ ##
8
+
9
+
10
+ @dc.dataclass(frozen=True)
11
+ class TextContent(SimpleExtendedContent, lang.Final):
12
+ s: str
@@ -5,7 +5,9 @@ from omlish import dataclasses as dc
5
5
  from omlish import dispatch
6
6
  from omlish import lang
7
7
 
8
- from .images import Image
8
+ from .images import ImageContent
9
+ from .list import ListContent
10
+ from .text import TextContent
9
11
 
10
12
 
11
13
  T = ta.TypeVar('T')
@@ -19,6 +21,8 @@ class ContentTransform(lang.Abstract):
19
21
  def apply(self, o: T) -> T:
20
22
  raise TypeError(o)
21
23
 
24
+ #
25
+
22
26
  @apply.register # noqa
23
27
  def apply_str(self, s: str) -> str:
24
28
  return s
@@ -27,10 +31,20 @@ class ContentTransform(lang.Abstract):
27
31
  def apply_sequence(self, l: collections.abc.Sequence[T]) -> collections.abc.Sequence[T]:
28
32
  return [self.apply(e) for e in l]
29
33
 
34
+ #
35
+
30
36
  @apply.register
31
- def apply_image(self, c: Image) -> Image:
37
+ def apply_image(self, c: ImageContent) -> ImageContent:
32
38
  return c
33
39
 
40
+ @apply.register
41
+ def apply_list(self, c: ListContent) -> ListContent:
42
+ return dc.replace(c, l=self.apply(c.l))
43
+
44
+ @apply.register
45
+ def apply_text(self, c: TextContent) -> ListContent:
46
+ return dc.replace(c, s=self.apply(c.s))
47
+
34
48
 
35
49
  ##
36
50
 
@@ -0,0 +1,48 @@
1
+ import abc
2
+ import typing as ta
3
+ import uuid
4
+
5
+ from omlish import lang
6
+ from omlish import typedvalues as tv
7
+
8
+
9
+ ##
10
+
11
+
12
+ class Metadata(tv.TypedValue, lang.Abstract, lang.PackageSealed):
13
+ pass
14
+
15
+
16
+ MetadataT = ta.TypeVar('MetadataT', bound=Metadata)
17
+
18
+
19
+ #
20
+
21
+
22
+ class MetadataContainer(
23
+ tv.TypedValueGeneric[MetadataT],
24
+ lang.Abstract,
25
+ lang.PackageSealed,
26
+ ):
27
+ @property
28
+ @abc.abstractmethod
29
+ def metadata(self) -> tv.TypedValues[MetadataT]:
30
+ raise NotImplementedError
31
+
32
+ @abc.abstractmethod
33
+ def with_metadata(self, *mds: MetadataT, override: bool = False) -> ta.Self:
34
+ raise NotImplementedError
35
+
36
+
37
+ ##
38
+
39
+
40
+ class CommonMetadata(Metadata, lang.Abstract):
41
+ pass
42
+
43
+
44
+ #
45
+
46
+
47
+ class Uuid(tv.ScalarTypedValue[uuid.UUID], CommonMetadata, lang.Final):
48
+ pass
@@ -1,6 +1,7 @@
1
1
  import typing as ta
2
2
 
3
3
  from omlish import check
4
+ from omlish import collections as col
4
5
  from omlish import dataclasses as dc
5
6
  from omlish import lang
6
7
  from omlish import marshal as msh
@@ -21,9 +22,19 @@ def _is_rr_rty(rty: rfl.Type) -> bool:
21
22
  )
22
23
 
23
24
 
25
+ def _get_tv_fld(rty: rfl.Type) -> dc.Field:
26
+ flds = col.make_map_by(lambda f: f.name, dc.fields(check.not_none(rfl.get_concrete_type(rty))), strict=True)
27
+ flds.pop('v')
28
+ return check.single(flds.values())
29
+
30
+
31
+ ##
32
+
33
+
24
34
  @dc.dataclass(frozen=True)
25
35
  class _RequestResponseMarshaler(msh.Marshaler):
26
36
  rty: rfl.Type
37
+ tv_fld: dc.Field
27
38
  v_m: msh.Marshaler | None
28
39
 
29
40
  def marshal(self, ctx: msh.MarshalContext, o: ta.Any) -> msh.Value:
@@ -31,6 +42,7 @@ class _RequestResponseMarshaler(msh.Marshaler):
31
42
  tv_ta = tv.TypedValues[ta.Union[*tv_types_set]] # type: ignore
32
43
  tv_m = ctx.make(tv_ta)
33
44
  tv_v = check.isinstance(tv_m.marshal(ctx, o._typed_values), ta.Sequence) # noqa
45
+
34
46
  if self.v_m is None:
35
47
  orty: rfl.Generic = check.isinstance(rfl.type_(rfl.get_orig_class(o)), rfl.Generic)
36
48
  check.state(orty.cls in (Request, Response))
@@ -38,7 +50,11 @@ class _RequestResponseMarshaler(msh.Marshaler):
38
50
  v_v = ctx.make(v_rty).marshal(ctx, o.v)
39
51
  else:
40
52
  v_v = self.v_m.marshal(ctx, o.v)
41
- return [v_v, *tv_v]
53
+
54
+ return {
55
+ 'v': v_v,
56
+ **({lang.strip_prefix(self.tv_fld.name, '_'): tv_v} if tv_v else {}),
57
+ }
42
58
 
43
59
 
44
60
  class _RequestResponseMarshalerFactory(msh.SimpleMarshalerFactory):
@@ -56,20 +72,38 @@ class _RequestResponseMarshalerFactory(msh.SimpleMarshalerFactory):
56
72
  v_m: msh.Marshaler | None = None
57
73
  if not isinstance(v_rty, ta.TypeVar):
58
74
  v_m = ctx.make(v_rty)
59
- return _RequestResponseMarshaler(rty, v_m)
75
+ return _RequestResponseMarshaler(
76
+ rty,
77
+ _get_tv_fld(rty),
78
+ v_m,
79
+ )
80
+
81
+
82
+ #
60
83
 
61
84
 
62
85
  @dc.dataclass(frozen=True)
63
86
  class _RequestResponseUnmarshaler(msh.Unmarshaler):
64
87
  rty: rfl.Type
88
+ tv_fld: dc.Field
65
89
  v_u: msh.Unmarshaler
66
90
  tv_u: msh.Unmarshaler
67
91
 
68
92
  def unmarshal(self, ctx: msh.UnmarshalContext, v: msh.Value) -> ta.Any:
69
- check.not_isinstance(v, str)
70
- v_v, *tv_vs = check.isinstance(v, ta.Sequence)
93
+ dct = dict(check.isinstance(v, ta.Mapping))
94
+
95
+ v_v = dct.pop('v')
71
96
  v = self.v_u.unmarshal(ctx, v_v)
72
- tvs = self.tv_u.unmarshal(ctx, tv_vs)
97
+
98
+ tvs: ta.Any
99
+ if dct:
100
+ tv_vs = dct.pop(lang.strip_prefix(self.tv_fld.name, '_'))
101
+ tvs = self.tv_u.unmarshal(ctx, tv_vs)
102
+ else:
103
+ tvs = []
104
+
105
+ check.empty(dct)
106
+
73
107
  cty = rfl.get_concrete_type(self.rty)
74
108
  return cty(v, tvs) # type: ignore
75
109
 
@@ -88,7 +122,15 @@ class _RequestResponseUnmarshalerFactory(msh.SimpleUnmarshalerFactory):
88
122
  tv_ta = tv.TypedValues[ta.Union[*tv_types_set]] # type: ignore
89
123
  tv_u = ctx.make(tv_ta)
90
124
  v_u = ctx.make(v_rty)
91
- return _RequestResponseUnmarshaler(rty, v_u, tv_u)
125
+ return _RequestResponseUnmarshaler(
126
+ rty,
127
+ _get_tv_fld(rty),
128
+ v_u,
129
+ tv_u,
130
+ )
131
+
132
+
133
+ ##
92
134
 
93
135
 
94
136
  @lang.static_init
@@ -101,36 +101,3 @@ class _TypedValues(
101
101
  not isinstance(o, tvi.tv_types)
102
102
  ):
103
103
  raise _TypedValuesTypeError(o)
104
-
105
-
106
- ##
107
-
108
-
109
- def _tv_field_coercer(tvc: type[tv.TypedValue]) -> ta.Callable[[ta.Sequence], tv.TypedValues]:
110
- check.issubclass(tvc, tv.TypedValue)
111
-
112
- def inner(seq):
113
- return tv.TypedValues(*[
114
- check.isinstance(e, tvc)
115
- for e in check.isinstance(seq, ta.Sequence)
116
- ])
117
-
118
- return inner
119
-
120
-
121
- def _tv_field_repr(tvs: tv.TypedValues) -> str | None:
122
- if not tvs:
123
- return None
124
-
125
- return repr(list(tvs))
126
-
127
-
128
- def _tv_field_metadata(tvc: type[tv.TypedValue]) -> ta.Mapping:
129
- check.issubclass(tvc, tv.TypedValue)
130
-
131
- return {
132
- **dc.extra_field_params(
133
- coerce=_tv_field_coercer(tvc),
134
- repr_fn=_tv_field_repr,
135
- ),
136
- }
@@ -5,7 +5,7 @@ from omlish import dataclasses as dc
5
5
  from omlish import lang
6
6
  from omlish import typedvalues as tv
7
7
 
8
- from ._typedvalues import _tv_field_metadata
8
+ from .._typedvalues import _tv_field_metadata
9
9
  from ._typedvalues import _TypedValues
10
10
 
11
11
 
@@ -37,7 +37,10 @@ class Request( # type: ignore[type-var] # FIXME: _TypedValues param is invaria
37
37
 
38
38
  _options: ta.Sequence[RequestOptionT_co] = dc.field(
39
39
  default=(),
40
- metadata=_tv_field_metadata(RequestOption),
40
+ metadata=_tv_field_metadata(
41
+ RequestOption,
42
+ marshal_name='options',
43
+ ),
41
44
  )
42
45
 
43
46
  @property
@@ -5,7 +5,7 @@ from omlish import dataclasses as dc
5
5
  from omlish import lang
6
6
  from omlish import typedvalues as tv
7
7
 
8
- from ._typedvalues import _tv_field_metadata
8
+ from .._typedvalues import _tv_field_metadata
9
9
  from ._typedvalues import _TypedValues
10
10
 
11
11
 
@@ -37,7 +37,10 @@ class Response( # type: ignore[type-var] # FIXME: _TypedValues param is invari
37
37
 
38
38
  _outputs: ta.Sequence[ResponseOutputT_contra] = dc.field(
39
39
  default=(),
40
- metadata=_tv_field_metadata(ResponseOutput),
40
+ metadata=_tv_field_metadata(
41
+ ResponseOutput,
42
+ marshal_name='outputs',
43
+ ),
41
44
  )
42
45
 
43
46
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ommlds
3
- Version: 0.0.0.dev332
3
+ Version: 0.0.0.dev334
4
4
  Summary: ommlds
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev332
16
- Requires-Dist: omlish==0.0.0.dev332
15
+ Requires-Dist: omdev==0.0.0.dev334
16
+ Requires-Dist: omlish==0.0.0.dev334
17
17
  Provides-Extra: all
18
18
  Requires-Dist: llama-cpp-python~=0.3; extra == "all"
19
19
  Requires-Dist: mlx~=0.26; extra == "all"