ommlds 0.0.0.dev480__py3-none-any.whl → 0.0.0.dev503__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/.omlish-manifests.json +100 -33
- ommlds/README.md +11 -0
- ommlds/__about__.py +9 -6
- ommlds/backends/anthropic/protocol/__init__.py +13 -1
- ommlds/backends/anthropic/protocol/_dataclasses.py +1625 -0
- ommlds/backends/anthropic/protocol/sse/events.py +2 -0
- ommlds/backends/cerebras/__init__.py +7 -0
- ommlds/backends/cerebras/_dataclasses.py +4254 -0
- ommlds/backends/cerebras/_marshal.py +24 -0
- ommlds/backends/cerebras/protocol.py +312 -0
- ommlds/backends/google/protocol/__init__.py +13 -0
- ommlds/backends/google/protocol/_dataclasses.py +5997 -0
- ommlds/backends/groq/__init__.py +7 -0
- ommlds/backends/groq/_dataclasses.py +3901 -0
- ommlds/backends/groq/clients.py +9 -0
- ommlds/backends/llamacpp/logging.py +4 -1
- ommlds/backends/mlx/caching.py +7 -3
- ommlds/backends/mlx/cli.py +10 -7
- ommlds/backends/mlx/generation.py +18 -16
- ommlds/backends/mlx/limits.py +10 -6
- ommlds/backends/mlx/loading.py +7 -4
- ommlds/backends/ollama/__init__.py +7 -0
- ommlds/backends/ollama/_dataclasses.py +3488 -0
- ommlds/backends/ollama/protocol.py +3 -0
- ommlds/backends/openai/protocol/__init__.py +15 -1
- ommlds/backends/openai/protocol/_dataclasses.py +7708 -0
- ommlds/backends/tavily/__init__.py +7 -0
- ommlds/backends/tavily/_dataclasses.py +1734 -0
- ommlds/backends/transformers/__init__.py +14 -0
- ommlds/cli/__init__.py +7 -0
- ommlds/cli/_dataclasses.py +3515 -0
- ommlds/cli/backends/catalog.py +0 -5
- ommlds/cli/backends/inject.py +70 -7
- ommlds/cli/backends/meta.py +82 -0
- ommlds/cli/content/messages.py +1 -1
- ommlds/cli/inject.py +11 -3
- ommlds/cli/main.py +137 -68
- ommlds/cli/rendering/types.py +6 -0
- ommlds/cli/secrets.py +2 -1
- ommlds/cli/sessions/base.py +1 -10
- ommlds/cli/sessions/chat/configs.py +9 -17
- ommlds/cli/sessions/chat/{chat → drivers}/ai/configs.py +3 -1
- ommlds/cli/sessions/chat/drivers/ai/events.py +57 -0
- ommlds/cli/sessions/chat/{chat → drivers}/ai/inject.py +10 -3
- ommlds/cli/sessions/chat/{chat → drivers}/ai/rendering.py +1 -1
- ommlds/cli/sessions/chat/{chat → drivers}/ai/services.py +1 -1
- ommlds/cli/sessions/chat/{chat → drivers}/ai/tools.py +4 -8
- ommlds/cli/sessions/chat/{chat → drivers}/ai/types.py +9 -0
- ommlds/cli/sessions/chat/drivers/configs.py +25 -0
- ommlds/cli/sessions/chat/drivers/events/inject.py +27 -0
- ommlds/cli/sessions/chat/drivers/events/injection.py +14 -0
- ommlds/cli/sessions/chat/drivers/events/manager.py +16 -0
- ommlds/cli/sessions/chat/drivers/events/types.py +38 -0
- ommlds/cli/sessions/chat/drivers/impl.py +50 -0
- ommlds/cli/sessions/chat/drivers/inject.py +70 -0
- ommlds/cli/sessions/chat/{chat → drivers}/state/configs.py +2 -0
- ommlds/cli/sessions/chat/drivers/state/ids.py +25 -0
- ommlds/cli/sessions/chat/drivers/state/inject.py +83 -0
- ommlds/cli/sessions/chat/{chat → drivers}/state/inmemory.py +0 -4
- ommlds/cli/sessions/chat/{chat → drivers}/state/storage.py +17 -10
- ommlds/cli/sessions/chat/{chat → drivers}/state/types.py +10 -5
- ommlds/cli/sessions/chat/{tools → drivers/tools}/configs.py +2 -2
- ommlds/cli/sessions/chat/drivers/tools/confirmation.py +44 -0
- ommlds/cli/sessions/chat/drivers/tools/errorhandling.py +39 -0
- ommlds/cli/sessions/chat/{tools → drivers/tools}/execution.py +3 -4
- ommlds/cli/sessions/chat/{tools → drivers/tools}/fs/inject.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/inject.py +7 -12
- ommlds/cli/sessions/chat/{tools → drivers/tools}/injection.py +5 -5
- ommlds/cli/sessions/chat/{tools → drivers/tools}/rendering.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/todo/inject.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/tools.py +1 -1
- ommlds/cli/sessions/chat/drivers/types.py +31 -0
- ommlds/cli/sessions/chat/{chat → drivers}/user/configs.py +0 -3
- ommlds/cli/sessions/chat/drivers/user/inject.py +41 -0
- ommlds/cli/sessions/chat/facades/__init__.py +0 -0
- ommlds/cli/sessions/chat/facades/commands/__init__.py +0 -0
- ommlds/cli/sessions/chat/facades/commands/base.py +83 -0
- ommlds/cli/sessions/chat/facades/commands/configs.py +9 -0
- ommlds/cli/sessions/chat/facades/commands/inject.py +41 -0
- ommlds/cli/sessions/chat/facades/commands/injection.py +15 -0
- ommlds/cli/sessions/chat/facades/commands/manager.py +59 -0
- ommlds/cli/sessions/chat/facades/commands/simple.py +34 -0
- ommlds/cli/sessions/chat/facades/commands/types.py +13 -0
- ommlds/cli/sessions/chat/facades/configs.py +11 -0
- ommlds/cli/sessions/chat/facades/facade.py +26 -0
- ommlds/cli/sessions/chat/facades/inject.py +35 -0
- ommlds/cli/sessions/chat/facades/ui.py +34 -0
- ommlds/cli/sessions/chat/inject.py +8 -31
- ommlds/cli/sessions/chat/interfaces/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/bare/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/bare/configs.py +15 -0
- ommlds/cli/sessions/chat/interfaces/bare/inject.py +69 -0
- ommlds/cli/sessions/chat/interfaces/bare/interactive.py +49 -0
- ommlds/cli/sessions/chat/interfaces/bare/oneshot.py +21 -0
- ommlds/cli/sessions/chat/{tools/confirmation.py → interfaces/bare/tools.py} +3 -22
- ommlds/cli/sessions/chat/interfaces/base.py +13 -0
- ommlds/cli/sessions/chat/interfaces/configs.py +11 -0
- ommlds/cli/sessions/chat/interfaces/inject.py +29 -0
- ommlds/cli/sessions/chat/interfaces/textual/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/textual/app.py +310 -0
- ommlds/cli/sessions/chat/interfaces/textual/configs.py +11 -0
- ommlds/cli/sessions/chat/interfaces/textual/facades.py +19 -0
- ommlds/cli/sessions/chat/interfaces/textual/inject.py +97 -0
- ommlds/cli/sessions/chat/interfaces/textual/interface.py +24 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/__init__.py +29 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/input.tcss +53 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/markdown.tcss +7 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/messages.tcss +157 -0
- ommlds/cli/sessions/chat/interfaces/textual/tools.py +38 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/input.py +36 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/messages.py +197 -0
- ommlds/cli/sessions/chat/session.py +8 -13
- ommlds/cli/sessions/completion/configs.py +3 -4
- ommlds/cli/sessions/completion/inject.py +1 -2
- ommlds/cli/sessions/completion/session.py +4 -8
- ommlds/cli/sessions/configs.py +10 -0
- ommlds/cli/sessions/embedding/configs.py +3 -4
- ommlds/cli/sessions/embedding/inject.py +1 -2
- ommlds/cli/sessions/embedding/session.py +4 -8
- ommlds/cli/sessions/inject.py +15 -15
- ommlds/cli/state/storage.py +7 -1
- ommlds/minichain/__init__.py +161 -38
- ommlds/minichain/_dataclasses.py +20452 -0
- ommlds/minichain/_typedvalues.py +11 -4
- ommlds/minichain/backends/impls/anthropic/names.py +3 -3
- ommlds/minichain/backends/impls/anthropic/protocol.py +2 -2
- ommlds/minichain/backends/impls/anthropic/stream.py +1 -1
- ommlds/minichain/backends/impls/cerebras/__init__.py +0 -0
- ommlds/minichain/backends/impls/cerebras/chat.py +80 -0
- ommlds/minichain/backends/impls/cerebras/names.py +45 -0
- ommlds/minichain/backends/impls/cerebras/protocol.py +143 -0
- ommlds/minichain/backends/impls/cerebras/stream.py +125 -0
- ommlds/minichain/backends/impls/duckduckgo/search.py +5 -1
- ommlds/minichain/backends/impls/google/names.py +6 -0
- ommlds/minichain/backends/impls/google/stream.py +1 -1
- ommlds/minichain/backends/impls/google/tools.py +2 -2
- ommlds/minichain/backends/impls/groq/chat.py +2 -0
- ommlds/minichain/backends/impls/groq/protocol.py +2 -2
- ommlds/minichain/backends/impls/groq/stream.py +3 -1
- ommlds/minichain/backends/impls/huggingface/repos.py +1 -5
- ommlds/minichain/backends/impls/llamacpp/chat.py +6 -3
- ommlds/minichain/backends/impls/llamacpp/completion.py +7 -3
- ommlds/minichain/backends/impls/llamacpp/stream.py +6 -3
- ommlds/minichain/backends/impls/mlx/chat.py +6 -3
- ommlds/minichain/backends/impls/ollama/chat.py +51 -57
- ommlds/minichain/backends/impls/ollama/protocol.py +144 -0
- ommlds/minichain/backends/impls/openai/format.py +4 -3
- ommlds/minichain/backends/impls/openai/names.py +3 -1
- ommlds/minichain/backends/impls/openai/stream.py +33 -1
- ommlds/minichain/backends/impls/sentencepiece/tokens.py +9 -6
- ommlds/minichain/backends/impls/tinygrad/chat.py +7 -4
- ommlds/minichain/backends/impls/tokenizers/tokens.py +9 -6
- ommlds/minichain/backends/impls/transformers/sentence.py +5 -2
- ommlds/minichain/backends/impls/transformers/tokens.py +9 -6
- ommlds/minichain/backends/impls/transformers/transformers.py +10 -8
- ommlds/minichain/backends/strings/resolving.py +1 -1
- ommlds/minichain/chat/content.py +42 -0
- ommlds/minichain/chat/messages.py +43 -39
- ommlds/minichain/chat/stream/joining.py +36 -12
- ommlds/minichain/chat/stream/types.py +1 -1
- ommlds/minichain/chat/templating.py +3 -3
- ommlds/minichain/content/__init__.py +19 -3
- ommlds/minichain/content/_marshal.py +181 -55
- ommlds/minichain/content/code.py +26 -0
- ommlds/minichain/content/composite.py +28 -0
- ommlds/minichain/content/content.py +27 -0
- ommlds/minichain/content/dynamic.py +12 -0
- ommlds/minichain/content/emphasis.py +27 -0
- ommlds/minichain/content/images.py +2 -2
- ommlds/minichain/content/json.py +2 -2
- ommlds/minichain/content/link.py +13 -0
- ommlds/minichain/content/markdown.py +12 -0
- ommlds/minichain/content/metadata.py +10 -0
- ommlds/minichain/content/namespaces.py +8 -0
- ommlds/minichain/content/placeholders.py +10 -9
- ommlds/minichain/content/quote.py +26 -0
- ommlds/minichain/content/raw.py +49 -0
- ommlds/minichain/content/recursive.py +12 -0
- ommlds/minichain/content/section.py +26 -0
- ommlds/minichain/content/sequence.py +17 -3
- ommlds/minichain/content/standard.py +32 -0
- ommlds/minichain/content/tag.py +28 -0
- ommlds/minichain/content/templates.py +13 -0
- ommlds/minichain/content/text.py +2 -2
- ommlds/minichain/content/transform/__init__.py +0 -0
- ommlds/minichain/content/transform/json.py +55 -0
- ommlds/minichain/content/transform/markdown.py +8 -0
- ommlds/minichain/content/transform/materialize.py +51 -0
- ommlds/minichain/content/transform/metadata.py +16 -0
- ommlds/minichain/content/{prepare.py → transform/prepare.py} +10 -15
- ommlds/minichain/content/transform/recursive.py +97 -0
- ommlds/minichain/content/transform/standard.py +43 -0
- ommlds/minichain/content/{transforms → transform}/stringify.py +1 -7
- ommlds/minichain/content/transform/strings.py +33 -0
- ommlds/minichain/content/transform/templates.py +25 -0
- ommlds/minichain/content/visitors.py +231 -0
- ommlds/minichain/lib/fs/tools/read.py +1 -1
- ommlds/minichain/lib/fs/tools/recursivels/rendering.py +1 -1
- ommlds/minichain/lib/fs/tools/recursivels/running.py +1 -1
- ommlds/minichain/lib/todo/tools/write.py +2 -1
- ommlds/minichain/lib/todo/types.py +1 -1
- ommlds/minichain/metadata.py +56 -2
- ommlds/minichain/resources.py +22 -1
- ommlds/minichain/services/README.md +154 -0
- ommlds/minichain/services/__init__.py +6 -2
- ommlds/minichain/services/_marshal.py +46 -10
- ommlds/minichain/services/_origclasses.py +11 -0
- ommlds/minichain/services/_typedvalues.py +8 -3
- ommlds/minichain/services/requests.py +73 -3
- ommlds/minichain/services/responses.py +73 -3
- ommlds/minichain/services/services.py +9 -0
- ommlds/minichain/stream/services.py +24 -1
- ommlds/minichain/text/applypatch.py +2 -1
- ommlds/minichain/text/toolparsing/llamacpp/types.py +1 -1
- ommlds/minichain/tokens/specials.py +1 -1
- ommlds/minichain/tools/execution/catalog.py +1 -1
- ommlds/minichain/tools/execution/errorhandling.py +36 -0
- ommlds/minichain/tools/execution/errors.py +2 -2
- ommlds/minichain/tools/execution/executors.py +1 -1
- ommlds/minichain/tools/fns.py +1 -1
- ommlds/minichain/tools/jsonschema.py +2 -2
- ommlds/minichain/tools/reflect.py +6 -6
- ommlds/minichain/tools/types.py +12 -15
- ommlds/minichain/vectors/_marshal.py +1 -1
- ommlds/minichain/vectors/embeddings.py +1 -1
- ommlds/minichain/wrappers/__init__.py +7 -0
- ommlds/minichain/wrappers/firstinwins.py +144 -0
- ommlds/minichain/wrappers/instrument.py +146 -0
- ommlds/minichain/wrappers/retry.py +168 -0
- ommlds/minichain/wrappers/services.py +98 -0
- ommlds/minichain/wrappers/stream.py +57 -0
- ommlds/nanochat/rustbpe/README.md +9 -0
- ommlds/nanochat/tokenizers.py +40 -6
- ommlds/specs/mcp/clients.py +146 -0
- ommlds/specs/mcp/protocol.py +123 -18
- ommlds/tools/git.py +82 -65
- {ommlds-0.0.0.dev480.dist-info → ommlds-0.0.0.dev503.dist-info}/METADATA +13 -11
- ommlds-0.0.0.dev503.dist-info/RECORD +520 -0
- ommlds/cli/sessions/chat/chat/state/inject.py +0 -36
- ommlds/cli/sessions/chat/chat/user/inject.py +0 -62
- ommlds/cli/sessions/chat/chat/user/interactive.py +0 -31
- ommlds/cli/sessions/chat/chat/user/oneshot.py +0 -25
- ommlds/cli/sessions/chat/chat/user/types.py +0 -15
- ommlds/cli/sessions/chat/driver.py +0 -43
- ommlds/minichain/content/materialize.py +0 -196
- ommlds/minichain/content/simple.py +0 -47
- ommlds/minichain/content/transforms/base.py +0 -46
- ommlds/minichain/content/transforms/interleave.py +0 -70
- ommlds/minichain/content/transforms/squeeze.py +0 -72
- ommlds/minichain/content/transforms/strings.py +0 -24
- ommlds/minichain/content/types.py +0 -43
- ommlds/minichain/stream/wrap.py +0 -62
- ommlds-0.0.0.dev480.dist-info/RECORD +0 -427
- /ommlds/cli/sessions/chat/{chat → drivers}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/ai/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/ai/injection.py +0 -0
- /ommlds/cli/sessions/chat/{chat/state → drivers/events}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat/user → drivers/phases}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/inject.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/injection.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/manager.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/types.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/state}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/fs/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/fs/configs.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/todo/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/todo/configs.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/configs.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/inject.py +0 -0
- /ommlds/{minichain/content/transforms → cli/sessions/chat/drivers/user}/__init__.py +0 -0
- {ommlds-0.0.0.dev480.dist-info → ommlds-0.0.0.dev503.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev480.dist-info → ommlds-0.0.0.dev503.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev480.dist-info → ommlds-0.0.0.dev503.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev480.dist-info → ommlds-0.0.0.dev503.dist-info}/top_level.txt +0 -0
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import collections.abc
|
|
2
|
-
import dataclasses as dc
|
|
3
2
|
import typing as ta
|
|
4
3
|
|
|
5
4
|
from omlish import check
|
|
5
|
+
from omlish import dataclasses as dc
|
|
6
6
|
from omlish import lang
|
|
7
7
|
from omlish import marshal as msh
|
|
8
8
|
from omlish import reflect as rfl
|
|
9
9
|
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
14
|
-
from .
|
|
15
|
-
from .
|
|
16
|
-
from .
|
|
17
|
-
from .
|
|
18
|
-
from .
|
|
19
|
-
from .
|
|
10
|
+
from .code import BlockCodeContent
|
|
11
|
+
from .code import InlineCodeContent
|
|
12
|
+
from .content import BaseContent
|
|
13
|
+
from .content import Content
|
|
14
|
+
from .emphasis import BoldContent
|
|
15
|
+
from .emphasis import BoldItalicContent
|
|
16
|
+
from .emphasis import ItalicContent
|
|
17
|
+
from .images import ImageContent
|
|
18
|
+
from .json import JsonContent
|
|
19
|
+
from .link import LinkContent
|
|
20
|
+
from .markdown import MarkdownContent
|
|
21
|
+
from .quote import QuoteContent
|
|
22
|
+
from .raw import NON_STR_SINGLE_RAW_CONTENT_TYPES
|
|
23
|
+
from .raw import NonStrSingleRawContent
|
|
24
|
+
from .raw import RawContent
|
|
25
|
+
from .raw import SingleRawContent
|
|
26
|
+
from .section import SectionContent
|
|
27
|
+
from .sequence import BlockContent
|
|
28
|
+
from .sequence import InlineContent
|
|
29
|
+
from .sequence import ItemListContent
|
|
30
|
+
from .tag import TagContent
|
|
31
|
+
from .text import TextContent
|
|
20
32
|
|
|
21
33
|
|
|
22
34
|
##
|
|
@@ -29,7 +41,7 @@ class MarshalContent(lang.NotInstantiable, lang.Final):
|
|
|
29
41
|
|
|
30
42
|
MarshalContentUnion: ta.TypeAlias = ta.Union[ # noqa
|
|
31
43
|
str,
|
|
32
|
-
|
|
44
|
+
BaseContent,
|
|
33
45
|
ta.Sequence[MarshalContent],
|
|
34
46
|
]
|
|
35
47
|
|
|
@@ -39,15 +51,15 @@ _MARSHAL_CONTENT_UNION_RTY = rfl.type_(MarshalContentUnion)
|
|
|
39
51
|
|
|
40
52
|
@dc.dataclass(frozen=True)
|
|
41
53
|
class _ContentMarshaler(msh.Marshaler):
|
|
42
|
-
|
|
54
|
+
bt: msh.Marshaler
|
|
43
55
|
|
|
44
56
|
def marshal(self, ctx: msh.MarshalContext, o: ta.Any) -> msh.Value:
|
|
45
57
|
if isinstance(o, str):
|
|
46
58
|
return o
|
|
47
59
|
elif isinstance(o, ta.Sequence):
|
|
48
60
|
return [self.marshal(ctx, e) for e in o]
|
|
49
|
-
elif isinstance(o,
|
|
50
|
-
return self.
|
|
61
|
+
elif isinstance(o, BaseContent):
|
|
62
|
+
return self.bt.marshal(ctx, o)
|
|
51
63
|
else:
|
|
52
64
|
raise TypeError(o)
|
|
53
65
|
|
|
@@ -56,12 +68,12 @@ class _ContentMarshalerFactory(msh.MarshalerFactory):
|
|
|
56
68
|
def make_marshaler(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
|
57
69
|
if not (rty is MarshalContent or rty == _MARSHAL_CONTENT_UNION_RTY):
|
|
58
70
|
return None
|
|
59
|
-
return lambda: _ContentMarshaler(ctx.make_marshaler(
|
|
71
|
+
return lambda: _ContentMarshaler(ctx.make_marshaler(BaseContent))
|
|
60
72
|
|
|
61
73
|
|
|
62
74
|
@dc.dataclass(frozen=True)
|
|
63
75
|
class _ContentUnmarshaler(msh.Unmarshaler):
|
|
64
|
-
|
|
76
|
+
bt: msh.Unmarshaler
|
|
65
77
|
|
|
66
78
|
def unmarshal(self, ctx: msh.UnmarshalContext, v: msh.Value) -> ta.Any:
|
|
67
79
|
if isinstance(v, str):
|
|
@@ -69,7 +81,7 @@ class _ContentUnmarshaler(msh.Unmarshaler):
|
|
|
69
81
|
elif isinstance(v, ta.Sequence):
|
|
70
82
|
return [self.unmarshal(ctx, e) for e in v]
|
|
71
83
|
elif isinstance(v, collections.abc.Mapping):
|
|
72
|
-
return self.
|
|
84
|
+
return self.bt.unmarshal(ctx, v) # noqa
|
|
73
85
|
else:
|
|
74
86
|
raise TypeError(v)
|
|
75
87
|
|
|
@@ -78,53 +90,117 @@ class _ContentUnmarshalerFactory(msh.UnmarshalerFactory):
|
|
|
78
90
|
def make_unmarshaler(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None: # noqa
|
|
79
91
|
if not (rty is MarshalContent or rty == _MARSHAL_CONTENT_UNION_RTY):
|
|
80
92
|
return None
|
|
81
|
-
return lambda: _ContentUnmarshaler(ctx.make_unmarshaler(
|
|
93
|
+
return lambda: _ContentUnmarshaler(ctx.make_unmarshaler(BaseContent))
|
|
82
94
|
|
|
83
95
|
|
|
84
96
|
##
|
|
85
97
|
|
|
86
98
|
|
|
87
|
-
class
|
|
99
|
+
class MarshalSingleRawContent(lang.NotInstantiable, lang.Final):
|
|
88
100
|
pass
|
|
89
101
|
|
|
90
102
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
_SINGLE_RAW_CONTENT_UNION_RTY = rfl.type_(SingleRawContent)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dc.dataclass(frozen=True)
|
|
107
|
+
class _SingleRawContentMarshaler(msh.Marshaler):
|
|
108
|
+
nst: msh.Marshaler
|
|
109
|
+
|
|
110
|
+
def marshal(self, ctx: msh.MarshalContext, o: ta.Any) -> msh.Value:
|
|
111
|
+
if isinstance(o, str):
|
|
112
|
+
return o
|
|
113
|
+
elif isinstance(o, NON_STR_SINGLE_RAW_CONTENT_TYPES):
|
|
114
|
+
return self.nst.marshal(ctx, o)
|
|
115
|
+
else:
|
|
116
|
+
raise TypeError(o)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class _SingleRawContentMarshalerFactory(msh.MarshalerFactory):
|
|
120
|
+
def make_marshaler(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
|
121
|
+
if not (rty is MarshalSingleRawContent or rty == _SINGLE_RAW_CONTENT_UNION_RTY):
|
|
122
|
+
return None
|
|
123
|
+
return lambda: _SingleRawContentMarshaler(ctx.make_marshaler(NonStrSingleRawContent))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@dc.dataclass(frozen=True)
|
|
127
|
+
class _SingleRawContentUnmarshaler(msh.Unmarshaler):
|
|
128
|
+
nst: msh.Unmarshaler
|
|
129
|
+
|
|
130
|
+
def unmarshal(self, ctx: msh.UnmarshalContext, v: msh.Value) -> ta.Any:
|
|
131
|
+
if isinstance(v, str):
|
|
132
|
+
return v
|
|
133
|
+
elif isinstance(v, collections.abc.Mapping):
|
|
134
|
+
return self.nst.unmarshal(ctx, v) # noqa
|
|
135
|
+
else:
|
|
136
|
+
raise TypeError(v)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class _SingleRawContentUnmarshalerFactory(msh.UnmarshalerFactory):
|
|
140
|
+
def make_unmarshaler(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None: # noqa
|
|
141
|
+
if not (rty is MarshalSingleRawContent or rty == _SINGLE_RAW_CONTENT_UNION_RTY):
|
|
142
|
+
return None
|
|
143
|
+
return lambda: _SingleRawContentUnmarshaler(ctx.make_unmarshaler(NonStrSingleRawContent))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
##
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class MarshalRawContent(lang.NotInstantiable, lang.Final):
|
|
150
|
+
pass
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
MarshalRawContentUnion: ta.TypeAlias = ta.Union[ # noqa
|
|
154
|
+
SingleRawContent,
|
|
155
|
+
ta.Sequence[MarshalRawContent],
|
|
94
156
|
]
|
|
95
157
|
|
|
96
158
|
|
|
97
|
-
|
|
159
|
+
_MARSHAL_RAW_CONTENT_UNION_RTY = rfl.type_(MarshalRawContentUnion)
|
|
98
160
|
|
|
99
161
|
|
|
100
162
|
@dc.dataclass(frozen=True)
|
|
101
|
-
class
|
|
102
|
-
|
|
163
|
+
class _RawContentMarshaler(msh.Marshaler):
|
|
164
|
+
nst: msh.Marshaler
|
|
103
165
|
|
|
104
166
|
def marshal(self, ctx: msh.MarshalContext, o: ta.Any) -> msh.Value:
|
|
105
|
-
|
|
167
|
+
if isinstance(o, str):
|
|
168
|
+
return o
|
|
169
|
+
elif isinstance(o, ta.Sequence):
|
|
170
|
+
return [self.marshal(ctx, e) for e in o]
|
|
171
|
+
elif isinstance(o, NON_STR_SINGLE_RAW_CONTENT_TYPES):
|
|
172
|
+
return self.nst.marshal(ctx, o)
|
|
173
|
+
else:
|
|
174
|
+
raise TypeError(o)
|
|
106
175
|
|
|
107
176
|
|
|
108
|
-
class
|
|
177
|
+
class _RawContentMarshalerFactory(msh.MarshalerFactory):
|
|
109
178
|
def make_marshaler(self, ctx: msh.MarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Marshaler] | None:
|
|
110
|
-
if not (rty is
|
|
179
|
+
if not (rty is MarshalRawContent or rty == _MARSHAL_RAW_CONTENT_UNION_RTY):
|
|
111
180
|
return None
|
|
112
|
-
return lambda:
|
|
181
|
+
return lambda: _RawContentMarshaler(ctx.make_marshaler(NonStrSingleRawContent))
|
|
113
182
|
|
|
114
183
|
|
|
115
184
|
@dc.dataclass(frozen=True)
|
|
116
|
-
class
|
|
117
|
-
|
|
185
|
+
class _RawContentUnmarshaler(msh.Unmarshaler):
|
|
186
|
+
nst: msh.Unmarshaler
|
|
118
187
|
|
|
119
188
|
def unmarshal(self, ctx: msh.UnmarshalContext, v: msh.Value) -> ta.Any:
|
|
120
|
-
|
|
189
|
+
if isinstance(v, str):
|
|
190
|
+
return v
|
|
191
|
+
elif isinstance(v, ta.Sequence):
|
|
192
|
+
return [self.unmarshal(ctx, e) for e in v]
|
|
193
|
+
elif isinstance(v, collections.abc.Mapping):
|
|
194
|
+
return self.nst.unmarshal(ctx, v) # noqa
|
|
195
|
+
else:
|
|
196
|
+
raise TypeError(v)
|
|
121
197
|
|
|
122
198
|
|
|
123
|
-
class
|
|
199
|
+
class _RawContentUnmarshalerFactory(msh.UnmarshalerFactory):
|
|
124
200
|
def make_unmarshaler(self, ctx: msh.UnmarshalFactoryContext, rty: rfl.Type) -> ta.Callable[[], msh.Unmarshaler] | None: # noqa
|
|
125
|
-
if not (rty is
|
|
201
|
+
if not (rty is MarshalRawContent or rty == _MARSHAL_RAW_CONTENT_UNION_RTY):
|
|
126
202
|
return None
|
|
127
|
-
return lambda:
|
|
203
|
+
return lambda: _RawContentUnmarshaler(ctx.make_unmarshaler(NonStrSingleRawContent))
|
|
128
204
|
|
|
129
205
|
|
|
130
206
|
##
|
|
@@ -158,35 +234,52 @@ class _JsonContentUnmarshaler(msh.Unmarshaler):
|
|
|
158
234
|
|
|
159
235
|
@lang.static_init
|
|
160
236
|
def _install_standard_marshaling() -> None:
|
|
161
|
-
|
|
162
|
-
|
|
237
|
+
base_content_poly = msh.Polymorphism(
|
|
238
|
+
BaseContent,
|
|
163
239
|
[
|
|
164
|
-
|
|
165
|
-
msh.Impl(
|
|
240
|
+
|
|
241
|
+
msh.Impl(InlineCodeContent, 'inline_code'),
|
|
242
|
+
msh.Impl(BlockCodeContent, 'block_code'),
|
|
243
|
+
|
|
244
|
+
msh.Impl(BoldContent, 'bold'),
|
|
245
|
+
msh.Impl(ItalicContent, 'italic'),
|
|
246
|
+
msh.Impl(BoldItalicContent, 'bold_italic'),
|
|
247
|
+
|
|
166
248
|
msh.Impl(ImageContent, 'image'),
|
|
249
|
+
|
|
167
250
|
msh.Impl(JsonContent, 'json'),
|
|
251
|
+
|
|
252
|
+
msh.Impl(LinkContent, 'link'),
|
|
253
|
+
|
|
254
|
+
msh.Impl(MarkdownContent, 'markdown'),
|
|
255
|
+
|
|
256
|
+
msh.Impl(QuoteContent, 'quote'),
|
|
257
|
+
|
|
258
|
+
msh.Impl(SectionContent, 'section'),
|
|
259
|
+
|
|
260
|
+
msh.Impl(BlockContent, 'block'),
|
|
261
|
+
msh.Impl(InlineContent, 'inline'),
|
|
262
|
+
msh.Impl(ItemListContent, 'item_list'),
|
|
263
|
+
|
|
264
|
+
msh.Impl(TagContent, 'tag'),
|
|
265
|
+
|
|
168
266
|
msh.Impl(TextContent, 'text'),
|
|
267
|
+
|
|
169
268
|
],
|
|
170
269
|
)
|
|
171
270
|
|
|
172
271
|
msh.install_standard_factories(
|
|
173
|
-
msh.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}),
|
|
178
|
-
_ContentMarshalerFactory(),
|
|
179
|
-
_CanContentMarshalerFactory(),
|
|
272
|
+
*msh.standard_polymorphism_factories(
|
|
273
|
+
base_content_poly,
|
|
274
|
+
unions='partial',
|
|
275
|
+
),
|
|
180
276
|
)
|
|
181
277
|
|
|
278
|
+
#
|
|
279
|
+
|
|
182
280
|
msh.install_standard_factories(
|
|
183
|
-
|
|
184
|
-
msh.TypeMapUnmarshalerFactory({
|
|
185
|
-
ImageContent: _ImageContentUnmarshaler(),
|
|
186
|
-
JsonContent: _JsonContentUnmarshaler(),
|
|
187
|
-
}),
|
|
281
|
+
_ContentMarshalerFactory(),
|
|
188
282
|
_ContentUnmarshalerFactory(),
|
|
189
|
-
_CanContentUnmarshalerFactory(),
|
|
190
283
|
)
|
|
191
284
|
|
|
192
285
|
msh.register_global_config(
|
|
@@ -195,8 +288,41 @@ def _install_standard_marshaling() -> None:
|
|
|
195
288
|
identity=True,
|
|
196
289
|
)
|
|
197
290
|
|
|
291
|
+
#
|
|
292
|
+
|
|
293
|
+
msh.install_standard_factories(
|
|
294
|
+
_SingleRawContentMarshalerFactory(),
|
|
295
|
+
_SingleRawContentUnmarshalerFactory(),
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
msh.register_global_config(
|
|
299
|
+
SingleRawContent,
|
|
300
|
+
msh.ReflectOverride(MarshalSingleRawContent),
|
|
301
|
+
identity=True,
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
#
|
|
305
|
+
|
|
306
|
+
msh.install_standard_factories(
|
|
307
|
+
_RawContentMarshalerFactory(),
|
|
308
|
+
_RawContentUnmarshalerFactory(),
|
|
309
|
+
)
|
|
310
|
+
|
|
198
311
|
msh.register_global_config(
|
|
199
|
-
|
|
200
|
-
msh.ReflectOverride(
|
|
312
|
+
RawContent,
|
|
313
|
+
msh.ReflectOverride(MarshalRawContent),
|
|
201
314
|
identity=True,
|
|
202
315
|
)
|
|
316
|
+
|
|
317
|
+
#
|
|
318
|
+
|
|
319
|
+
msh.install_standard_factories(
|
|
320
|
+
msh.TypeMapMarshalerFactory({
|
|
321
|
+
ImageContent: _ImageContentMarshaler(),
|
|
322
|
+
JsonContent: _JsonContentMarshaler(),
|
|
323
|
+
}),
|
|
324
|
+
msh.TypeMapUnmarshalerFactory({
|
|
325
|
+
ImageContent: _ImageContentUnmarshaler(),
|
|
326
|
+
JsonContent: _JsonContentUnmarshaler(),
|
|
327
|
+
}),
|
|
328
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from omlish import dataclasses as dc
|
|
2
|
+
from omlish import lang
|
|
3
|
+
|
|
4
|
+
from .standard import StandardContent
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dc.dataclass(frozen=True)
|
|
11
|
+
class CodeContent(StandardContent, lang.Abstract):
|
|
12
|
+
s: str
|
|
13
|
+
|
|
14
|
+
_: dc.KW_ONLY
|
|
15
|
+
|
|
16
|
+
lang: str | None = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dc.dataclass(frozen=True)
|
|
20
|
+
class InlineCodeContent(CodeContent, lang.Final):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dc.dataclass(frozen=True)
|
|
25
|
+
class BlockCodeContent(CodeContent, lang.Final):
|
|
26
|
+
pass
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import typing as ta
|
|
3
|
+
|
|
4
|
+
from omlish import dataclasses as dc
|
|
5
|
+
from omlish import lang
|
|
6
|
+
|
|
7
|
+
from .content import Content
|
|
8
|
+
from .standard import StandardContent
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dc.dataclass(frozen=True)
|
|
15
|
+
class CompositeContent(StandardContent, lang.Abstract):
|
|
16
|
+
@abc.abstractmethod
|
|
17
|
+
def child_content(self) -> ta.Sequence[Content]:
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
|
|
20
|
+
@abc.abstractmethod
|
|
21
|
+
def _replace_child_content(self, new_child_content: ta.Sequence[Content]) -> ta.Self:
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
24
|
+
def replace_child_content(self, new_child_content: ta.Sequence[Content]) -> ta.Self:
|
|
25
|
+
if lang.seqs_identical(new_child_content, self.child_content()):
|
|
26
|
+
return self
|
|
27
|
+
|
|
28
|
+
return self._replace_child_content(new_child_content)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import typing as ta
|
|
2
|
+
|
|
3
|
+
from omlish import lang
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseContent(lang.Abstract, lang.PackageSealed):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Content: ta.TypeAlias = ta.Union[ # noqa
|
|
17
|
+
str,
|
|
18
|
+
BaseContent,
|
|
19
|
+
ta.Sequence['Content'],
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
CONTENT_TYPES: tuple[type, ...] = (
|
|
24
|
+
str,
|
|
25
|
+
BaseContent,
|
|
26
|
+
ta.Sequence,
|
|
27
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from omlish import dataclasses as dc
|
|
2
|
+
from omlish import lang
|
|
3
|
+
|
|
4
|
+
from .standard import StandardContent
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dc.dataclass(frozen=True)
|
|
11
|
+
class EmphasisContent(StandardContent, lang.Abstract):
|
|
12
|
+
s: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dc.dataclass(frozen=True)
|
|
16
|
+
class BoldContent(EmphasisContent, lang.Final):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dc.dataclass(frozen=True)
|
|
21
|
+
class ItalicContent(EmphasisContent, lang.Final):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dc.dataclass(frozen=True)
|
|
26
|
+
class BoldItalicContent(EmphasisContent, lang.Final):
|
|
27
|
+
pass
|
|
@@ -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 .
|
|
11
|
+
from .standard import StandardContent
|
|
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 ImageContent(
|
|
24
|
+
class ImageContent(StandardContent, lang.Final):
|
|
25
25
|
i: 'pimg.Image' = dc.field()
|
ommlds/minichain/content/json.py
CHANGED
|
@@ -2,12 +2,12 @@ from omlish import dataclasses as dc
|
|
|
2
2
|
from omlish import lang
|
|
3
3
|
|
|
4
4
|
from ..json import JsonValue
|
|
5
|
-
from .
|
|
5
|
+
from .standard import StandardContent
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
##
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@dc.dataclass(frozen=True)
|
|
12
|
-
class JsonContent(
|
|
12
|
+
class JsonContent(StandardContent, lang.Final):
|
|
13
13
|
v: JsonValue
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import typing as ta
|
|
2
2
|
|
|
3
|
+
from omlish import dataclasses as dc
|
|
3
4
|
from omlish import lang
|
|
4
5
|
|
|
5
6
|
from ..metadata import CommonMetadata
|
|
6
7
|
from ..metadata import Metadata
|
|
8
|
+
from .content import Content
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
##
|
|
@@ -14,3 +16,11 @@ class ContentMetadata(Metadata, lang.Abstract):
|
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
ContentMetadatas: ta.TypeAlias = ContentMetadata | CommonMetadata
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dc.dataclass(frozen=True)
|
|
25
|
+
class ContentOriginal(ContentMetadata, lang.Final):
|
|
26
|
+
c: Content
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
from omlish import dataclasses as dc
|
|
1
2
|
from omlish import lang
|
|
2
3
|
|
|
4
|
+
from .recursive import RecursiveContent
|
|
5
|
+
|
|
3
6
|
|
|
4
7
|
##
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class ContentNamespace(lang.Namespace, lang.Abstract):
|
|
8
11
|
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dc.dataclass(frozen=True)
|
|
15
|
+
class NamespaceContent(RecursiveContent, lang.Final):
|
|
16
|
+
ns: type[ContentNamespace]
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import typing as ta
|
|
2
|
+
|
|
1
3
|
from omlish import dataclasses as dc
|
|
2
4
|
from omlish import lang
|
|
3
5
|
|
|
6
|
+
from .recursive import RecursiveContent
|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
##
|
|
6
10
|
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ContentPlaceholder(lang.Final):
|
|
11
|
-
# kw_only to prevent misuse - the string passed to this class is not the Content itself, just the name of the
|
|
12
|
-
# placeholder
|
|
13
|
-
name: str | None = dc.field(default=None, kw_only=True, metadata=dc.extra_field_params(repr_fn=lang.opt_repr))
|
|
12
|
+
class ContentPlaceholder(lang.Marker, lang.Abstract):
|
|
13
|
+
pass
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
PlaceholderContentKey: ta.TypeAlias = str | type[ContentPlaceholder]
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
@dc.dataclass(frozen=True)
|
|
20
|
+
class PlaceholderContent(RecursiveContent, lang.Final):
|
|
21
|
+
k: PlaceholderContentKey
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- attribution
|
|
4
|
+
"""
|
|
5
|
+
import typing as ta
|
|
6
|
+
|
|
7
|
+
from omlish import check
|
|
8
|
+
from omlish import dataclasses as dc
|
|
9
|
+
from omlish import lang
|
|
10
|
+
|
|
11
|
+
from .composite import CompositeContent
|
|
12
|
+
from .content import Content
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dc.dataclass(frozen=True)
|
|
19
|
+
class QuoteContent(CompositeContent, lang.Final):
|
|
20
|
+
body: Content
|
|
21
|
+
|
|
22
|
+
def child_content(self) -> ta.Sequence[Content]:
|
|
23
|
+
return [self.body]
|
|
24
|
+
|
|
25
|
+
def _replace_child_content(self, new_child_content: ta.Sequence[Content]) -> ta.Self:
|
|
26
|
+
return self.replace(body=check.single(new_child_content))
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import typing as ta
|
|
2
|
+
|
|
3
|
+
from .images import ImageContent
|
|
4
|
+
from .text import TextContent
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
NonStrSingleRawContent: ta.TypeAlias = ta.Union[ # noqa
|
|
11
|
+
TextContent,
|
|
12
|
+
ImageContent,
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
NON_STR_SINGLE_RAW_CONTENT_TYPES: tuple[type, ...] = (
|
|
17
|
+
TextContent,
|
|
18
|
+
ImageContent,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
SingleRawContent: ta.TypeAlias = ta.Union[ # noqa
|
|
26
|
+
str,
|
|
27
|
+
NonStrSingleRawContent,
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
SINGLE_RAW_CONTENT_TYPES: tuple[type, ...] = (
|
|
32
|
+
str,
|
|
33
|
+
*NON_STR_SINGLE_RAW_CONTENT_TYPES,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
RawContent: ta.TypeAlias = ta.Union[ # noqa
|
|
41
|
+
SingleRawContent,
|
|
42
|
+
ta.Sequence[SingleRawContent],
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
RAW_CONTENT_TYPES: tuple[type, ...] = (
|
|
47
|
+
*SINGLE_RAW_CONTENT_TYPES,
|
|
48
|
+
ta.Sequence,
|
|
49
|
+
)
|