ommlds 0.0.0.dev466__py3-none-any.whl → 0.0.0.dev512__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 +404 -31
- ommlds/README.md +11 -0
- ommlds/__about__.py +21 -12
- ommlds/_hacks/__init__.py +4 -0
- ommlds/_hacks/funcs.py +110 -0
- ommlds/_hacks/names.py +158 -0
- ommlds/_hacks/params.py +73 -0
- ommlds/_hacks/patches.py +0 -3
- 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/anthropic/protocol/types.py +5 -7
- ommlds/backends/cerebras/__init__.py +7 -0
- ommlds/backends/cerebras/_dataclasses.py +4254 -0
- ommlds/backends/cerebras/_marshal.py +24 -0
- ommlds/backends/cerebras/clients.py +9 -0
- ommlds/backends/cerebras/protocol.py +310 -0
- ommlds/backends/google/protocol/__init__.py +13 -0
- ommlds/backends/google/protocol/_dataclasses.py +5997 -0
- ommlds/backends/google/protocol/types.py +6 -8
- ommlds/backends/groq/__init__.py +7 -0
- ommlds/backends/groq/_dataclasses.py +3901 -0
- ommlds/backends/groq/_marshal.py +23 -0
- ommlds/backends/groq/clients.py +9 -0
- ommlds/backends/groq/protocol.py +247 -0
- ommlds/{huggingface.py → backends/huggingface/cache.py} +1 -6
- ommlds/backends/huggingface/cli.py +208 -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 +3940 -0
- ommlds/backends/ollama/cli.py +36 -0
- ommlds/backends/ollama/protocol.py +201 -0
- ommlds/backends/openai/protocol/__init__.py +15 -1
- ommlds/backends/openai/protocol/_common.py +3 -5
- ommlds/backends/openai/protocol/_dataclasses.py +7708 -0
- ommlds/backends/tavily/__init__.py +7 -0
- ommlds/backends/tavily/_dataclasses.py +1734 -0
- ommlds/backends/tavily/protocol.py +299 -0
- ommlds/backends/tinygrad/models/llama3/__init__.py +22 -14
- ommlds/backends/torch/backends.py +1 -1
- ommlds/backends/transformers/__init__.py +14 -0
- ommlds/backends/transformers/filecache.py +109 -0
- ommlds/backends/transformers/streamers.py +73 -0
- ommlds/cli/__init__.py +7 -0
- ommlds/cli/_dataclasses.py +3835 -0
- ommlds/cli/asyncs.py +30 -0
- ommlds/cli/backends/catalog.py +88 -0
- ommlds/cli/backends/configs.py +9 -0
- ommlds/cli/backends/inject.py +100 -42
- ommlds/cli/{sessions/chat/backends → backends}/injection.py +1 -1
- ommlds/cli/backends/meta.py +82 -0
- ommlds/cli/{sessions/chat/backends → backends}/types.py +11 -1
- ommlds/cli/{sessions/chat/content → content}/messages.py +2 -2
- ommlds/cli/{sessions/chat/content → content}/strings.py +1 -1
- ommlds/cli/inject.py +17 -8
- ommlds/cli/inputs/asyncs.py +32 -0
- ommlds/cli/inputs/sync.py +75 -0
- ommlds/cli/main.py +346 -114
- ommlds/cli/rendering/configs.py +9 -0
- ommlds/cli/{sessions/chat/rendering → rendering}/inject.py +4 -5
- ommlds/cli/{sessions/chat/rendering → rendering}/markdown.py +1 -1
- ommlds/cli/{sessions/chat/rendering → rendering}/raw.py +1 -1
- ommlds/cli/{sessions/chat/rendering → rendering}/types.py +7 -1
- ommlds/cli/secrets.py +22 -0
- ommlds/cli/sessions/base.py +1 -10
- ommlds/cli/sessions/chat/configs.py +13 -30
- ommlds/cli/sessions/chat/drivers/ai/configs.py +13 -0
- ommlds/cli/sessions/chat/drivers/ai/events.py +57 -0
- ommlds/cli/sessions/chat/{chat → drivers}/ai/inject.py +15 -12
- ommlds/cli/sessions/chat/{chat → drivers}/ai/rendering.py +8 -8
- ommlds/cli/sessions/chat/{chat → drivers}/ai/services.py +5 -5
- ommlds/cli/sessions/chat/{chat → drivers}/ai/tools.py +4 -8
- ommlds/cli/sessions/chat/{chat → drivers}/ai/types.py +10 -1
- 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 +44 -0
- ommlds/cli/sessions/chat/drivers/impl.py +50 -0
- ommlds/cli/sessions/chat/drivers/inject.py +70 -0
- ommlds/cli/sessions/chat/drivers/state/configs.py +13 -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 +1 -6
- ommlds/cli/sessions/chat/{chat → drivers}/state/storage.py +18 -12
- ommlds/cli/sessions/chat/{chat → drivers}/state/types.py +11 -6
- ommlds/cli/sessions/chat/drivers/tools/configs.py +22 -0
- 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/drivers/tools/fs/__init__.py +0 -0
- ommlds/cli/sessions/chat/drivers/tools/fs/configs.py +12 -0
- ommlds/cli/sessions/chat/drivers/tools/fs/inject.py +35 -0
- ommlds/cli/sessions/chat/drivers/tools/inject.py +83 -0
- ommlds/cli/sessions/chat/{tools → drivers/tools}/injection.py +20 -5
- ommlds/cli/sessions/chat/{tools → drivers/tools}/rendering.py +3 -3
- ommlds/cli/sessions/chat/drivers/tools/todo/__init__.py +0 -0
- ommlds/cli/sessions/chat/drivers/tools/todo/configs.py +12 -0
- ommlds/cli/sessions/chat/drivers/tools/todo/inject.py +31 -0
- ommlds/cli/sessions/chat/drivers/tools/weather/__init__.py +0 -0
- ommlds/cli/sessions/chat/drivers/tools/weather/configs.py +12 -0
- ommlds/cli/sessions/chat/drivers/tools/weather/inject.py +22 -0
- ommlds/cli/sessions/chat/{tools/weather.py → drivers/tools/weather/tools.py} +1 -1
- ommlds/cli/sessions/chat/drivers/types.py +31 -0
- ommlds/cli/sessions/chat/drivers/user/__init__.py +0 -0
- ommlds/cli/sessions/chat/drivers/user/configs.py +14 -0
- 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 +10 -49
- 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 +429 -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 +111 -0
- ommlds/cli/sessions/chat/interfaces/textual/inputhistory.py +174 -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 +167 -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 +70 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/messages.py +207 -0
- ommlds/cli/sessions/chat/session.py +8 -13
- ommlds/cli/sessions/completion/configs.py +5 -6
- ommlds/cli/sessions/completion/inject.py +15 -2
- ommlds/cli/sessions/completion/session.py +10 -18
- ommlds/cli/sessions/configs.py +10 -0
- ommlds/cli/sessions/embedding/configs.py +5 -6
- ommlds/cli/sessions/embedding/inject.py +15 -2
- ommlds/cli/sessions/embedding/session.py +10 -18
- ommlds/cli/sessions/inject.py +15 -15
- ommlds/cli/state/storage.py +8 -2
- ommlds/minichain/__init__.py +217 -60
- ommlds/minichain/_dataclasses.py +20640 -0
- ommlds/minichain/_typedvalues.py +15 -8
- ommlds/minichain/backends/catalogs/base.py +20 -1
- ommlds/minichain/backends/catalogs/simple.py +2 -2
- ommlds/minichain/backends/catalogs/strings.py +13 -10
- ommlds/minichain/backends/impls/anthropic/chat.py +28 -5
- 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 +23 -18
- ommlds/minichain/backends/impls/cerebras/__init__.py +0 -0
- ommlds/minichain/backends/impls/cerebras/chat.py +82 -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 +114 -0
- ommlds/minichain/backends/impls/duckduckgo/search.py +5 -1
- ommlds/minichain/backends/impls/dummy/__init__.py +0 -0
- ommlds/minichain/backends/impls/dummy/chat.py +69 -0
- ommlds/minichain/backends/impls/google/chat.py +20 -84
- ommlds/minichain/backends/impls/google/names.py +6 -0
- ommlds/minichain/backends/impls/google/protocol.py +105 -0
- ommlds/minichain/backends/impls/google/search.py +10 -5
- ommlds/minichain/backends/impls/google/stream.py +64 -142
- ommlds/minichain/backends/impls/google/tools.py +2 -2
- ommlds/minichain/backends/impls/groq/__init__.py +0 -0
- ommlds/minichain/backends/impls/groq/chat.py +77 -0
- ommlds/minichain/backends/impls/groq/names.py +48 -0
- ommlds/minichain/backends/impls/groq/protocol.py +143 -0
- ommlds/minichain/backends/impls/groq/stream.py +114 -0
- ommlds/minichain/backends/impls/huggingface/repos.py +1 -5
- ommlds/minichain/backends/impls/llamacpp/chat.py +15 -3
- ommlds/minichain/backends/impls/llamacpp/completion.py +7 -3
- ommlds/minichain/backends/impls/llamacpp/stream.py +38 -19
- ommlds/minichain/backends/impls/mistral.py +9 -2
- ommlds/minichain/backends/impls/mlx/chat.py +100 -23
- ommlds/minichain/backends/impls/ollama/__init__.py +0 -0
- ommlds/minichain/backends/impls/ollama/chat.py +193 -0
- ommlds/minichain/backends/impls/ollama/protocol.py +144 -0
- ommlds/minichain/backends/impls/openai/chat.py +14 -7
- ommlds/minichain/backends/impls/openai/completion.py +9 -2
- ommlds/minichain/backends/impls/openai/embedding.py +9 -2
- ommlds/minichain/backends/impls/openai/format.py +117 -115
- ommlds/minichain/backends/impls/openai/names.py +33 -5
- ommlds/minichain/backends/impls/openai/stream.py +61 -70
- ommlds/minichain/backends/impls/sentencepiece/tokens.py +9 -6
- ommlds/minichain/backends/impls/tavily.py +66 -0
- ommlds/minichain/backends/impls/tinygrad/chat.py +17 -14
- 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 +139 -20
- ommlds/minichain/backends/strings/parsing.py +2 -2
- ommlds/minichain/backends/strings/resolving.py +7 -2
- ommlds/minichain/chat/choices/stream/__init__.py +0 -0
- ommlds/minichain/chat/{stream → choices/stream}/adapters.py +7 -7
- ommlds/minichain/chat/choices/stream/joining.py +31 -0
- ommlds/minichain/chat/choices/stream/services.py +45 -0
- ommlds/minichain/chat/choices/stream/types.py +43 -0
- ommlds/minichain/chat/content.py +42 -0
- ommlds/minichain/chat/messages.py +46 -42
- ommlds/minichain/chat/stream/_marshal.py +4 -4
- ommlds/minichain/chat/stream/joining.py +56 -43
- ommlds/minichain/chat/stream/services.py +15 -15
- ommlds/minichain/chat/stream/types.py +17 -24
- ommlds/minichain/chat/templating.py +3 -3
- ommlds/minichain/content/__init__.py +20 -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/resources.py +22 -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 +59 -0
- ommlds/minichain/content/transform/metadata.py +16 -0
- ommlds/minichain/content/transform/namespaces.py +20 -0
- ommlds/minichain/content/transform/placeholders.py +60 -0
- ommlds/minichain/content/{prepare.py → transform/prepare.py} +10 -15
- ommlds/minichain/content/transform/recursive.py +54 -0
- ommlds/minichain/content/transform/resources.py +58 -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/transform/types.py +18 -0
- ommlds/minichain/content/transform/visitors.py +38 -0
- ommlds/minichain/content/visitors.py +218 -0
- ommlds/minichain/http/__init__.py +0 -0
- ommlds/minichain/http/stream.py +195 -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/llms/types.py +4 -0
- ommlds/minichain/metadata.py +56 -2
- ommlds/minichain/models/configs.py +2 -2
- ommlds/minichain/models/names.py +2 -0
- ommlds/minichain/registries/globals.py +18 -4
- ommlds/minichain/resources.py +49 -3
- ommlds/minichain/search.py +1 -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/standard.py +8 -0
- ommlds/minichain/stream/services.py +43 -17
- 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 +2 -2
- 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 +11 -7
- ommlds/minichain/tools/types.py +16 -19
- 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/LICENSE +21 -0
- ommlds/nanochat/__init__.py +0 -0
- ommlds/nanochat/rustbpe/LICENSE +21 -0
- ommlds/nanochat/rustbpe/README.md +10 -0
- ommlds/nanochat/tokenizers.py +440 -0
- ommlds/specs/__init__.py +0 -0
- ommlds/specs/mcp/__init__.py +0 -0
- ommlds/specs/mcp/_marshal.py +23 -0
- ommlds/specs/mcp/clients.py +146 -0
- ommlds/specs/mcp/protocol.py +369 -0
- ommlds/tools/git.py +84 -64
- ommlds/tools/ocr.py +1 -1
- ommlds/wiki/analyze.py +2 -2
- ommlds/wiki/models.py +4 -4
- ommlds/wiki/text/mfh.py +9 -9
- ommlds/wiki/utils/xml.py +5 -5
- {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/METADATA +28 -21
- ommlds-0.0.0.dev512.dist-info/RECORD +534 -0
- {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/WHEEL +1 -1
- ommlds/cli/backends/standard.py +0 -20
- ommlds/cli/sessions/chat/backends/catalog.py +0 -56
- ommlds/cli/sessions/chat/backends/inject.py +0 -37
- ommlds/cli/sessions/chat/chat/state/inject.py +0 -40
- ommlds/cli/sessions/chat/chat/user/inject.py +0 -61
- ommlds/cli/sessions/chat/chat/user/interactive.py +0 -29
- 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/cli/sessions/chat/tools/inject.py +0 -145
- ommlds/minichain/backends/impls/openai/format2.py +0 -210
- 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.dev466.dist-info/RECORD +0 -376
- /ommlds/{cli/sessions/chat/backends → backends/huggingface}/__init__.py +0 -0
- /ommlds/cli/{sessions/chat/chat → content}/__init__.py +0 -0
- /ommlds/cli/{sessions/chat/chat/ai → inputs}/__init__.py +0 -0
- /ommlds/cli/{sessions/chat/chat/state → rendering}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat/user → drivers}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{content → drivers/ai}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/ai/injection.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/events}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{rendering → 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/{tools → drivers/state}/__init__.py +0 -0
- /ommlds/{minichain/content/transforms → cli/sessions/chat/drivers/tools}/__init__.py +0 -0
- {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev466.dist-info → ommlds-0.0.0.dev512.dist-info}/top_level.txt +0 -0
|
@@ -6,8 +6,12 @@ from omlish import lang
|
|
|
6
6
|
from omlish import typedvalues as tv
|
|
7
7
|
|
|
8
8
|
from .._typedvalues import _tv_field_metadata
|
|
9
|
+
from ..metadata import CommonMetadata
|
|
10
|
+
from ..metadata import Metadata
|
|
11
|
+
from ..metadata import MetadataContainerDataclass
|
|
9
12
|
from ..types import Output
|
|
10
13
|
from ..types import OutputT_contra
|
|
14
|
+
from ._origclasses import confer_orig_class
|
|
11
15
|
from ._typedvalues import _TypedValues
|
|
12
16
|
|
|
13
17
|
|
|
@@ -17,6 +21,17 @@ V_co = ta.TypeVar('V_co', covariant=True)
|
|
|
17
21
|
##
|
|
18
22
|
|
|
19
23
|
|
|
24
|
+
class ResponseMetadata(Metadata, lang.Abstract):
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ResponseMetadatas: ta.TypeAlias = ResponseMetadata | CommonMetadata
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@ta.final
|
|
20
35
|
@dc.dataclass(frozen=True)
|
|
21
36
|
@dc.extra_class_params(
|
|
22
37
|
allow_dynamic_dunder_attrs=True,
|
|
@@ -24,11 +39,32 @@ V_co = ta.TypeVar('V_co', covariant=True)
|
|
|
24
39
|
)
|
|
25
40
|
class Response( # type: ignore[type-var] # FIXME: _TypedValues param is invariant
|
|
26
41
|
_TypedValues[OutputT_contra],
|
|
42
|
+
MetadataContainerDataclass[ResponseMetadatas],
|
|
27
43
|
lang.Final,
|
|
28
44
|
ta.Generic[V_co, OutputT_contra],
|
|
29
45
|
):
|
|
46
|
+
"""
|
|
47
|
+
Universal service response, comprised of:
|
|
48
|
+
- a value of type `V_co`
|
|
49
|
+
- a sequence of outputs of type `OutputT_contra`
|
|
50
|
+
- metadata of type `ResponseMetadatas`
|
|
51
|
+
|
|
52
|
+
Refer to the package README.md for an explanation of its type var variance.
|
|
53
|
+
|
|
54
|
+
This class is final, but each instance's `__orig_class__` (if present) is significant. It is encouraged to construct
|
|
55
|
+
these through a pre-parameterized type alias, and the provided `with_` methods should be used rather than
|
|
56
|
+
`dc.replace` (as they will propagate `__orig_class__`).
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
|
|
30
61
|
v: V_co # type: ignore[misc] # FIXME: Cannot use a covariant type variable as a parameter
|
|
31
62
|
|
|
63
|
+
def with_v(self, v: V_co) -> ta.Self: # type: ignore[misc]
|
|
64
|
+
return confer_orig_class(self, dc.replace(self, v=v))
|
|
65
|
+
|
|
66
|
+
#
|
|
67
|
+
|
|
32
68
|
_outputs: ta.Sequence[OutputT_contra] = dc.field(
|
|
33
69
|
default=(),
|
|
34
70
|
metadata=_tv_field_metadata(
|
|
@@ -41,13 +77,47 @@ class Response( # type: ignore[type-var] # FIXME: _TypedValues param is invari
|
|
|
41
77
|
def outputs(self) -> tv.TypedValues[OutputT_contra]:
|
|
42
78
|
return check.isinstance(self._outputs, tv.TypedValues)
|
|
43
79
|
|
|
44
|
-
def with_outputs(self, *outputs: OutputT_contra, override: bool = False) -> ta.Self:
|
|
45
|
-
return dc.replace(self, _outputs=self.outputs.update(*outputs, override=override))
|
|
46
|
-
|
|
47
80
|
@property
|
|
48
81
|
def _typed_values(self) -> tv.TypedValues[OutputT_contra]:
|
|
49
82
|
return check.isinstance(self._outputs, tv.TypedValues)
|
|
50
83
|
|
|
84
|
+
def with_outputs(
|
|
85
|
+
self,
|
|
86
|
+
*add: OutputT_contra,
|
|
87
|
+
discard: ta.Iterable[type] | None = None,
|
|
88
|
+
override: bool = False,
|
|
89
|
+
) -> ta.Self:
|
|
90
|
+
new = (old := self.outputs).update(
|
|
91
|
+
*add,
|
|
92
|
+
discard=discard,
|
|
93
|
+
override=override,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if new is old:
|
|
97
|
+
return self
|
|
98
|
+
|
|
99
|
+
return confer_orig_class(self, dc.replace(self, _outputs=new))
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
|
|
103
|
+
_metadata: ta.Sequence[ResponseMetadatas] = dc.field(
|
|
104
|
+
default=(),
|
|
105
|
+
kw_only=True,
|
|
106
|
+
repr=False,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
MetadataContainerDataclass._configure_metadata_field(_metadata, ResponseMetadatas) # noqa
|
|
110
|
+
|
|
111
|
+
def with_metadata(
|
|
112
|
+
self,
|
|
113
|
+
*add: ResponseMetadatas,
|
|
114
|
+
discard: ta.Iterable[type] | None = None,
|
|
115
|
+
override: bool = False,
|
|
116
|
+
) -> ta.Self:
|
|
117
|
+
return confer_orig_class(self, super().with_metadata(*add, discard=discard, override=override))
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
|
|
51
121
|
def validate(self) -> ta.Self:
|
|
52
122
|
self._check_typed_values()
|
|
53
123
|
return self
|
|
@@ -11,4 +11,13 @@ from .responses import ResponseT_co
|
|
|
11
11
|
|
|
12
12
|
@ta.runtime_checkable
|
|
13
13
|
class Service(lang.ProtocolForbiddenAsBaseClass, ta.Protocol[RequestT_contra, ResponseT_co]):
|
|
14
|
+
"""
|
|
15
|
+
Universal service protocol, comprised of a single method `invoke`, accepting a request of type `RequestT_contra` and
|
|
16
|
+
returning a response of type `ResponseT_co`.
|
|
17
|
+
|
|
18
|
+
Refer to the package README.md for an explanation of its type var variance.
|
|
19
|
+
|
|
20
|
+
This class is final, but each instance's `__orig_class__` (if present) is significant.
|
|
21
|
+
"""
|
|
22
|
+
|
|
14
23
|
def invoke(self, request: RequestT_contra) -> ta.Awaitable[ResponseT_co]: ...
|
ommlds/minichain/standard.py
CHANGED
|
@@ -25,6 +25,14 @@ class Device(tv.UniqueScalarTypedValue[ta.Any], Config):
|
|
|
25
25
|
##
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
# TODO: ApiEndpointPath, ApiEndpointUrl, ApiBaseUrl, ...
|
|
29
|
+
class ApiUrl(tv.UniqueScalarTypedValue[str], Config):
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
|
|
35
|
+
|
|
28
36
|
@dc.dataclass(frozen=True)
|
|
29
37
|
class SecretConfig(Config, lang.Abstract):
|
|
30
38
|
v: sec.SecretRefOrStr = dc.field() | sec.secret_field
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- new_stream_response carry TypeAlias __orig_type__ somehow
|
|
4
|
+
"""
|
|
1
5
|
import abc
|
|
2
6
|
import itertools
|
|
3
7
|
import types
|
|
@@ -104,17 +108,23 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
104
108
|
return _StreamServiceResponse._Emit(self._ssr, item)
|
|
105
109
|
|
|
106
110
|
_state: ta.Literal['new', 'running', 'closed'] = 'new'
|
|
111
|
+
|
|
107
112
|
_sink: _Sink[V]
|
|
108
|
-
|
|
113
|
+
|
|
109
114
|
_cr: ta.Any
|
|
115
|
+
_a: ta.Any
|
|
116
|
+
_g: ta.Any
|
|
110
117
|
|
|
111
118
|
async def __aenter__(self) -> ta.Self:
|
|
112
119
|
check.state(self._state == 'new')
|
|
113
120
|
self._state = 'running'
|
|
121
|
+
|
|
114
122
|
self._sink = _StreamServiceResponse._Sink(self)
|
|
123
|
+
|
|
115
124
|
self._cr = self._fn(self._sink)
|
|
116
125
|
self._a = self._cr.__await__()
|
|
117
126
|
self._g = iter(self._a)
|
|
127
|
+
|
|
118
128
|
return self
|
|
119
129
|
|
|
120
130
|
@types.coroutine
|
|
@@ -123,21 +133,29 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
123
133
|
self._state = 'closed'
|
|
124
134
|
if old_state != 'running':
|
|
125
135
|
return
|
|
136
|
+
|
|
126
137
|
if self._cr.cr_running or self._cr.cr_suspended:
|
|
127
138
|
cex = StreamServiceCancelledError()
|
|
128
|
-
|
|
139
|
+
|
|
140
|
+
i = None
|
|
141
|
+
for n in itertools.count():
|
|
129
142
|
try:
|
|
130
|
-
if not
|
|
143
|
+
if not n:
|
|
131
144
|
x = self._g.throw(cex)
|
|
132
145
|
else:
|
|
133
|
-
x = self._g.send(
|
|
146
|
+
x = self._g.send(i)
|
|
147
|
+
|
|
134
148
|
except StreamServiceCancelledError as cex2:
|
|
135
149
|
if cex2 is cex:
|
|
136
150
|
break
|
|
151
|
+
|
|
137
152
|
raise
|
|
138
|
-
|
|
153
|
+
|
|
154
|
+
i = yield x
|
|
155
|
+
|
|
139
156
|
if self._cr.cr_running:
|
|
140
157
|
raise RuntimeError(f'Coroutine {self._cr!r} not terminated')
|
|
158
|
+
|
|
141
159
|
if self._g is not self._a:
|
|
142
160
|
self._g.close()
|
|
143
161
|
self._a.close()
|
|
@@ -155,14 +173,18 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
155
173
|
@types.coroutine
|
|
156
174
|
def _anext(self):
|
|
157
175
|
check.state(self._state == 'running')
|
|
176
|
+
|
|
177
|
+
i = None
|
|
158
178
|
while True:
|
|
159
179
|
try:
|
|
160
|
-
x = self._g.send(
|
|
180
|
+
x = self._g.send(i)
|
|
181
|
+
|
|
161
182
|
except StopIteration as e:
|
|
162
183
|
if e.value is not None:
|
|
163
184
|
self._outputs = tv.TypedValues(*check.isinstance(e.value, ta.Sequence))
|
|
164
185
|
else:
|
|
165
186
|
self._outputs = tv.TypedValues()
|
|
187
|
+
|
|
166
188
|
raise StopAsyncIteration from None
|
|
167
189
|
|
|
168
190
|
if isinstance(x, _StreamServiceResponse._Emit) and x.ssr is self:
|
|
@@ -170,7 +192,7 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
170
192
|
x.done = True
|
|
171
193
|
return x.value
|
|
172
194
|
|
|
173
|
-
yield x
|
|
195
|
+
i = yield x
|
|
174
196
|
|
|
175
197
|
async def __anext__(self) -> V:
|
|
176
198
|
return await self._anext()
|
|
@@ -195,13 +217,17 @@ async def new_stream_response(
|
|
|
195
217
|
fn: ta.Callable[[StreamResponseSink[V]], ta.Awaitable[ta.Sequence[OutputT] | None]],
|
|
196
218
|
outputs: ta.Sequence[StreamOutputT] | None = None,
|
|
197
219
|
) -> StreamResponse[V, OutputT, StreamOutputT]:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
220
|
+
ssr = _StreamServiceResponse(fn)
|
|
221
|
+
|
|
222
|
+
v = rs.new_managed(await rs.enter_async_context(ssr))
|
|
223
|
+
|
|
224
|
+
try:
|
|
225
|
+
return StreamResponse(v, outputs or [])
|
|
226
|
+
|
|
227
|
+
except BaseException: # noqa
|
|
228
|
+
# The StreamResponse ctor can raise - for example in `_tv_field_coercer` - in which case we need to clean up the
|
|
229
|
+
# resources ref we have already allocated before reraising.
|
|
230
|
+
async with v:
|
|
231
|
+
pass
|
|
232
|
+
|
|
233
|
+
raise
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
A self-contained **pure-Python 3.9+** utility for applying human-readable "pseudo-diff" patch files to a collection of
|
|
21
21
|
text files.
|
|
22
22
|
"""
|
|
23
|
-
import dataclasses as dc
|
|
24
23
|
import enum
|
|
25
24
|
import pathlib
|
|
26
25
|
import typing as ta
|
|
27
26
|
|
|
27
|
+
from omlish import dataclasses as dc
|
|
28
|
+
|
|
28
29
|
|
|
29
30
|
##
|
|
30
31
|
# Domain objects
|
|
@@ -4,7 +4,7 @@ from omlish import check
|
|
|
4
4
|
from omlish import dataclasses as dc
|
|
5
5
|
from omlish import lang
|
|
6
6
|
|
|
7
|
-
from ...content.
|
|
7
|
+
from ...content.content import Content
|
|
8
8
|
from ..fns import ToolFn
|
|
9
9
|
from ..types import ToolSpec
|
|
10
10
|
from .context import ToolContext
|
|
@@ -22,7 +22,7 @@ class ToolCatalogEntry(lang.Final):
|
|
|
22
22
|
|
|
23
23
|
_: dc.KW_ONLY
|
|
24
24
|
|
|
25
|
-
name_override: str | None = dc.xfield(default=None, repr_fn=
|
|
25
|
+
name_override: str | None = dc.xfield(default=None, repr_fn=lang.opt_repr)
|
|
26
26
|
|
|
27
27
|
@property
|
|
28
28
|
def name(self) -> str:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import typing as ta
|
|
2
|
+
|
|
3
|
+
from ...content.content import Content
|
|
4
|
+
from ...content.transform.materialize import ContentMaterializer
|
|
5
|
+
from ...content.transform.materialize import DefaultContentMaterializer
|
|
6
|
+
from .context import ToolContext
|
|
7
|
+
from .errors import ToolExecutionError
|
|
8
|
+
from .executors import ToolExecutor
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ErrorHandlingToolExecutor(ToolExecutor):
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
*,
|
|
18
|
+
wrapped: ToolExecutor,
|
|
19
|
+
content_materializer: ContentMaterializer = DefaultContentMaterializer(),
|
|
20
|
+
) -> None:
|
|
21
|
+
super().__init__()
|
|
22
|
+
|
|
23
|
+
self._wrapped = wrapped
|
|
24
|
+
self._content_materializer = content_materializer
|
|
25
|
+
|
|
26
|
+
async def execute_tool(
|
|
27
|
+
self,
|
|
28
|
+
ctx: ToolContext,
|
|
29
|
+
name: str,
|
|
30
|
+
args: ta.Mapping[str, ta.Any],
|
|
31
|
+
) -> Content:
|
|
32
|
+
try:
|
|
33
|
+
return await self._wrapped.execute_tool(ctx, name, args)
|
|
34
|
+
|
|
35
|
+
except ToolExecutionError as txe:
|
|
36
|
+
return self._content_materializer.materialize(txe.content)
|
|
@@ -2,7 +2,7 @@ import abc
|
|
|
2
2
|
|
|
3
3
|
from omlish import lang
|
|
4
4
|
|
|
5
|
-
from ...content.
|
|
5
|
+
from ...content.content import Content
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
##
|
|
@@ -11,5 +11,5 @@ from ...content.materialize import CanContent
|
|
|
11
11
|
class ToolExecutionError(Exception, lang.Abstract):
|
|
12
12
|
@property
|
|
13
13
|
@abc.abstractmethod
|
|
14
|
-
def content(self) ->
|
|
14
|
+
def content(self) -> Content:
|
|
15
15
|
raise NotImplementedError
|
|
@@ -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.
|
|
11
|
+
from ...content.content import Content
|
|
12
12
|
from ..fns import ToolFn
|
|
13
13
|
from ..fns import execute_tool_fn
|
|
14
14
|
from .context import ToolContext
|
ommlds/minichain/tools/fns.py
CHANGED
|
@@ -4,8 +4,8 @@ TODO:
|
|
|
4
4
|
"""
|
|
5
5
|
from omlish import check
|
|
6
6
|
|
|
7
|
-
from ..content.prepare import ContentStrPreparer
|
|
8
|
-
from ..content.prepare import default_content_str_preparer
|
|
7
|
+
from ..content.transform.prepare import ContentStrPreparer
|
|
8
|
+
from ..content.transform.prepare import default_content_str_preparer
|
|
9
9
|
from .types import EnumToolDtype
|
|
10
10
|
from .types import MappingToolDtype
|
|
11
11
|
from .types import NullableToolDtype
|
|
@@ -15,15 +15,15 @@ import textwrap
|
|
|
15
15
|
import types
|
|
16
16
|
import typing as ta
|
|
17
17
|
|
|
18
|
-
from omdev.py import docstrings
|
|
19
18
|
from omlish import check
|
|
20
19
|
from omlish import collections as col
|
|
21
20
|
from omlish import dataclasses as dc
|
|
21
|
+
from omlish import lang
|
|
22
22
|
from omlish import metadata as md
|
|
23
23
|
from omlish import reflect as rfl
|
|
24
24
|
from omlish.lite.cached import cached_nullary
|
|
25
25
|
|
|
26
|
-
from ..content.
|
|
26
|
+
from ..content.content import Content
|
|
27
27
|
from .types import EnumToolDtype
|
|
28
28
|
from .types import MappingToolDtype
|
|
29
29
|
from .types import NullableToolDtype
|
|
@@ -37,6 +37,10 @@ from .types import TupleToolDtype
|
|
|
37
37
|
from .types import UnionToolDtype
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
with lang.auto_proxy_import(globals()):
|
|
41
|
+
from omdev.py import docstrings
|
|
42
|
+
|
|
43
|
+
|
|
40
44
|
##
|
|
41
45
|
|
|
42
46
|
|
|
@@ -155,7 +159,7 @@ class ToolReflector:
|
|
|
155
159
|
|
|
156
160
|
#
|
|
157
161
|
|
|
158
|
-
def _prepare_desc(self, s:
|
|
162
|
+
def _prepare_desc(self, s: Content | None) -> Content | None:
|
|
159
163
|
if s is None:
|
|
160
164
|
return None
|
|
161
165
|
if not self._raw_descs and isinstance(s, str):
|
|
@@ -174,14 +178,14 @@ class ToolReflector:
|
|
|
174
178
|
for o in md.get_object_metadata(fn, type=_ToolSpecOverride):
|
|
175
179
|
ts_ovr.update({
|
|
176
180
|
k: v
|
|
177
|
-
for k, v in dc.
|
|
181
|
+
for k, v in dc.shallow_asdict(o).items()
|
|
178
182
|
if k != 'params'
|
|
179
183
|
and v is not None
|
|
180
184
|
})
|
|
181
185
|
for op in (o.params or []):
|
|
182
186
|
p_ovr_dct.setdefault(check.non_empty_str(op.name), {}).update({
|
|
183
187
|
k: v
|
|
184
|
-
for k, v in dc.
|
|
188
|
+
for k, v in dc.shallow_asdict(op).items()
|
|
185
189
|
if v is not None
|
|
186
190
|
})
|
|
187
191
|
|
|
@@ -236,7 +240,7 @@ class ToolReflector:
|
|
|
236
240
|
ds_p = ds_p_dct.get(pn)
|
|
237
241
|
sig_p = sig_p_dct.get(pn)
|
|
238
242
|
|
|
239
|
-
p_desc:
|
|
243
|
+
p_desc: Content | None
|
|
240
244
|
if (p_desc := ovr_p.get('desc')) is None:
|
|
241
245
|
if ds_p is not None:
|
|
242
246
|
p_desc = ds_p.description
|
|
@@ -282,7 +286,7 @@ class ToolReflector:
|
|
|
282
286
|
if md_tp is not None:
|
|
283
287
|
tp_kw.update({
|
|
284
288
|
k: v
|
|
285
|
-
for k, v in dc.
|
|
289
|
+
for k, v in dc.shallow_asdict(md_tp).items()
|
|
286
290
|
if v is not None
|
|
287
291
|
})
|
|
288
292
|
|
ommlds/minichain/tools/types.py
CHANGED
|
@@ -6,14 +6,11 @@ from omlish import cached
|
|
|
6
6
|
from omlish import check
|
|
7
7
|
from omlish import collections as col
|
|
8
8
|
from omlish import dataclasses as dc
|
|
9
|
-
from omlish import dispatch
|
|
10
9
|
from omlish import lang
|
|
11
10
|
from omlish import marshal as msh
|
|
12
11
|
from omlish import reflect as rfl
|
|
13
12
|
|
|
14
|
-
from ..content.
|
|
15
|
-
from ..content.transforms.base import ContentTransform
|
|
16
|
-
from ..content.types import Content
|
|
13
|
+
from ..content.content import Content
|
|
17
14
|
|
|
18
15
|
|
|
19
16
|
msh.register_global_module_import('._marshal', __package__)
|
|
@@ -143,14 +140,14 @@ class ObjectToolDtype(ToolDtype):
|
|
|
143
140
|
|
|
144
141
|
|
|
145
142
|
@dc.dataclass(frozen=True)
|
|
146
|
-
@msh.
|
|
147
|
-
@msh.
|
|
143
|
+
@msh.update_fields_options(['name', 'desc', 'type'], omit_if=lang.is_none)
|
|
144
|
+
@msh.update_fields_options(['required'], omit_if=operator.not_)
|
|
148
145
|
class ToolParam:
|
|
149
146
|
name: str | None = None
|
|
150
147
|
|
|
151
148
|
_: dc.KW_ONLY
|
|
152
149
|
|
|
153
|
-
desc:
|
|
150
|
+
desc: Content | None = None
|
|
154
151
|
|
|
155
152
|
type: ToolDtype | None = None
|
|
156
153
|
|
|
@@ -161,19 +158,19 @@ class ToolParam:
|
|
|
161
158
|
|
|
162
159
|
|
|
163
160
|
@dc.dataclass(frozen=True)
|
|
164
|
-
@msh.
|
|
165
|
-
@msh.
|
|
161
|
+
@msh.update_fields_options(['name', 'desc', 'params', 'returns_desc', 'returns_type'], omit_if=lang.is_none)
|
|
162
|
+
@msh.update_fields_options(['allow_additional_params'], omit_if=operator.not_)
|
|
166
163
|
class ToolSpec:
|
|
167
164
|
name: str | None = None
|
|
168
165
|
|
|
169
166
|
_: dc.KW_ONLY
|
|
170
167
|
|
|
171
|
-
desc:
|
|
168
|
+
desc: Content | None = None
|
|
172
169
|
|
|
173
170
|
params: ta.Sequence[ToolParam] | None = None
|
|
174
171
|
allow_additional_params: bool | None = None
|
|
175
172
|
|
|
176
|
-
returns_desc:
|
|
173
|
+
returns_desc: Content | None = None
|
|
177
174
|
returns_type: ToolDtype | None = None
|
|
178
175
|
|
|
179
176
|
@cached.property
|
|
@@ -207,11 +204,11 @@ class ToolUseResult(lang.Final):
|
|
|
207
204
|
##
|
|
208
205
|
|
|
209
206
|
|
|
210
|
-
class _ToolUseContentTransform(ContentTransform, lang.Final, lang.NotInstantiable):
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
207
|
+
# class _ToolUseContentTransform(ContentTransform, lang.Final, lang.NotInstantiable):
|
|
208
|
+
# @dispatch.install_method(ContentTransform.apply)
|
|
209
|
+
# def apply_tool_use(self, tu: ToolUse) -> ToolUse:
|
|
210
|
+
# return tu # TODO: args are Content
|
|
211
|
+
#
|
|
212
|
+
# @dispatch.install_method(ContentTransform.apply)
|
|
213
|
+
# def apply_tool_use_result(self, tur: ToolUseResult) -> ToolUseResult:
|
|
214
|
+
# return dc.replace(tur, c=self.apply(tur.c)) # noqa
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
TODO:
|
|
3
3
|
- serialize as base64 bytes? at least support deserializing as it
|
|
4
4
|
"""
|
|
5
|
-
import dataclasses as dc
|
|
6
5
|
import typing as ta
|
|
7
6
|
|
|
8
7
|
from omlish import check
|
|
8
|
+
from omlish import dataclasses as dc
|
|
9
9
|
from omlish import lang
|
|
10
10
|
from omlish import marshal as msh
|
|
11
11
|
from omlish import reflect as rfl
|