ommlds 0.0.0.dev366__tar.gz → 0.0.0.dev368__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. {ommlds-0.0.0.dev366/ommlds.egg-info → ommlds-0.0.0.dev368}/PKG-INFO +3 -3
  2. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/__init__.py +6 -0
  3. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/anthropic/chat.py +2 -2
  4. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/google/chat.py +4 -4
  5. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/llamacpp/format.py +2 -2
  6. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/mistral.py +2 -2
  7. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/mlx/chat.py +3 -3
  8. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/format.py +1 -1
  9. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/tinygrad/chat.py +1 -1
  10. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/transformers/transformers.py +1 -1
  11. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/messages.py +2 -2
  12. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/_marshal.py +2 -6
  13. ommlds-0.0.0.dev368/ommlds/minichain/content/materialize.py +203 -0
  14. ommlds-0.0.0.dev368/ommlds/minichain/content/placeholders.py +20 -0
  15. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/lib/fs/ls/rendering.py +82 -57
  16. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368/ommlds.egg-info}/PKG-INFO +3 -3
  17. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds.egg-info/SOURCES.txt +1 -0
  18. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds.egg-info/requires.txt +2 -2
  19. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/pyproject.toml +3 -3
  20. ommlds-0.0.0.dev366/ommlds/minichain/content/materialize.py +0 -112
  21. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/LICENSE +0 -0
  22. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/MANIFEST.in +0 -0
  23. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/README.md +0 -0
  24. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/.manifests.json +0 -0
  25. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/__about__.py +0 -0
  26. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/__init__.py +0 -0
  27. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/__init__.py +0 -0
  28. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/__init__.py +0 -0
  29. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/__init__.py +0 -0
  30. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/marshal.py +0 -0
  31. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/sse/__init__.py +0 -0
  32. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/sse/assemble.py +0 -0
  33. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/sse/events.py +0 -0
  34. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/sse/marshal.py +0 -0
  35. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/anthropic/protocol/types.py +0 -0
  36. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/llamacpp/__init__.py +0 -0
  37. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/llamacpp/buildwheel.py +0 -0
  38. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/llamacpp/logging.py +0 -0
  39. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/__init__.py +0 -0
  40. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/__main__.py +0 -0
  41. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/caching.py +0 -0
  42. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/cli.py +0 -0
  43. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/generation.py +0 -0
  44. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/limits.py +0 -0
  45. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/loading.py +0 -0
  46. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/LICENSE +0 -0
  47. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/__init__.py +0 -0
  48. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/detokenization/__init__.py +0 -0
  49. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/detokenization/base.py +0 -0
  50. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/detokenization/bpe.py +0 -0
  51. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/detokenization/naive.py +0 -0
  52. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/detokenization/spm.py +0 -0
  53. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/loading.py +0 -0
  54. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/tokenization.py +0 -0
  55. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/mlx/tokenization/types.py +0 -0
  56. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/__init__.py +0 -0
  57. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/__init__.py +0 -0
  58. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/__init__.py +0 -0
  59. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/chunk.py +0 -0
  60. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/contentpart.py +0 -0
  61. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/message.py +0 -0
  62. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/request.py +0 -0
  63. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/response.py +0 -0
  64. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/responseformat.py +0 -0
  65. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/chatcompletion/tokenlogprob.py +0 -0
  66. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/openai/protocol/completionusage.py +0 -0
  67. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/__init__.py +0 -0
  68. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/LICENSE +0 -0
  69. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/__init__.py +0 -0
  70. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/__init__.py +0 -0
  71. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/__main__.py +0 -0
  72. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/attention.py +0 -0
  73. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/cli.py +0 -0
  74. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/fetch.py +0 -0
  75. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/llm.py +0 -0
  76. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/loading.py +0 -0
  77. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/quantization.py +0 -0
  78. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/sampling.py +0 -0
  79. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/tokenization.py +0 -0
  80. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/llama3/transformer.py +0 -0
  81. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/__init__.py +0 -0
  82. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/__main__.py +0 -0
  83. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/cli.py +0 -0
  84. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/clip.py +0 -0
  85. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/sdxl.py +0 -0
  86. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/models/sdxl/unet.py +0 -0
  87. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/tinygrad/tinygrad.py +0 -0
  88. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/torch/__init__.py +0 -0
  89. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/torch/backends.py +0 -0
  90. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/torch/devices.py +0 -0
  91. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/backends/torch/purge.py +0 -0
  92. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/__init__.py +0 -0
  93. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/__main__.py +0 -0
  94. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/inject.py +0 -0
  95. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/main.py +0 -0
  96. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/__init__.py +0 -0
  97. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/base.py +0 -0
  98. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/chat.py +0 -0
  99. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/completion.py +0 -0
  100. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/embedding.py +0 -0
  101. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/sessions/inject.py +0 -0
  102. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/state.py +0 -0
  103. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/tools/__init__.py +0 -0
  104. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/tools/inject.py +0 -0
  105. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/cli/tools/tools.py +0 -0
  106. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/datasets/__init__.py +0 -0
  107. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/datasets/library/__init__.py +0 -0
  108. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/datasets/library/movies.py +0 -0
  109. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/hacks/__init__.py +0 -0
  110. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/hacks/patches.py +0 -0
  111. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/huggingface.py +0 -0
  112. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/_abc.py +0 -0
  113. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/_typedvalues.py +0 -0
  114. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/__init__.py +0 -0
  115. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/anthropic/__init__.py +0 -0
  116. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/duckduckgo.py +0 -0
  117. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/google/__init__.py +0 -0
  118. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/google/search.py +0 -0
  119. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/huggingface.py +0 -0
  120. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/llamacpp/__init__.py +0 -0
  121. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/llamacpp/chat.py +0 -0
  122. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/llamacpp/completion.py +0 -0
  123. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/llamacpp/stream.py +0 -0
  124. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/mlx/__init__.py +0 -0
  125. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/__init__.py +0 -0
  126. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/chat.py +0 -0
  127. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/completion.py +0 -0
  128. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/embedding.py +0 -0
  129. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/openai/stream.py +0 -0
  130. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/sentencepiece/__init__.py +0 -0
  131. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/sentencepiece/tokens.py +0 -0
  132. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/sqlite.py +0 -0
  133. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/tinygrad/__init__.py +0 -0
  134. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/tokenizers/__init__.py +0 -0
  135. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/tokenizers/tokens.py +0 -0
  136. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/transformers/__init__.py +0 -0
  137. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/transformers/sentence.py +0 -0
  138. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/backends/transformers/tokens.py +0 -0
  139. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/__init__.py +0 -0
  140. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/_marshal.py +0 -0
  141. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/choices/__init__.py +0 -0
  142. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/choices/adapters.py +0 -0
  143. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/choices/services.py +0 -0
  144. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/choices/types.py +0 -0
  145. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/formats.py +0 -0
  146. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/history.py +0 -0
  147. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/metadata.py +0 -0
  148. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/services.py +0 -0
  149. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/stream/__init__.py +0 -0
  150. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/stream/adapters.py +0 -0
  151. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/stream/services.py +0 -0
  152. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/stream/types.py +0 -0
  153. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/templating.py +0 -0
  154. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/tools.py +0 -0
  155. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/transforms/__init__.py +0 -0
  156. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/transforms/base.py +0 -0
  157. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/transforms/uuids.py +0 -0
  158. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/chat/types.py +0 -0
  159. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/completion.py +0 -0
  160. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/configs.py +0 -0
  161. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/__init__.py +0 -0
  162. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/images.py +0 -0
  163. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/metadata.py +0 -0
  164. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/namespaces.py +0 -0
  165. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/prepare.py +0 -0
  166. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/rendering.py +0 -0
  167. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/sequence.py +0 -0
  168. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/simple.py +0 -0
  169. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/text.py +0 -0
  170. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/__init__.py +0 -0
  171. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/base.py +0 -0
  172. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/interleave.py +0 -0
  173. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/squeeze.py +0 -0
  174. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/stringify.py +0 -0
  175. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/transforms/strings.py +0 -0
  176. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/content/types.py +0 -0
  177. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/docs/__init__.py +0 -0
  178. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/docs/docs.py +0 -0
  179. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/docs/dtypes.py +0 -0
  180. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/docs/filters.py +0 -0
  181. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/envs.py +0 -0
  182. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/json.py +0 -0
  183. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/lib/__init__.py +0 -0
  184. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/lib/fs/__init__.py +0 -0
  185. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/lib/fs/ls/__init__.py +0 -0
  186. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/lib/fs/ls/running.py +0 -0
  187. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/llms/__init__.py +0 -0
  188. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/llms/_marshal.py +0 -0
  189. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/llms/tokens.py +0 -0
  190. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/llms/types.py +0 -0
  191. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/metadata.py +0 -0
  192. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/registry.py +0 -0
  193. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/resources.py +0 -0
  194. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/search.py +0 -0
  195. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/__init__.py +0 -0
  196. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/_marshal.py +0 -0
  197. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/_origclasses.py +0 -0
  198. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/_typedvalues.py +0 -0
  199. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/facades.py +0 -0
  200. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/requests.py +0 -0
  201. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/responses.py +0 -0
  202. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/services/services.py +0 -0
  203. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/standard.py +0 -0
  204. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/stream/__init__.py +0 -0
  205. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/stream/services.py +0 -0
  206. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/stream/wrap.py +0 -0
  207. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/__init__.py +0 -0
  208. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/applypatch.py +0 -0
  209. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/__init__.py +0 -0
  210. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/base.py +0 -0
  211. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/dumb.py +0 -0
  212. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/LICENSE +0 -0
  213. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/__init__.py +0 -0
  214. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/hermes2.py +0 -0
  215. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/llama31.py +0 -0
  216. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/types.py +0 -0
  217. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/text/toolparsing/llamacpp/utils.py +0 -0
  218. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tokens/__init__.py +0 -0
  219. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tokens/specials.py +0 -0
  220. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tokens/tokenizers.py +0 -0
  221. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tokens/types.py +0 -0
  222. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tokens/vocabs.py +0 -0
  223. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tools/__init__.py +0 -0
  224. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tools/_marshal.py +0 -0
  225. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tools/jsonschema.py +0 -0
  226. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tools/reflect.py +0 -0
  227. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/tools/types.py +0 -0
  228. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/types.py +0 -0
  229. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/__init__.py +0 -0
  230. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/embeddings.py +0 -0
  231. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/index.py +0 -0
  232. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/search.py +0 -0
  233. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/similarity.py +0 -0
  234. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/stores.py +0 -0
  235. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/minichain/vectors/types.py +0 -0
  236. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/__init__.py +0 -0
  237. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/__main__.py +0 -0
  238. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/cli.py +0 -0
  239. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/client.py +0 -0
  240. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/server.py +0 -0
  241. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/server/service.py +0 -0
  242. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/tools/__init__.py +0 -0
  243. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/tools/git.py +0 -0
  244. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/tools/ocr.py +0 -0
  245. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/__init__.py +0 -0
  246. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/analyze.py +0 -0
  247. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/convert.py +0 -0
  248. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/models.py +0 -0
  249. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/text/__init__.py +0 -0
  250. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/text/mfh.py +0 -0
  251. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/text/wtp.py +0 -0
  252. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/utils/__init__.py +0 -0
  253. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/utils/io.py +0 -0
  254. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/utils/progress.py +0 -0
  255. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/utils/xml.py +0 -0
  256. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds/wiki/xml.py +0 -0
  257. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds.egg-info/dependency_links.txt +0 -0
  258. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds.egg-info/entry_points.txt +0 -0
  259. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/ommlds.egg-info/top_level.txt +0 -0
  260. {ommlds-0.0.0.dev366 → ommlds-0.0.0.dev368}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ommlds
