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