ommlds 0.0.0.dev475__py3-none-any.whl → 0.0.0.dev476__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 (71) hide show
  1. ommlds/.omlish-manifests.json +85 -1
  2. ommlds/__about__.py +1 -1
  3. ommlds/backends/groq/_marshal.py +23 -0
  4. ommlds/backends/groq/protocol.py +184 -0
  5. ommlds/cli/{sessions/chat/backends → backends}/catalog.py +35 -3
  6. ommlds/cli/backends/configs.py +9 -0
  7. ommlds/cli/backends/inject.py +31 -36
  8. ommlds/cli/{sessions/chat/backends → backends}/injection.py +1 -1
  9. ommlds/cli/{sessions/chat/backends → backends}/types.py +11 -1
  10. ommlds/cli/{sessions/chat/content → content}/messages.py +1 -1
  11. ommlds/cli/{sessions/chat/content → content}/strings.py +1 -1
  12. ommlds/cli/inject.py +0 -6
  13. ommlds/cli/inputs/asyncs.py +32 -0
  14. ommlds/cli/{sessions/chat/chat/user/inputs.py → inputs/sync.py} +0 -30
  15. ommlds/cli/main.py +267 -113
  16. ommlds/cli/rendering/__init__.py +0 -0
  17. ommlds/cli/rendering/configs.py +9 -0
  18. ommlds/cli/{sessions/chat/rendering → rendering}/inject.py +4 -5
  19. ommlds/cli/{sessions/chat/rendering → rendering}/markdown.py +1 -1
  20. ommlds/cli/{sessions/chat/rendering → rendering}/raw.py +1 -1
  21. ommlds/cli/{sessions/chat/rendering → rendering}/types.py +1 -1
  22. ommlds/cli/secrets.py +21 -0
  23. ommlds/cli/sessions/base.py +1 -1
  24. ommlds/cli/sessions/chat/chat/ai/configs.py +11 -0
  25. ommlds/cli/sessions/chat/chat/ai/inject.py +7 -11
  26. ommlds/cli/sessions/chat/chat/ai/rendering.py +4 -4
  27. ommlds/cli/sessions/chat/chat/ai/services.py +2 -2
  28. ommlds/cli/sessions/chat/chat/state/configs.py +11 -0
  29. ommlds/cli/sessions/chat/chat/state/inject.py +6 -10
  30. ommlds/cli/sessions/chat/chat/state/inmemory.py +1 -2
  31. ommlds/cli/sessions/chat/chat/state/storage.py +1 -2
  32. ommlds/cli/sessions/chat/chat/state/types.py +1 -1
  33. ommlds/cli/sessions/chat/chat/user/configs.py +17 -0
  34. ommlds/cli/sessions/chat/chat/user/inject.py +13 -19
  35. ommlds/cli/sessions/chat/chat/user/interactive.py +3 -3
  36. ommlds/cli/sessions/chat/configs.py +15 -26
  37. ommlds/cli/sessions/chat/inject.py +18 -35
  38. ommlds/cli/sessions/chat/session.py +1 -1
  39. ommlds/cli/sessions/chat/tools/configs.py +13 -0
  40. ommlds/cli/sessions/chat/tools/inject.py +6 -10
  41. ommlds/cli/sessions/chat/tools/injection.py +1 -0
  42. ommlds/cli/sessions/chat/tools/rendering.py +1 -1
  43. ommlds/cli/sessions/completion/configs.py +2 -2
  44. ommlds/cli/sessions/completion/inject.py +14 -0
  45. ommlds/cli/sessions/completion/session.py +7 -11
  46. ommlds/cli/sessions/embedding/configs.py +2 -2
  47. ommlds/cli/sessions/embedding/inject.py +14 -0
  48. ommlds/cli/sessions/embedding/session.py +7 -11
  49. ommlds/cli/state/storage.py +1 -1
  50. ommlds/minichain/backends/catalogs/strings.py +1 -1
  51. ommlds/minichain/backends/impls/groq/__init__.py +0 -0
  52. ommlds/minichain/backends/impls/groq/chat.py +69 -0
  53. ommlds/minichain/backends/impls/groq/names.py +35 -0
  54. ommlds/minichain/backends/impls/groq/protocol.py +46 -0
  55. ommlds/minichain/backends/impls/groq/stream.py +121 -0
  56. ommlds/minichain/backends/impls/openai/chat.py +3 -3
  57. ommlds/minichain/backends/impls/openai/names.py +27 -3
  58. ommlds/minichain/backends/impls/openai/stream.py +2 -2
  59. ommlds/wiki/utils/xml.py +5 -5
  60. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/METADATA +5 -5
  61. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/RECORD +68 -55
  62. ommlds/cli/backends/standard.py +0 -20
  63. ommlds/cli/main2.py +0 -220
  64. ommlds/cli/sessions/chat/backends/inject.py +0 -53
  65. /ommlds/{cli/sessions/chat/backends → backends/groq}/__init__.py +0 -0
  66. /ommlds/cli/{sessions/chat/content → content}/__init__.py +0 -0
  67. /ommlds/cli/{sessions/chat/rendering → inputs}/__init__.py +0 -0
  68. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/WHEEL +0 -0
  69. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/entry_points.txt +0 -0
  70. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/licenses/LICENSE +0 -0
  71. {ommlds-0.0.0.dev475.dist-info → ommlds-0.0.0.dev476.dist-info}/top_level.txt +0 -0
