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
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"""
|
|
2
|
+
https://modelcontextprotocol.io/specification/2025-06-18
|
|
3
|
+
https://modelcontextprotocol.io/specification/2025-06-18/schema
|
|
4
|
+
|
|
5
|
+
TODO:
|
|
6
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/cancellation
|
|
7
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/basic/utilities/progress
|
|
8
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/client/sampling
|
|
9
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation
|
|
10
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/server/prompts
|
|
11
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/server/resources
|
|
12
|
+
- https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/logging
|
|
13
|
+
"""
|
|
14
|
+
import abc
|
|
15
|
+
import typing as ta
|
|
16
|
+
|
|
17
|
+
from omlish import collections as col
|
|
18
|
+
from omlish import dataclasses as dc
|
|
19
|
+
from omlish import lang
|
|
20
|
+
from omlish import marshal as msh
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
ClientRequestT = ta.TypeVar('ClientRequestT', bound='ClientRequest')
|
|
24
|
+
ClientResultT = ta.TypeVar('ClientResultT', bound='ClientResult')
|
|
25
|
+
|
|
26
|
+
ServerRequestT = ta.TypeVar('ServerRequestT', bound='ServerRequest')
|
|
27
|
+
ServerResultT = ta.TypeVar('ServerResultT', bound='ServerResult')
|
|
28
|
+
|
|
29
|
+
CursorClientRequestT = ta.TypeVar('CursorClientRequestT', bound='CursorClientRequest')
|
|
30
|
+
CursorClientResultT = ta.TypeVar('CursorClientResultT', bound='CursorClientResult')
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
msh.register_global_module_import('._marshal', __package__)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _set_class_marshal_options(cls):
|
|
40
|
+
msh.update_object_options(
|
|
41
|
+
cls,
|
|
42
|
+
field_naming=msh.Naming.LOW_CAMEL,
|
|
43
|
+
field_defaults=msh.FieldOptions(
|
|
44
|
+
omit_if=lang.is_none,
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
return cls
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
54
|
+
class Message(lang.Sealed, lang.Abstract):
|
|
55
|
+
@property
|
|
56
|
+
@abc.abstractmethod
|
|
57
|
+
def json_rpc_method_name(self) -> str:
|
|
58
|
+
raise NotImplementedError
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ClientRequest(Message, lang.Abstract, ta.Generic[ClientResultT]):
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ClientResult(Message, lang.Abstract, ta.Generic[ClientRequestT]):
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ServerRequest(Message, lang.Abstract, ta.Generic[ServerResultT]):
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class ServerResult(Message, lang.Abstract, ta.Generic[ServerRequestT]):
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Notification(Message, lang.Abstract):
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
94
|
+
class WithMeta(lang.Sealed, lang.Abstract):
|
|
95
|
+
meta_: ta.Mapping[str, ta.Any] | None = dc.field(default=None) | msh.with_field_options(name='_meta')
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
102
|
+
@_set_class_marshal_options
|
|
103
|
+
class Implementation(lang.Final):
|
|
104
|
+
name: str
|
|
105
|
+
version: str
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
DEFAULT_PROTOCOL_VERSION = '2025-06-18'
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
112
|
+
@_set_class_marshal_options
|
|
113
|
+
class ClientCapabilities(lang.Final):
|
|
114
|
+
elicitation: ta.Any | None = None
|
|
115
|
+
|
|
116
|
+
experimental: ta.Mapping[str, ta.Any] | None = None
|
|
117
|
+
|
|
118
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
119
|
+
@_set_class_marshal_options
|
|
120
|
+
class Roots:
|
|
121
|
+
list_changed: bool | None = None
|
|
122
|
+
|
|
123
|
+
roots: Roots | None = None
|
|
124
|
+
|
|
125
|
+
sampling: ta.Any | None = None
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
129
|
+
@_set_class_marshal_options
|
|
130
|
+
class InitializeRequest(ClientRequest['InitializeResult']):
|
|
131
|
+
json_rpc_method_name: ta.ClassVar[str] = 'initialize'
|
|
132
|
+
|
|
133
|
+
client_info: Implementation
|
|
134
|
+
protocol_version: str = DEFAULT_PROTOCOL_VERSION
|
|
135
|
+
capabilities: ClientCapabilities = ClientCapabilities()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
139
|
+
@_set_class_marshal_options
|
|
140
|
+
class ServerCapabilities:
|
|
141
|
+
completions: ta.Any | None = None
|
|
142
|
+
|
|
143
|
+
experimental: ta.Mapping[str, ta.Any] | None = None
|
|
144
|
+
|
|
145
|
+
logging: ta.Any | None = None
|
|
146
|
+
|
|
147
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
148
|
+
@_set_class_marshal_options
|
|
149
|
+
class Prompts:
|
|
150
|
+
list_changed: bool | None = None
|
|
151
|
+
|
|
152
|
+
prompts: Prompts | None = None
|
|
153
|
+
|
|
154
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
155
|
+
@_set_class_marshal_options
|
|
156
|
+
class Resources:
|
|
157
|
+
list_changed: bool | None = None
|
|
158
|
+
subscribe: bool | None = None
|
|
159
|
+
|
|
160
|
+
resources: Resources | None = None
|
|
161
|
+
|
|
162
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
163
|
+
@_set_class_marshal_options
|
|
164
|
+
class Tools:
|
|
165
|
+
list_changed: bool | None = None
|
|
166
|
+
|
|
167
|
+
tools: Tools | None = None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
171
|
+
@_set_class_marshal_options
|
|
172
|
+
class InitializeResult(ClientResult[InitializeRequest], WithMeta):
|
|
173
|
+
json_rpc_method_name: ta.ClassVar[str] = 'initialize'
|
|
174
|
+
|
|
175
|
+
server_info: Implementation
|
|
176
|
+
protocol_version: str
|
|
177
|
+
capabilities: ServerCapabilities
|
|
178
|
+
instructions: str | None = None
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
182
|
+
@_set_class_marshal_options
|
|
183
|
+
class InitializedNotification(Notification):
|
|
184
|
+
json_rpc_method_name: ta.ClassVar[str] = 'initialized'
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
##
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
191
|
+
class CursorClientRequest(ClientRequest[CursorClientResultT], lang.Abstract):
|
|
192
|
+
cursor: str | None = None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
196
|
+
class CursorClientResult(ClientResult[CursorClientRequestT], lang.Abstract):
|
|
197
|
+
next_cursor: str | None = None
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
##
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
204
|
+
@_set_class_marshal_options
|
|
205
|
+
class ToolAnnotations(lang.Final):
|
|
206
|
+
destructive_hint: bool | None = None
|
|
207
|
+
idempotent_hint: bool | None = None
|
|
208
|
+
open_world_hint: bool | None = None
|
|
209
|
+
read_only_hint: bool | None = None
|
|
210
|
+
title: str | None = None
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
214
|
+
@_set_class_marshal_options
|
|
215
|
+
class Tool(WithMeta, lang.Final):
|
|
216
|
+
name: str
|
|
217
|
+
title: str | None = None
|
|
218
|
+
|
|
219
|
+
description: str | None = None
|
|
220
|
+
|
|
221
|
+
annotations: ToolAnnotations | None = None
|
|
222
|
+
|
|
223
|
+
input_schema: ta.Any
|
|
224
|
+
output_schema: ta.Any | None = None
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
228
|
+
@_set_class_marshal_options
|
|
229
|
+
class ListToolsRequest(CursorClientRequest['ListToolsResult']):
|
|
230
|
+
json_rpc_method_name: ta.ClassVar[str] = 'tools/list'
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
234
|
+
@_set_class_marshal_options
|
|
235
|
+
class ListToolsResult(CursorClientResult[ListToolsRequest], WithMeta):
|
|
236
|
+
json_rpc_method_name: ta.ClassVar[str] = 'tools/list'
|
|
237
|
+
|
|
238
|
+
tools: ta.Sequence[Tool]
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
##
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class ContentBlock(lang.Abstract):
|
|
245
|
+
pass
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
249
|
+
@_set_class_marshal_options
|
|
250
|
+
class TextContentBlock(ContentBlock, lang.Final):
|
|
251
|
+
text: str
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
##
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
258
|
+
@_set_class_marshal_options
|
|
259
|
+
class CallToolRequest(ClientRequest['CallToolResult']):
|
|
260
|
+
json_rpc_method_name: ta.ClassVar[str] = 'tools/call'
|
|
261
|
+
|
|
262
|
+
name: str
|
|
263
|
+
arguments: ta.Mapping[str, ta.Any] | None = None
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
267
|
+
@_set_class_marshal_options
|
|
268
|
+
class CallToolResult(ClientResult[CallToolRequest], WithMeta):
|
|
269
|
+
json_rpc_method_name: ta.ClassVar[str] = 'tools/call'
|
|
270
|
+
|
|
271
|
+
content: ta.Sequence[ContentBlock]
|
|
272
|
+
is_error: bool | None = None
|
|
273
|
+
structured_content: ta.Mapping[str, ta.Any] | None = None
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
##
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
280
|
+
@_set_class_marshal_options
|
|
281
|
+
class PingClientRequest(ClientRequest['PingClientResult'], WithMeta):
|
|
282
|
+
json_rpc_method_name: ta.ClassVar[str] = 'ping'
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
286
|
+
@_set_class_marshal_options
|
|
287
|
+
class PingClientResult(ClientResult[PingClientRequest]):
|
|
288
|
+
json_rpc_method_name: ta.ClassVar[str] = 'ping'
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
292
|
+
@_set_class_marshal_options
|
|
293
|
+
class PingServerRequest(ServerRequest['PingServerResult'], WithMeta):
|
|
294
|
+
json_rpc_method_name: ta.ClassVar[str] = 'ping'
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
298
|
+
@_set_class_marshal_options
|
|
299
|
+
class PingServerResult(ServerResult[PingServerRequest]):
|
|
300
|
+
json_rpc_method_name: ta.ClassVar[str] = 'ping'
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
##
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
307
|
+
@_set_class_marshal_options
|
|
308
|
+
class PromptArgument(lang.Final):
|
|
309
|
+
name: str
|
|
310
|
+
title: str | None = None
|
|
311
|
+
|
|
312
|
+
description: str | None = None
|
|
313
|
+
|
|
314
|
+
required: bool | None = None
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
318
|
+
@_set_class_marshal_options
|
|
319
|
+
class Prompt(WithMeta, lang.Final):
|
|
320
|
+
name: str
|
|
321
|
+
title: str | None = None
|
|
322
|
+
|
|
323
|
+
description: str | None = None
|
|
324
|
+
|
|
325
|
+
arguments: ta.Sequence[PromptArgument] | None = None
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
329
|
+
@_set_class_marshal_options
|
|
330
|
+
class ListPromptsRequest(CursorClientRequest['ListPromptsResult']):
|
|
331
|
+
json_rpc_method_name: ta.ClassVar[str] = 'prompts/list'
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
335
|
+
@_set_class_marshal_options
|
|
336
|
+
class ListPromptsResult(CursorClientResult[ListPromptsRequest], WithMeta):
|
|
337
|
+
json_rpc_method_name: ta.ClassVar[str] = 'prompts/list'
|
|
338
|
+
|
|
339
|
+
prompts: ta.Sequence[Prompt]
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
##
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
LoggingLevel: ta.TypeAlias = ta.Literal[
|
|
346
|
+
'debug',
|
|
347
|
+
'info',
|
|
348
|
+
'notice',
|
|
349
|
+
'warning',
|
|
350
|
+
'error',
|
|
351
|
+
'critical',
|
|
352
|
+
'alert',
|
|
353
|
+
'emergency',
|
|
354
|
+
]
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
##
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
MESSAGE_TYPES_BY_JSON_RPC_METHOD_NAME: ta.Mapping[type[Message], ta.Mapping[str, type[Message]]] = {
|
|
361
|
+
bty: col.make_map_by(lambda mty: mty.json_rpc_method_name, lang.deep_subclasses(bty, concrete_only=True)) # type: ignore # noqa
|
|
362
|
+
for bty in [
|
|
363
|
+
ClientRequest,
|
|
364
|
+
ClientResult,
|
|
365
|
+
ServerRequest,
|
|
366
|
+
ServerResult,
|
|
367
|
+
Notification,
|
|
368
|
+
]
|
|
369
|
+
}
|
ommlds/tools/git.py
CHANGED
|
@@ -3,30 +3,25 @@ TODO:
|
|
|
3
3
|
- move omit magic to omdev lol
|
|
4
4
|
"""
|
|
5
5
|
import abc
|
|
6
|
-
import concurrent.futures as cf
|
|
7
6
|
import dataclasses as dc
|
|
8
|
-
import os.path
|
|
9
7
|
import re
|
|
10
8
|
import typing as ta
|
|
11
9
|
import urllib.request
|
|
12
10
|
|
|
13
11
|
from omdev.git.magic import GIT_DIFF_OMIT_MAGIC_COMMENT
|
|
14
|
-
from omdev.
|
|
12
|
+
from omdev.py.srcheaders import get_py_header_lines
|
|
15
13
|
from omdev.tools.git.messages import GitMessageGenerator
|
|
16
14
|
from omlish import check
|
|
17
15
|
from omlish import lang
|
|
18
16
|
from omlish.configs.classes import Configurable
|
|
17
|
+
from omlish.http import all as http
|
|
19
18
|
from omlish.subprocesses.sync import subprocesses
|
|
20
19
|
|
|
21
20
|
from .. import minichain as mc
|
|
22
|
-
from ..
|
|
21
|
+
from ..cli.secrets import install_env_secrets
|
|
23
22
|
from ..server.client import McServerClient
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
with lang.auto_proxy_import(globals()):
|
|
27
|
-
from ..minichain.backends.impls.mlx import chat as mc_mlx_chat
|
|
28
|
-
|
|
29
|
-
|
|
30
25
|
GitAiBackendConfigT = ta.TypeVar('GitAiBackendConfigT', bound='GitAiBackend.Config')
|
|
31
26
|
|
|
32
27
|
|
|
@@ -34,7 +29,7 @@ GitAiBackendConfigT = ta.TypeVar('GitAiBackendConfigT', bound='GitAiBackend.Conf
|
|
|
34
29
|
|
|
35
30
|
|
|
36
31
|
class GitAiBackend(Configurable[GitAiBackendConfigT], lang.Abstract):
|
|
37
|
-
@dc.dataclass(frozen=True)
|
|
32
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
38
33
|
class Config(Configurable.Config):
|
|
39
34
|
max_tokens: int | None = 128
|
|
40
35
|
|
|
@@ -62,21 +57,36 @@ def _get_single_ai_message_str(resp: mc.ChatChoicesResponse) -> str:
|
|
|
62
57
|
#
|
|
63
58
|
|
|
64
59
|
|
|
65
|
-
class
|
|
66
|
-
@dc.dataclass(frozen=True)
|
|
60
|
+
class StandardGitAiBackend(GitAiBackend['StandardGitAiBackend.Config']):
|
|
61
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
67
62
|
class Config(GitAiBackend.Config):
|
|
68
|
-
|
|
63
|
+
backend: str | None = None
|
|
69
64
|
|
|
70
|
-
|
|
65
|
+
DEFAULT_BACKEND_NAME: str = 'openai'
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
config: Config = Config(),
|
|
70
|
+
*,
|
|
71
|
+
backend_catalog: ta.Optional['mc.BackendCatalog'] = None,
|
|
72
|
+
) -> None:
|
|
71
73
|
super().__init__(config)
|
|
72
74
|
|
|
75
|
+
if backend_catalog is None:
|
|
76
|
+
backend_catalog = mc.BackendStringBackendCatalog()
|
|
77
|
+
self._backend_catalog = backend_catalog
|
|
78
|
+
|
|
73
79
|
def run_prompt(self, prompt: str) -> str:
|
|
74
|
-
# FIXME
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
install_env_secrets() # FIXME
|
|
81
|
+
|
|
82
|
+
be = self._backend_catalog.get_backend(
|
|
83
|
+
mc.ChatChoicesService, # type: ignore[type-abstract]
|
|
84
|
+
self._config.backend or self.DEFAULT_BACKEND_NAME,
|
|
85
|
+
)
|
|
78
86
|
|
|
79
|
-
llm =
|
|
87
|
+
llm = be.factory(
|
|
88
|
+
http_client=http.SyncAsyncHttpClient(http.client()), # FIXME
|
|
89
|
+
)
|
|
80
90
|
|
|
81
91
|
resp = lang.sync_await(llm.invoke(mc.ChatChoicesRequest(
|
|
82
92
|
[mc.UserMessage(prompt)],
|
|
@@ -94,51 +104,51 @@ def _strip_markdown_code_block(text: str) -> str:
|
|
|
94
104
|
return match.group(1)
|
|
95
105
|
|
|
96
106
|
|
|
97
|
-
class MlxGitAiBackend(GitAiBackend['MlxGitAiBackend.Config']):
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
107
|
+
# class MlxGitAiBackend(GitAiBackend['MlxGitAiBackend.Config']):
|
|
108
|
+
# @dc.dataclass(frozen=True, kw_only=True)
|
|
109
|
+
# class Config(GitAiBackend.Config):
|
|
110
|
+
# model: str = 'mlx-community/Qwen2.5-Coder-32B-Instruct-8bit'
|
|
111
|
+
#
|
|
112
|
+
# run_in_subprocess: bool = True
|
|
113
|
+
# subprocess_timeout: float | None = 60.
|
|
114
|
+
#
|
|
115
|
+
# def __init__(self, config: Config = Config()) -> None:
|
|
116
|
+
# super().__init__(config)
|
|
117
|
+
#
|
|
118
|
+
# def _run_prompt(self, prompt: str) -> str:
|
|
119
|
+
# with mc_mlx_chat.MlxChatChoicesService(mc.ModelRepo.parse(self._config.model)) as llm:
|
|
120
|
+
# resp = lang.sync_await(llm.invoke(mc.ChatChoicesRequest(
|
|
121
|
+
# [mc.UserMessage(prompt)],
|
|
122
|
+
# # FIXME: *((MaxTokens(self._config.max_tokens),) if self._config.max_tokens is not None else ()),
|
|
123
|
+
# )))
|
|
124
|
+
# text = _get_single_ai_message_str(resp)
|
|
125
|
+
#
|
|
126
|
+
# text = _strip_markdown_code_block(text)
|
|
127
|
+
#
|
|
128
|
+
# return text
|
|
129
|
+
#
|
|
130
|
+
# def run_prompt(self, prompt: str) -> str:
|
|
131
|
+
# if self._config.run_in_subprocess:
|
|
132
|
+
# # tokenizers installs a pthread_atfork callback at *import* time:
|
|
133
|
+
# # https://github.com/huggingface/tokenizers/blob/4f1a810aa258d287e6936315e63fbf58bde2a980/bindings/python/src/lib.rs#L57 # noqa
|
|
134
|
+
# # then complains about `TOKENIZERS_PARALLELISM` at the next fork (which presumably will happen immediately
|
|
135
|
+
# # after this to `git commit`, despite it being conceptually just a fork/exe).
|
|
136
|
+
# # TODO: a generic subprocessing minichain service wrapper?
|
|
137
|
+
# with cf.ProcessPoolExecutor() as exe:
|
|
138
|
+
# return exe.submit(
|
|
139
|
+
# self._run_prompt,
|
|
140
|
+
# prompt,
|
|
141
|
+
# ).result(timeout=self._config.subprocess_timeout)
|
|
142
|
+
#
|
|
143
|
+
# else:
|
|
144
|
+
# return self._run_prompt(prompt)
|
|
135
145
|
|
|
136
146
|
|
|
137
147
|
#
|
|
138
148
|
|
|
139
149
|
|
|
140
150
|
class LocalhostHttpPostGitAiBackend(GitAiBackend['LocalhostHttpPostGitAiBackend.Config']):
|
|
141
|
-
@dc.dataclass(frozen=True)
|
|
151
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
142
152
|
class Config(GitAiBackend.Config):
|
|
143
153
|
port: int = 5067
|
|
144
154
|
path: str = ''
|
|
@@ -162,7 +172,7 @@ class LocalhostHttpPostGitAiBackend(GitAiBackend['LocalhostHttpPostGitAiBackend.
|
|
|
162
172
|
|
|
163
173
|
|
|
164
174
|
class McServerGitAiBackend(GitAiBackend['McServerGitAiBackend.Config']):
|
|
165
|
-
@dc.dataclass(frozen=True)
|
|
175
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
166
176
|
class Config(GitAiBackend.Config):
|
|
167
177
|
pass
|
|
168
178
|
|
|
@@ -188,18 +198,23 @@ class AiGitMessageGenerator(GitMessageGenerator):
|
|
|
188
198
|
def __init__(
|
|
189
199
|
self,
|
|
190
200
|
*,
|
|
191
|
-
backend: GitAiBackend | None = None,
|
|
201
|
+
backend: GitAiBackend | str | None = None,
|
|
192
202
|
) -> None:
|
|
193
203
|
super().__init__()
|
|
194
204
|
|
|
195
205
|
if backend is None:
|
|
196
206
|
backend = self.DEFAULT_BACKEND
|
|
197
|
-
|
|
207
|
+
elif isinstance(backend, str):
|
|
208
|
+
backend = StandardGitAiBackend(
|
|
209
|
+
config=StandardGitAiBackend.Config(
|
|
210
|
+
backend=backend,
|
|
211
|
+
),
|
|
212
|
+
)
|
|
213
|
+
self._backend = check.isinstance(backend, GitAiBackend)
|
|
198
214
|
|
|
199
215
|
DEFAULT_BACKEND: ta.ClassVar[GitAiBackend] = (
|
|
200
|
-
|
|
216
|
+
StandardGitAiBackend()
|
|
201
217
|
# LocalhostHttpPostGitAiBackend()
|
|
202
|
-
# MlxGitAiBackend()
|
|
203
218
|
# McServerGitAiBackend()
|
|
204
219
|
)
|
|
205
220
|
|
|
@@ -213,9 +228,14 @@ class AiGitMessageGenerator(GitMessageGenerator):
|
|
|
213
228
|
except FileNotFoundError:
|
|
214
229
|
return False
|
|
215
230
|
|
|
231
|
+
hls = get_py_header_lines(f_src)
|
|
232
|
+
|
|
216
233
|
return any(
|
|
217
|
-
|
|
218
|
-
|
|
234
|
+
hl.src.strip() in (
|
|
235
|
+
'# @omlish-generated',
|
|
236
|
+
GIT_DIFF_OMIT_MAGIC_COMMENT,
|
|
237
|
+
)
|
|
238
|
+
for hl in hls
|
|
219
239
|
)
|
|
220
240
|
|
|
221
241
|
# TODO: configurable
|
ommlds/tools/ocr.py
CHANGED
ommlds/wiki/analyze.py
CHANGED
|
@@ -213,7 +213,7 @@ class FileAnalyzer:
|
|
|
213
213
|
self.verbose and print()
|
|
214
214
|
return True
|
|
215
215
|
|
|
216
|
-
@logs.
|
|
216
|
+
@logs.exception_logging(log)
|
|
217
217
|
def run(self, file_name: str) -> None:
|
|
218
218
|
log.info(f'{self._ctx.deathpact=} {file_name}') # noqa
|
|
219
219
|
|
|
@@ -268,7 +268,7 @@ class FileAnalyzer:
|
|
|
268
268
|
self._flush_rows()
|
|
269
269
|
|
|
270
270
|
|
|
271
|
-
@logs.
|
|
271
|
+
@logs.exception_logging(log)
|
|
272
272
|
def analyze_file(
|
|
273
273
|
file_name: str,
|
|
274
274
|
db_url: str,
|
ommlds/wiki/models.py
CHANGED
|
@@ -51,7 +51,7 @@ class Redirect:
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
@dc.dataclass(frozen=True)
|
|
54
|
-
@msh.
|
|
54
|
+
@msh.update_fields_options([
|
|
55
55
|
'username',
|
|
56
56
|
'id',
|
|
57
57
|
'ip',
|
|
@@ -78,7 +78,7 @@ class RevisionText:
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
@dc.dataclass(frozen=True)
|
|
81
|
-
@msh.
|
|
81
|
+
@msh.update_fields_options([
|
|
82
82
|
'parentid',
|
|
83
83
|
'timestamp',
|
|
84
84
|
'contributors',
|
|
@@ -108,7 +108,7 @@ class Revision:
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
@dc.dataclass(frozen=True)
|
|
111
|
-
@msh.
|
|
111
|
+
@msh.update_fields_options([
|
|
112
112
|
'timestamp',
|
|
113
113
|
'contributor',
|
|
114
114
|
'comment',
|
|
@@ -129,7 +129,7 @@ class Upload:
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
@dc.dataclass(frozen=True)
|
|
132
|
-
@msh.
|
|
132
|
+
@msh.update_fields_options([
|
|
133
133
|
'redirect',
|
|
134
134
|
'restrictions',
|
|
135
135
|
'revisions',
|