3
- Version: 0.0.0.dev366
3
+ Version: 0.0.0.dev368
4
4
  Summary: ommlds
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.13
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev366
16
- Requires-Dist: omlish==0.0.0.dev366
15
+ Requires-Dist: omdev==0.0.0.dev368
16
+ Requires-Dist: omlish==0.0.0.dev368
17
17
  Provides-Extra: all
18
18
  Requires-Dist: llama-cpp-python~=0.3; extra == "all"
19
19
  Requires-Dist: mlx~=0.26; extra == "all"
@@ -137,6 +137,12 @@ from .content.namespaces import ( # noqa
137
137
  ContentNamespace,
138
138
  )
139
139
 
140
+ from .content.placeholders import ( # noqa
141
+ ContentPlaceholder,
142
+ ContentPlaceholderMarker,
143
+ content_placeholder,
144
+ )
145
+
140
146
  from .content.prepare import ( # noqa
141
147
  ContentPreparer,
142
148
  ContentStrPreparer,
@@ -56,10 +56,10 @@ class AnthropicChatChoicesService:
56
56
  self._model_name = cc.pop(ModelName(self.model))
57
57
 
58
58
  def _get_msg_content(self, m: Message) -> str | None:
59
- if isinstance(m, (SystemMessage, AiMessage)):
59
+ if isinstance(m, AiMessage):
60
60
  return m.s
61
61
 
62
- elif isinstance(m, UserMessage):
62
+ elif isinstance(m, (UserMessage, SystemMessage)):
63
63
  return check.isinstance(m.c, str)
64
64
 
65
65
  else:
@@ -38,16 +38,16 @@ class GoogleChatChoicesService:
38
38
  self._api_key = ApiKey.pop_secret(cc, env='GEMINI_API_KEY')
39
39
 
40
40
  def _get_msg_content(self, m: Message) -> str | None:
41
- if isinstance(m, (SystemMessage, AiMessage)):
42
- return m.s
41
+ if isinstance(m, AiMessage):
42
+ return check.isinstance(m.s, str)
43
43
 
44
- elif isinstance(m, UserMessage):
44
+ elif isinstance(m, (SystemMessage, UserMessage)):
45
45
  return check.isinstance(m.c, str)
46
46
 
47
47
  else:
48
48
  raise TypeError(m)
49
49
 
50
- BASE_URL = 'https://generativelanguage.googleapis.com/v1beta/models'
50
+ BASE_URL: ta.ClassVar[str] = 'https://generativelanguage.googleapis.com/v1beta/models'
51
51
 
52
52
  ROLES_MAP: ta.ClassVar[ta.Mapping[type[Message], str]] = {
53
53
  SystemMessage: 'system',
@@ -21,10 +21,10 @@ ROLES_MAP: ta.Mapping[type[Message], str] = {
21
21
 
22
22
 
23
23
  def get_msg_content(m: Message) -> str | None:
24
- if isinstance(m, (SystemMessage, AiMessage)):
24
+ if isinstance(m, AiMessage):
25
25
  return m.s
26
26
 
27
- elif isinstance(m, UserMessage):
27
+ elif isinstance(m, (SystemMessage, UserMessage)):
28
28
  return check.isinstance(m.c, str)
29
29
 
30
30
  else:
@@ -37,10 +37,10 @@ class MistralChatChoicesService:
37
37
  self._api_key = api_key
38
38
 
39
39
  def _get_msg_content(self, m: Message) -> str | None:
40
- if isinstance(m, (SystemMessage, AiMessage)):
40
+ if isinstance(m, AiMessage):
41
41
  return m.s
42
42
 
43
- elif isinstance(m, UserMessage):
43
+ elif isinstance(m, (UserMessage, SystemMessage)):
44
44
  return check.isinstance(m.c, str)
45
45
 
46
46
  else:
@@ -56,10 +56,10 @@ class MlxChatChoicesService(lang.ExitStacked):
56
56
  }
57
57
 
58
58
  def _get_msg_content(self, m: Message) -> str | None:
59
- if isinstance(m, (SystemMessage, AiMessage)):
60
- return m.s
59
+ if isinstance(m, AiMessage):
60
+ return check.isinstance(m.s, str)
61
61
 
62
- elif isinstance(m, UserMessage):
62
+ elif isinstance(m, (SystemMessage, UserMessage)):
63
63
  return check.isinstance(m.c, str)
64
64
 
65
65
  else:
@@ -35,7 +35,7 @@ def build_request_message(m: Message) -> ta.Mapping[str, ta.Any]:
35
35
  if isinstance(m, SystemMessage):
36
36
  return dict(
37
37
  role='system',
38
- content=m.s,
38
+ content=m.c,
39
39
  )
40
40
 
41
41
  elif isinstance(m, AiMessage):
@@ -65,7 +65,7 @@ def _prepare_toks(
65
65
  for msg in chat:
66
66
  if isinstance(msg, SystemMessage):
67
67
  role = 'system'
68
- msg_s = msg.s
68
+ msg_s = check.isinstance(msg.c, str)
69
69
  elif isinstance(msg, UserMessage):
70
70
  role = 'user'
71
71
  msg_s = check.isinstance(msg.c, str)
@@ -86,7 +86,7 @@ def build_chat_message(m: Message) -> ta.Mapping[str, ta.Any]:
86
86
  if isinstance(m, SystemMessage):
87
87
  return dict(
88
88
  role='system',
89
- content=m.s,
89
+ content=m.c,
90
90
  )
91
91
 
92
92
  elif isinstance(m, AiMessage):
@@ -47,7 +47,7 @@ class Message( # noqa
47
47
 
48
48
  @dc.dataclass(frozen=True)
49
49
  class SystemMessage(Message, lang.Final):
50
- s: str
50
+ c: CanContent
51
51
 
52
52
 
53
53
  #
@@ -94,7 +94,7 @@ Chat: ta.TypeAlias = ta.Sequence[Message]
94
94
  class _MessageContentTransform(ContentTransform, lang.Final, lang.NotInstantiable):
95
95
  @dispatch.install_method(ContentTransform.apply)
96
96
  def apply_system_message(self, m: SystemMessage) -> SystemMessage:
97
- return dc.replace(m, s=self.apply(m.s))
97
+ return dc.replace(m, c=self.apply(m.c))
98
98
 
99
99
  @dispatch.install_method(ContentTransform.apply)
100
100
  def apply_user_message(self, m: UserMessage) -> UserMessage:
@@ -7,11 +7,10 @@ from omlish import lang
7
7
  from omlish import marshal as msh
8
8
  from omlish import reflect as rfl
9
9
  from omlish.funcs import match as mfs
10
- from omlish.text import templating as tpl
11
10
 
12
11
  from .images import ImageContent # noqa
13
12
  from .materialize import CanContent
14
- from .namespaces import ContentNamespace
13
+ from .materialize import _InnerCanContent
15
14
  from .sequence import BlockContent # noqa
16
15
  from .sequence import InlineContent # noqa
17
16
  from .text import TextContent # noqa
@@ -88,11 +87,8 @@ class MarshalCanContent(lang.NotInstantiable, lang.Final):
88
87
 
89
88
 
90
89
  MarshalCanContentUnion: ta.TypeAlias = ta.Union[ # noqa
91
- str,
92
- ExtendedContent,
93
90
  ta.Iterable[MarshalCanContent],
94
- type[ContentNamespace],
95
- tpl.Templater,
91
+ _InnerCanContent,
96
92
  ]
97
93
 
98
94
 
@@ -0,0 +1,203 @@
1
+ """
2
+ TODO:
3
+ - ExtendedCanContent
4
+ """
5
+ import dataclasses as dc
6
+ import typing as ta
7
+
8
+ from omlish import check
9
+ from omlish import dispatch
10
+ from omlish.text import templating as tpl
11
+
12
+ from .namespaces import ContentNamespace
13
+ from .placeholders import ContentPlaceholder
14
+ from .placeholders import ContentPlaceholderMarker
15
+ from .types import Content
16
+ from .types import ExtendedContent
17
+
18
+
19
+ ##
20
+
21
+
22
+ _InnerCanContent: ta.TypeAlias = ta.Union[ # noqa
23
+ str,
24
+ ExtendedContent,
25
+
26
+ ContentPlaceholder,
27
+ type[ContentPlaceholderMarker],
28
+
29
+ type[ContentNamespace],
30
+
31
+ tpl.Templater,
32
+ ]
33
+
34
+ CanContent: ta.TypeAlias = ta.Union[ # noqa
35
+ ta.Iterable['CanContent'],
36
+
37
+ None,
38
+
39
+ _InnerCanContent,
40
+ ]
41
+
42
+
43
+ ##
44
+
45
+
46
+ ContentPlaceholderKey: ta.TypeAlias = ContentPlaceholder | type[ContentPlaceholderMarker]
47
+ ContentPlaceholderMap: ta.TypeAlias = ta.Mapping[ContentPlaceholderKey, CanContent]
48
+ ContentPlaceholderFn: ta.TypeAlias = ta.Callable[[ContentPlaceholderKey], CanContent]
49
+ ContentPlaceholders: ta.TypeAlias = ContentPlaceholderMap | ContentPlaceholderFn
50
+
51
+
52
+ @dc.dataclass()
53
+ class ContentPlaceholderMissingError(Exception):
54
+ key: ContentPlaceholderKey
55
+
56
+
57
+ def _make_content_placeholder_fn(cps: ContentPlaceholders | None = None) -> ContentPlaceholderFn:
58
+ if cps is None:
59
+ def none_fn(cpk: ContentPlaceholderKey) -> CanContent:
60
+ raise ContentPlaceholderMissingError(cpk)
61
+
62
+ return none_fn
63
+
64
+ elif isinstance(cps, ta.Mapping):
65
+ def mapping_fn(cpk: ContentPlaceholderKey) -> CanContent:
66
+ try:
67
+ return cps[cpk]
68
+ except KeyError:
69
+ raise ContentPlaceholderMissingError(cpk) from None
70
+
71
+ return mapping_fn
72
+
73
+ elif callable(cps):
74
+ return cps
75
+
76
+ else:
77
+ raise TypeError(cps)
78
+
79
+
80
+ ##
81
+
82
+
83
+ class ContentDepthExceededError(Exception):
84
+ pass
85
+
86
+
87
+ class ContentMaterializer:
88
+ DEFAULT_MAX_DEPTH: int = 100
89
+
90
+ def __init__(
91
+ self,
92
+ *,
93
+ content_placeholders: ContentPlaceholders | None = None,
94
+ templater_context: tpl.Templater.Context | None = None,
95
+ max_depth: int = DEFAULT_MAX_DEPTH,
96
+ ) -> None:
97
+ super().__init__()
98
+
99
+ self._templater_context = templater_context
100
+ self._content_placeholders_fn = _make_content_placeholder_fn(content_placeholders)
101
+ self._max_depth = max_depth
102
+
103
+ self._cur_depth = 0
104
+
105
+ def materialize(self, o: CanContent) -> Content:
106
+ if self._cur_depth >= self._max_depth:
107
+ raise ContentDepthExceededError
108
+
109
+ self._cur_depth += 1
110
+ try:
111
+ return self._materialize(o)
112
+ finally:
113
+ self._cur_depth -= 1
114
+
115
+ @dispatch.method
116
+ def _materialize(self, o: CanContent) -> Content:
117
+ raise TypeError(o)
118
+
119
+ #
120
+
121
+ @_materialize.register
122
+ def _materialize_str(self, o: str) -> Content:
123
+ return o
124
+
125
+ @_materialize.register
126
+ def _materialize_extended_content(self, o: ExtendedContent) -> Content:
127
+ return o
128
+
129
+ #
130
+
131
+ @_materialize.register
132
+ def _materialize_iterable(self, o: ta.Iterable) -> Content:
133
+ return [self.materialize(e) for e in o]
134
+
135
+ @_materialize.register
136
+ def _materialize_none(self, o: None) -> Content:
137
+ return []
138
+
139
+ #
140
+
141
+ @_materialize.register
142
+ def _materialize_placeholder(self, o: ContentPlaceholder) -> Content:
143
+ return self.materialize(self._content_placeholders_fn(o))
144
+
145
+ def _materialize_placeholder_marker_type(self, o: type[ContentPlaceholderMarker]) -> Content:
146
+ check.issubclass(o, ContentPlaceholderMarker)
147
+ return self.materialize(self._content_placeholders_fn(o))
148
+
149
+ #
150
+
151
+ def _materialize_namespace_type(self, o: type[ContentNamespace]) -> Content:
152
+ check.issubclass(o, ContentNamespace)
153
+
154
+ def rec(v: ta.Any) -> ta.Generator[Content]:
155
+ if isinstance(v, (bytes, bytearray, ta.Mapping)):
156
+ return
157
+
158
+ elif isinstance(v, type):
159
+ if issubclass(v, ContentNamespace):
160
+ for n, e in v:
161
+ if n.startswith('_'):
162
+ continue
163
+ yield from rec(e)
164
+
165
+ elif isinstance(v, ta.Iterable):
166
+ for e in v:
167
+ yield from rec(e)
168
+
169
+ else:
170
+ yield self.materialize(v)
171
+
172
+ return list(rec(o))
173
+
174
+ #
175
+
176
+ @_materialize.register
177
+ def _materialize_type(self, o: type) -> Content:
178
+ if issubclass(o, ContentPlaceholderMarker):
179
+ return self._materialize_placeholder_marker_type(o)
180
+
181
+ elif issubclass(o, ContentNamespace):
182
+ return self._materialize_namespace_type(o)
183
+
184
+ else:
185
+ raise TypeError(o)
186
+
187
+ #
188
+
189
+ @_materialize.register
190
+ def _materialize_templater(self, o: tpl.Templater) -> Content:
191
+ return o.render(check.not_none(self._templater_context))
192
+
193
+
194
+ def materialize_content(
195
+ o: CanContent,
196
+ *,
197
+ content_placeholders: ContentPlaceholders | None = None,
198
+ templater_context: tpl.Templater.Context | None = None,
199
+ ) -> Content:
200
+ return ContentMaterializer(
201
+ content_placeholders=content_placeholders,
202
+ templater_context=templater_context,
203
+ ).materialize(o)
@@ -0,0 +1,20 @@
1
+ from omlish import dataclasses as dc
2
+ from omlish import lang
3
+
4
+
5
+ ##
6
+
7
+
8
+ @dc.dataclass(frozen=True, eq=False)
9
+ @dc.extra_class_params(repr_id=True)
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))
14
+
15
+
16
+ content_placeholder = ContentPlaceholder
17
+
18
+
19
+ class ContentPlaceholderMarker(lang.Marker):
20
+ pass
@@ -1,6 +1,9 @@
1
1
  """
2
2
  TODO:
3
+ - max_depth
3
4
  - '...' marker for truncated directories
5
+ - any directory with unlisted children will be suffixed inline with '...'
6
+ - absence of '...' indicates an empty directory
4
7
  """
5
8
  import dataclasses as dc
6
9
  import typing as ta
@@ -15,7 +18,16 @@ from .running import LsItem
15
18
  ##
16
19
 
17
20
 
18
- @dc.dataclass()
21
+ class RenderedLsLines(ta.NamedTuple):
22
+ lines: list[str]
23
+ joined_len: int
24
+ is_truncated: bool
25
+
26
+
27
+ #
28
+
29
+
30
+ @dc.dataclass(eq=False)
19
31
  class _LsLine:
20
32
  item: LsItem
21
33
  d: int
@@ -30,28 +42,16 @@ class _LsLine:
30
42
  return f'{self.__class__.__name__}<{self.item.path!r}, {self.s!r}>'
31
43
 
32
44
 
33
- class RenderedLsLines(ta.NamedTuple):
34
- lines: list[str]
35
- joined_len: int
36
- is_truncated: bool
37
-
38
-
39
- class LsLinesRenderer:
40
- def __init__(
41
- self,
42
- *,
43
- soft_max_len: int | None = None,
44
- ) -> None:
45
- super().__init__()
46
-
47
- self._soft_max_len = soft_max_len
45
+ @dc.dataclass()
46
+ class _LsRenderRun:
47
+ root: DirLsItem
48
48
 
49
- def render(self, root: DirLsItem) -> RenderedLsLines:
50
- check.state(not root.path.endswith('/'))
51
- root_pfx = root.path + '/'
49
+ _: dc.KW_ONLY
52
50
 
53
- #
51
+ soft_max_len: int | None = None
54
52
 
53
+ @lang.cached_function
54
+ def root_line(self) -> _LsLine:
55
55
  def rec0(cur: LsItem, *, d: int = 0) -> _LsLine:
56
56
  if isinstance(cur, DirLsItem):
57
57
  return _LsLine(
@@ -69,10 +69,10 @@ class LsLinesRenderer:
69
69
  d,
70
70
  )
71
71
 
72
- root_line = rec0(root)
73
-
74
- #
72
+ return rec0(self.root)
75
73
 
74
+ @lang.cached_function
75
+ def all_lines(self) -> ta.Sequence[_LsLine]:
76
76
  all_lines: list[_LsLine] = []
77
77
 
78
78
  def rec1(cur: _LsLine) -> None:
@@ -81,10 +81,39 @@ class LsLinesRenderer:
81
81
  for child in cur.children.values():
82
82
  rec1(child)
83
83
 
84
- rec1(root_line)
84
+ rec1(self.root_line())
85
+ return all_lines
85
86
 
86
- #
87
+ def render_item(self, item: LsItem) -> str:
88
+ root_pfx = self.root.path + '/'
89
+
90
+ if item.path == self.root.path:
91
+ return f'- {self.root.path}'
92
+
93
+ else:
94
+ return (
95
+ f'{" " * (lang.strip_prefix(item.path, root_pfx).count("/") + 1)}'
96
+ f'- {item.name}'
97
+ f'{"/" if isinstance(item, DirLsItem) else ""}'
98
+ )
99
+
100
+ def collect_lines(self) -> list[str]:
101
+ ret: list[str] = []
87
102
 
103
+ def rec2(cur: _LsLine) -> None:
104
+ if cur.s is None:
105
+ return
106
+
107
+ ret.append(cur.s)
108
+
109
+ if cur.children is not None:
110
+ for child in cur.children.values():
111
+ rec2(child)
112
+
113
+ rec2(self.root_line())
114
+ return ret
115
+
116
+ def run(self) -> RenderedLsLines:
88
117
  cur_len = 0
89
118
 
90
119
  def add_line(s: str, *, force: bool = False) -> str | None:
@@ -93,7 +122,7 @@ class LsLinesRenderer:
93
122
  nonlocal cur_len
94
123
  sl = len(s) + (1 if cur_len else 0)
95
124
 
96
- if not force and (self._soft_max_len is not None and (cur_len + sl) > self._soft_max_len):
125
+ if not force and (self.soft_max_len is not None and (cur_len + sl) > self.soft_max_len):
97
126
  return None
98
127
 
99
128
  cur_len += sl
@@ -101,26 +130,14 @@ class LsLinesRenderer:
101
130
 
102
131
  #
103
132
 
104
- def render_item(item: LsItem) -> str:
105
- if item.path == root.path:
106
- return f'- {root.path}'
107
-
108
- else:
109
- return (
110
- f'{" " * (lang.strip_prefix(item.path, root_pfx).count("/") + 1)}'
111
- f'- {item.name}'
112
- f'{"/" if isinstance(item, DirLsItem) else ""}'
113
- )
114
-
115
- #
116
-
117
- root_line.s = add_line(render_item(root_line.item), force=True)
133
+ root_line = self.root_line()
134
+ root_line.s = add_line(self.render_item(root_line.item), force=True)
118
135
 
119
136
  for root_child in check.not_none(root_line.children).values():
120
- root_child.s = add_line(render_item(root_child.item), force=True)
137
+ root_child.s = add_line(self.render_item(root_child.item), force=True)
121
138
 
122
139
  sorted_lines = sorted(
123
- all_lines,
140
+ self.all_lines(),
124
141
  key=lambda line: (line.children is None, line.d),
125
142
  )
126
143
 
@@ -130,7 +147,7 @@ class LsLinesRenderer:
130
147
  if cur.s is not None:
131
148
  continue
132
149
 
133
- s = add_line(render_item(cur.item))
150
+ s = add_line(self.render_item(cur.item))
134
151
  if s is None:
135
152
  is_truncated = True
136
153
  break
@@ -139,22 +156,30 @@ class LsLinesRenderer:
139
156
 
140
157
  #
141
158
 
142
- ret: list[str] = []
159
+ return RenderedLsLines(
160
+ self.collect_lines(),
161
+ cur_len,
162
+ is_truncated,
163
+ )
143
164
 
144
- def rec2(cur: _LsLine) -> None:
145
- if cur.s is None:
146
- return
147
165
 
148
- ret.append(cur.s)
166
+ #
149
167
 
150
- if cur.children is not None:
151
- for child in cur.children.values():
152
- rec2(child)
153
168
 
154
- rec2(root_line)
169
+ class LsLinesRenderer:
170
+ def __init__(
171
+ self,
172
+ *,
173
+ soft_max_len: int | None = None,
174
+ ) -> None:
175
+ super().__init__()
176
+
177
+ self._soft_max_len = soft_max_len
155
178
 
156
- return RenderedLsLines(
157
- ret,
158
- cur_len,
159
- is_truncated,
160
- )
179
+ def render(self, root: DirLsItem) -> RenderedLsLines:
180
+ check.state(not root.path.endswith('/'))
181
+
182
+ return _LsRenderRun(
183
+ root,
184
+ soft_max_len=self._soft_max_len,
185
+ ).run()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ommlds
3
- Version: 0.0.0.dev366
3
+ Version: 0.0.0.dev368
4
4
  Summary: ommlds
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.13
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev366
16
- Requires-Dist: omlish==0.0.0.dev366
15
+ Requires-Dist: omdev==0.0.0.dev368
16
+ Requires-Dist: omlish==0.0.0.dev368
17
17
  Provides-Extra: all
18
18
  Requires-Dist: llama-cpp-python~=0.3; extra == "all"
19
19
  Requires-Dist: mlx~=0.26; extra == "all"
@@ -169,6 +169,7 @@ ommlds/minichain/content/images.py
169
169
  ommlds/minichain/content/materialize.py
170
170
  ommlds/minichain/content/metadata.py
171
171
  ommlds/minichain/content/namespaces.py
172
+ ommlds/minichain/content/placeholders.py
172
173
  ommlds/minichain/content/prepare.py
173
174
  ommlds/minichain/content/rendering.py
174
175
  ommlds/minichain/content/sequence.py
@@ -1,5 +1,5 @@
1
- omdev==0.0.0.dev366
2
- omlish==0.0.0.dev366
1
+ omdev==0.0.0.dev368
2
+ omlish==0.0.0.dev368
3
3
 
4
4
  [all]
5
5
  llama-cpp-python~=0.3
@@ -12,7 +12,7 @@ authors = [
12
12
  urls = {source = 'https://github.com/wrmsr/omlish'}
13
13
  license = {text = 'BSD-3-Clause'}
14
14
  requires-python = '>=3.13'
15
- version = '0.0.0.dev366'
15
+ version = '0.0.0.dev368'
16
16
  classifiers = [
17
17
  'License :: OSI Approved :: BSD License',
18
18
  'Development Status :: 2 - Pre-Alpha',
@@ -22,8 +22,8 @@ classifiers = [
22
22
  ]
23
23
  description = 'ommlds'
24
24
  dependencies = [
25
- 'omdev == 0.0.0.dev366',
26
- 'omlish == 0.0.0.dev366',
25
+ 'omdev == 0.0.0.dev368',
26
+ 'omlish == 0.0.0.dev368',
27
27
  ]
28
28
 
29
29
  [project.optional-dependencies]