ommlds/cli/main2.py DELETED
@@ -1,220 +0,0 @@
1
- """
2
- TODO:
3
- - bootstrap lol
4
- """
5
- import abc
6
- import functools
7
- import typing as ta
8
-
9
- import anyio
10
-
11
- from omlish import check
12
- from omlish import dataclasses as dc
13
- from omlish import inject as inj
14
- from omlish import lang
15
- from omlish.argparse import all as ap
16
- from omlish.logs import all as logs
17
-
18
- from .inject import bind_main
19
- from .sessions.base import Session
20
- from .sessions.chat.configs import ChatConfig
21
-
22
-
23
- ##
24
-
25
-
26
- MAIN_EXTRA_ARGS: ta.Sequence[ap.Arg] = [
27
- ap.arg('-v', '--verbose', action='store_true'),
28
- ]
29
-
30
-
31
- def _process_main_extra_args(args: ap.Namespace) -> None:
32
- if args.verbose:
33
- logs.configure_standard_logging('DEBUG')
34
- else:
35
- logs.configure_standard_logging('INFO')
36
- logs.silence_noisy_loggers()
37
-
38
-
39
- ##
40
-
41
-
42
- class Profile(lang.Abstract):
43
- @abc.abstractmethod
44
- def run(self, argv: ta.Sequence[str]) -> ta.Awaitable[None]:
45
- raise NotImplementedError
46
-
47
-
48
- ##
49
-
50
-
51
- # class ChatAspect(lang.Abstract):
52
- # def get_parser_args(self) -> ta.Sequence[ap.Arg]: ...
53
- # def set_args(self, args: ap.Namespace) -> None: ...
54
- # def configure(self, cfg: ChatConfig) -> ChatConfig: ...
55
-
56
-
57
- class ChatProfile(Profile):
58
- _args: ap.Namespace
59
-
60
- #
61
-
62
- BACKEND_ARGS: ta.ClassVar[ta.Sequence[ap.Arg]] = [
63
- ap.arg('-b', '--backend', group='backend'),
64
- ]
65
-
66
- def configure_backend(self, cfg: ChatConfig) -> ChatConfig:
67
- return dc.replace(
68
- cfg,
69
- backend=self._args.backend,
70
- )
71
-
72
- #
73
-
74
- INPUT_ARGS: ta.ClassVar[ta.Sequence[ap.Arg]] = [
75
- ap.arg('message', nargs='*', group='input'),
76
- ap.arg('-i', '--interactive', action='store_true', group='input'),
77
- ap.arg('-e', '--editor', action='store_true', group='input'),
78
- ]
79
-
80
- def configure_input(self, cfg: ChatConfig) -> ChatConfig:
81
- if self._args.editor:
82
- check.arg(not self._args.interactive)
83
- check.arg(not self._args.message)
84
- raise NotImplementedError
85
-
86
- elif self._args.interactive:
87
- check.arg(not self._args.message)
88
- return dc.replace(
89
- cfg,
90
- interactive=True,
91
- )
92
-
93
- elif self._args.message:
94
- # TODO: '-' -> stdin
95
- return dc.replace(
96
- cfg,
97
- initial_user_content=' '.join(self._args.message),
98
- )
99
-
100
- else:
101
- raise ValueError('Must specify input')
102
-
103
- #
104
-
105
- STATE_ARGS: ta.ClassVar[ta.Sequence[ap.Arg]] = [
106
- ap.arg('-n', '--new', action='store_true', group='state'),
107
- ap.arg('--ephemeral', action='store_true', group='state'),
108
- ]
109
-
110
- def configure_state(self, cfg: ChatConfig) -> ChatConfig:
111
- return dc.replace(
112
- cfg,
113
- state='ephemeral' if self._args.ephemeral else 'new' if self._args.new else 'continue',
114
- )
115
-
116
- #
117
-
118
- OUTPUT_ARGS: ta.ClassVar[ta.Sequence[ap.Arg]] = [
119
- ap.arg('-s', '--stream', action='store_true', group='output'),
120
- ap.arg('-M', '--markdown', action='store_true', group='output'),
121
- ]
122
-
123
- def configure_output(self, cfg: ChatConfig) -> ChatConfig:
124
- return dc.replace(
125
- cfg,
126
- stream=bool(self._args.stream),
127
- markdown=bool(self._args.markdown),
128
- )
129
-
130
- #
131
-
132
- async def run(self, argv: ta.Sequence[str]) -> None:
133
- parser = ap.ArgumentParser()
134
-
135
- for grp_name, grp_args in [
136
- ('backend', self.BACKEND_ARGS),
137
- ('input', self.INPUT_ARGS),
138
- ('state', self.STATE_ARGS),
139
- ('output', self.OUTPUT_ARGS),
140
- ]:
141
- grp = parser.add_argument_group(grp_name)
142
- for a in grp_args:
143
- grp.add_argument(*a.args, **a.kwargs)
144
-
145
- self._args = parser.parse_args(argv)
146
-
147
- cfg = ChatConfig()
148
- cfg = self.configure_backend(cfg)
149
- cfg = self.configure_input(cfg)
150
- cfg = self.configure_state(cfg)
151
- cfg = self.configure_output(cfg)
152
-
153
- # session_cfg = ChatConfig(
154
- # initial_system_content=system_content,
155
- # enable_tools=(
156
- # args.enable_fs_tools or
157
- # args.enable_todo_tools or
158
- # args.enable_unsafe_tools_do_not_use_lol or
159
- # args.enable_test_weather_tool or
160
- # args.code
161
- # ),
162
- # enabled_tools={ # noqa
163
- # *(['fs'] if args.enable_fs_tools else []),
164
- # *(['todo'] if args.enable_todo_tools else []),
165
- # *(['weather'] if args.enable_test_weather_tool else []),
166
- # # FIXME: enable_unsafe_tools_do_not_use_lol
167
- # },
168
- # dangerous_no_tool_confirmation=bool(args.dangerous_no_tool_confirmation),
169
- # )
170
-
171
- with inj.create_managed_injector(bind_main(
172
- session_cfg=cfg,
173
- enable_backend_strings=True,
174
- )) as injector:
175
- await injector[Session].run()
176
-
177
-
178
- ##
179
-
180
-
181
- PROFILE_TYPES: ta.Mapping[str, type[Profile]] = {
182
- 'chat': ChatProfile,
183
- }
184
-
185
-
186
- ##
187
-
188
-
189
- MAIN_PROFILE_ARGS: ta.Sequence[ap.Arg] = [
190
- ap.arg('profile', nargs='?', default='chat'),
191
- ap.arg('args', nargs=ap.REMAINDER),
192
- ]
193
-
194
-
195
- async def _a_main(argv: ta.Any = None) -> None:
196
- parser = ap.ArgumentParser()
197
-
198
- for a in [*MAIN_EXTRA_ARGS, *MAIN_PROFILE_ARGS]:
199
- parser.add_argument(*a.args, **a.kwargs)
200
-
201
- args, unk_args = parser.parse_known_args(argv)
202
-
203
- _process_main_extra_args(args)
204
-
205
- profile_cls = PROFILE_TYPES[args.profile]
206
- profile = profile_cls()
207
- await profile.run([*unk_args, *args.args])
208
-
209
-
210
- def _main(args: ta.Any = None) -> None:
211
- anyio.run(
212
- functools.partial(
213
- _a_main,
214
- args,
215
- ),
216
- ) # noqa
217
-
218
-
219
- if __name__ == '__main__':
220
- _main()
@@ -1,53 +0,0 @@
1
- import typing as ta
2
-
3
- from omlish import inject as inj
4
- from omlish import lang
5
- from omlish import typedvalues as tv
6
-
7
- from ..... import minichain as mc
8
- from .injection import backend_configs
9
-
10
-
11
- with lang.auto_proxy_import(globals()):
12
- from . import catalog as _catalog
13
- from . import types as _types
14
-
15
-
16
- ##
17
-
18
-
19
- def bind_backends(
20
- *,
21
- backend: str | None = None,
22
- ) -> inj.Elements:
23
- els: list[inj.Elemental] = []
24
-
25
- #
26
-
27
- els.append(backend_configs().bind_items_provider(singleton=True))
28
-
29
- #
30
-
31
- if backend is not None:
32
- els.append(inj.bind(_types.BackendName, to_const=backend))
33
-
34
- els.extend([
35
- inj.bind(_types.ChatChoicesServiceBackendProvider, to_ctor=_catalog.CatalogChatChoicesServiceBackendProvider, singleton=True), # noqa
36
- inj.bind(_types.ChatChoicesStreamServiceBackendProvider, to_ctor=_catalog.CatalogChatChoicesStreamServiceBackendProvider, singleton=True), # noqa
37
- ])
38
-
39
- #
40
-
41
- async def catalog_backend_instantiator_provider(injector: inj.AsyncInjector) -> _catalog.CatalogBackendProvider.Instantiator: # noqa
42
- async def inner(be: 'mc.BackendCatalog.Backend', cfgs: _types.BackendConfigs | None) -> ta.Any:
43
- kwt = inj.build_kwargs_target(be.factory, non_strict=True)
44
- kw = await injector.provide_kwargs(kwt)
45
- return be.factory(*tv.collect(*(be.configs or []), *(cfgs or []), override=True), **kw)
46
-
47
- return _catalog.CatalogBackendProvider.Instantiator(inner)
48
-
49
- els.append(inj.bind(_catalog.CatalogBackendProvider.Instantiator, to_async_fn=catalog_backend_instantiator_provider)) # noqa
50
-
51
- #
52
-
53
- return inj.as_elements(*els)