ommlds 0.0.0.dev462__py3-none-any.whl → 0.0.0.dev464__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.
Potentially problematic release.
This version of ommlds might be problematic. Click here for more details.
- ommlds/backends/mlx/loading.py +58 -1
- ommlds/cli/inject.py +0 -5
- ommlds/cli/main.py +26 -38
- ommlds/cli/sessions/chat/backends/catalog.py +56 -0
- ommlds/cli/sessions/chat/backends/inject.py +37 -0
- ommlds/cli/sessions/chat/backends/injection.py +16 -0
- ommlds/cli/sessions/chat/backends/types.py +36 -0
- ommlds/cli/sessions/chat/chat/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/ai/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/ai/inject.py +81 -0
- ommlds/cli/sessions/chat/chat/ai/injection.py +14 -0
- ommlds/cli/sessions/chat/chat/ai/rendering.py +70 -0
- ommlds/cli/sessions/chat/chat/ai/services.py +81 -0
- ommlds/cli/sessions/chat/chat/ai/tools.py +44 -0
- ommlds/cli/sessions/chat/chat/ai/types.py +28 -0
- ommlds/cli/sessions/chat/chat/state/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/state/inject.py +40 -0
- ommlds/cli/sessions/chat/chat/state/inmemory.py +34 -0
- ommlds/cli/sessions/chat/chat/state/storage.py +53 -0
- ommlds/cli/sessions/chat/chat/state/types.py +38 -0
- ommlds/cli/sessions/chat/chat/user/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/user/inject.py +61 -0
- ommlds/cli/sessions/chat/chat/user/interactive.py +29 -0
- ommlds/cli/sessions/chat/chat/user/oneshot.py +25 -0
- ommlds/cli/sessions/chat/chat/user/types.py +15 -0
- ommlds/cli/sessions/chat/configs.py +36 -0
- ommlds/cli/sessions/chat/content/__init__.py +0 -0
- ommlds/cli/sessions/chat/content/messages.py +34 -0
- ommlds/cli/sessions/chat/content/strings.py +42 -0
- ommlds/cli/sessions/chat/driver.py +43 -0
- ommlds/cli/sessions/chat/inject.py +40 -66
- ommlds/cli/sessions/chat/phases/__init__.py +0 -0
- ommlds/cli/sessions/chat/phases/inject.py +27 -0
- ommlds/cli/sessions/chat/phases/injection.py +14 -0
- ommlds/cli/sessions/chat/phases/manager.py +29 -0
- ommlds/cli/sessions/chat/phases/types.py +29 -0
- ommlds/cli/sessions/chat/rendering/__init__.py +0 -0
- ommlds/cli/sessions/chat/rendering/inject.py +32 -0
- ommlds/cli/sessions/chat/rendering/markdown.py +52 -0
- ommlds/cli/sessions/chat/rendering/raw.py +73 -0
- ommlds/cli/sessions/chat/rendering/types.py +21 -0
- ommlds/cli/sessions/chat/session.py +27 -0
- ommlds/cli/sessions/chat/tools/__init__.py +0 -0
- ommlds/cli/sessions/chat/tools/confirmation.py +46 -0
- ommlds/cli/sessions/chat/tools/execution.py +66 -0
- ommlds/cli/sessions/chat/tools/inject.py +145 -0
- ommlds/cli/sessions/chat/tools/injection.py +29 -0
- ommlds/cli/sessions/chat/tools/rendering.py +58 -0
- ommlds/cli/{tools → sessions/chat/tools}/weather.py +1 -1
- ommlds/cli/sessions/inject.py +3 -3
- ommlds/cli/state.py +40 -23
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/METADATA +3 -3
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/RECORD +58 -23
- ommlds/cli/sessions/chat/base.py +0 -42
- ommlds/cli/sessions/chat/code.py +0 -125
- ommlds/cli/sessions/chat/interactive.py +0 -70
- ommlds/cli/sessions/chat/printing.py +0 -126
- ommlds/cli/sessions/chat/prompt.py +0 -161
- ommlds/cli/sessions/chat/state.py +0 -110
- ommlds/cli/sessions/chat/tools.py +0 -97
- ommlds/cli/tools/config.py +0 -14
- ommlds/cli/tools/inject.py +0 -75
- /ommlds/cli/{tools → sessions/chat/backends}/__init__.py +0 -0
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev462.dist-info → ommlds-0.0.0.dev464.dist-info}/top_level.txt +0 -0
ommlds/cli/state.py
CHANGED
|
@@ -14,6 +14,38 @@ T = ta.TypeVar('T')
|
|
|
14
14
|
##
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
class StateStorage(lang.Abstract):
|
|
18
|
+
@abc.abstractmethod
|
|
19
|
+
def load_state(self, key: str, ty: type[T] | None) -> ta.Awaitable[T | None]:
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
@abc.abstractmethod
|
|
23
|
+
def save_state(self, key: str, obj: ta.Any | None, ty: type[T] | None) -> ta.Awaitable[None]:
|
|
24
|
+
raise NotImplementedError
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class InMemoryStateStorage(StateStorage):
|
|
31
|
+
def __init__(self) -> None:
|
|
32
|
+
super().__init__()
|
|
33
|
+
|
|
34
|
+
self._dct: dict[str, ta.Any] = {}
|
|
35
|
+
|
|
36
|
+
async def load_state(self, key: str, ty: type[T] | None) -> T | None:
|
|
37
|
+
return self._dct.get(key)
|
|
38
|
+
|
|
39
|
+
async def save_state(self, key: str, obj: ta.Any | None, ty: type[T] | None) -> None:
|
|
40
|
+
if obj is None:
|
|
41
|
+
self._dct.pop(key, None)
|
|
42
|
+
else:
|
|
43
|
+
self._dct[key] = obj
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
|
|
48
|
+
|
|
17
49
|
STATE_VERSION = 0
|
|
18
50
|
|
|
19
51
|
|
|
@@ -23,10 +55,7 @@ class MarshaledState:
|
|
|
23
55
|
payload: ta.Any
|
|
24
56
|
|
|
25
57
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class StateStorage(lang.Abstract):
|
|
58
|
+
class MarshalStateStorage(StateStorage, lang.Abstract):
|
|
30
59
|
def __init__(
|
|
31
60
|
self,
|
|
32
61
|
*,
|
|
@@ -36,36 +65,24 @@ class StateStorage(lang.Abstract):
|
|
|
36
65
|
|
|
37
66
|
self._version = version
|
|
38
67
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def unmarshal_state(self, obj: ta.Any, ty: type[T] | None = None) -> T | None:
|
|
68
|
+
def _unmarshal_state(self, obj: ta.Any, ty: type[T] | None = None) -> T | None:
|
|
42
69
|
ms = msh.unmarshal(obj, MarshaledState)
|
|
43
70
|
if ms.version < self._version:
|
|
44
71
|
return None
|
|
45
72
|
return msh.unmarshal(ms.payload, ty)
|
|
46
73
|
|
|
47
|
-
def
|
|
74
|
+
def _marshal_state(self, obj: ta.Any, ty: type | None = None) -> ta.Any:
|
|
48
75
|
ms = MarshaledState(
|
|
49
76
|
version=self._version,
|
|
50
77
|
payload=msh.marshal(obj, ty),
|
|
51
78
|
)
|
|
52
79
|
return msh.marshal(ms)
|
|
53
80
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
@abc.abstractmethod
|
|
57
|
-
def load_state(self, key: str, ty: type[T] | None) -> T | None:
|
|
58
|
-
raise NotImplementedError
|
|
59
|
-
|
|
60
|
-
@abc.abstractmethod
|
|
61
|
-
def save_state(self, key: str, obj: ta.Any | None, ty: type[T] | None) -> None:
|
|
62
|
-
raise NotImplementedError
|
|
63
|
-
|
|
64
81
|
|
|
65
82
|
#
|
|
66
83
|
|
|
67
84
|
|
|
68
|
-
class JsonFileStateStorage(
|
|
85
|
+
class JsonFileStateStorage(MarshalStateStorage):
|
|
69
86
|
def __init__(
|
|
70
87
|
self,
|
|
71
88
|
file: str,
|
|
@@ -91,19 +108,19 @@ class JsonFileStateStorage(StateStorage):
|
|
|
91
108
|
|
|
92
109
|
#
|
|
93
110
|
|
|
94
|
-
def load_state(self, key: str, ty: type[T] | None) -> T | None:
|
|
111
|
+
async def load_state(self, key: str, ty: type[T] | None) -> T | None:
|
|
95
112
|
if not (data := self._load_file_data()):
|
|
96
113
|
return None
|
|
97
114
|
if (dct := data.get(key)) is None:
|
|
98
115
|
return None
|
|
99
|
-
return self.
|
|
116
|
+
return self._unmarshal_state(dct, ty)
|
|
100
117
|
|
|
101
|
-
def save_state(self, key: str, obj: ta.Any | None, ty: type[T] | None) -> None:
|
|
118
|
+
async def save_state(self, key: str, obj: ta.Any | None, ty: type[T] | None) -> None:
|
|
102
119
|
if (data := self._load_file_data()) is None:
|
|
103
120
|
data = {}
|
|
104
121
|
if obj is None:
|
|
105
122
|
data.pop(key, None)
|
|
106
123
|
else:
|
|
107
|
-
dct = self.
|
|
124
|
+
dct = self._marshal_state(obj, ty)
|
|
108
125
|
data[key] = dct
|
|
109
126
|
self._save_file_data(data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommlds
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev464
|
|
4
4
|
Summary: ommlds
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omdev==0.0.0.
|
|
18
|
-
Requires-Dist: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omdev==0.0.0.dev464
|
|
18
|
+
Requires-Dist: omlish==0.0.0.dev464
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Requires-Dist: llama-cpp-python~=0.3; extra == "all"
|
|
21
21
|
Requires-Dist: mlx~=0.29; extra == "all"
|
|
@@ -26,7 +26,7 @@ ommlds/backends/mlx/caching.py,sha256=jPhVclrm8RckXiJLY-iokCSGjMfVMr_VH8fTFYA3FB
|
|
|
26
26
|
ommlds/backends/mlx/cli.py,sha256=In4gGBqvFApLE-vNMi6bqba7Xa-SZfCmSSGuRCDCjlU,10685
|
|
27
27
|
ommlds/backends/mlx/generation.py,sha256=e53MT80QJI6KhUr9UNnJkx9h3bUFtn1dy9K-R57c6hk,9785
|
|
28
28
|
ommlds/backends/mlx/limits.py,sha256=GZfad6q14fvFHoPfovdnH3jnM1qGvdprfQk_pMWqI5g,2780
|
|
29
|
-
ommlds/backends/mlx/loading.py,sha256=
|
|
29
|
+
ommlds/backends/mlx/loading.py,sha256=5M18MPeXiIsPV5Laww6gu3KicLKJ11G0OJMjyixDa9c,3585
|
|
30
30
|
ommlds/backends/mlx/tokenization/LICENSE,sha256=0T9KDFIRDAqANM8DZgpgrzPq3WwnBKsw5EkrkeR3xqM,1066
|
|
31
31
|
ommlds/backends/mlx/tokenization/__init__.py,sha256=0GfhhjUc4OhY_dpQncq984kcdyOCholjVNjAIAcjAHM,232
|
|
32
32
|
ommlds/backends/mlx/tokenization/loading.py,sha256=OSD7-ZnLuY2Owv5MpQB8CCEPMhOPwParqMPpS5omZBI,3154
|
|
@@ -77,32 +77,67 @@ ommlds/backends/torch/devices.py,sha256=KWkeyArPdUwVqckQTJPkN-4GQdv39cpOgCMv_Xfk
|
|
|
77
77
|
ommlds/backends/torch/purge.py,sha256=sp6XUxNLoVCepxIPKw3tevHn-cQqgorILvIQzixauiI,1834
|
|
78
78
|
ommlds/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
ommlds/cli/__main__.py,sha256=1ffCb0fcUOJMzxROJmJRXQ8PSOVYv7KrcuBtT95cf0c,140
|
|
80
|
-
ommlds/cli/inject.py,sha256=
|
|
81
|
-
ommlds/cli/main.py,sha256=
|
|
82
|
-
ommlds/cli/state.py,sha256=
|
|
80
|
+
ommlds/cli/inject.py,sha256=QEuipqBPsET3rA0aO2c8hKCU77kgWwMfWktW8cGDkyw,1160
|
|
81
|
+
ommlds/cli/main.py,sha256=dCSmhu0Xk6thP6pu_nmo1kp-WiR4aC1RBOfG0Y8BKjI,5534
|
|
82
|
+
ommlds/cli/state.py,sha256=tRPmgCANRrw7A5Qr700OaH58F6S96O37I8Ivrbo7_gI,3001
|
|
83
83
|
ommlds/cli/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
84
|
ommlds/cli/backends/inject.py,sha256=OVstNsoeVnprM9PBL_zP0N46KkoDg3_Wz90BWcQ7km4,1734
|
|
85
85
|
ommlds/cli/backends/standard.py,sha256=HnammWyAXJHeqXJrAMBdarcT4Nyt2CxudZdD2fW_Y9M,631
|
|
86
86
|
ommlds/cli/sessions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
87
|
ommlds/cli/sessions/base.py,sha256=oTqsqZ9jhBWFblANpVWLLIzmRfP8HO9QYtPnZ-GZxS0,452
|
|
88
|
-
ommlds/cli/sessions/inject.py,sha256=
|
|
88
|
+
ommlds/cli/sessions/inject.py,sha256=oDiEuBkchaBKHVTJcd11v4P_pSurhrvwhbaAVCcUhOM,548
|
|
89
89
|
ommlds/cli/sessions/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
|
-
ommlds/cli/sessions/chat/
|
|
91
|
-
ommlds/cli/sessions/chat/
|
|
92
|
-
ommlds/cli/sessions/chat/inject.py,sha256=
|
|
93
|
-
ommlds/cli/sessions/chat/
|
|
94
|
-
ommlds/cli/sessions/chat/
|
|
95
|
-
ommlds/cli/sessions/chat/
|
|
96
|
-
ommlds/cli/sessions/chat/
|
|
97
|
-
ommlds/cli/sessions/chat/
|
|
90
|
+
ommlds/cli/sessions/chat/configs.py,sha256=7NtpOaSyjABKLuJ1jAbp1lCT1tPjvPVJ_vakbzvuk8g,692
|
|
91
|
+
ommlds/cli/sessions/chat/driver.py,sha256=ddnCYTKqWiPxV8U4UbFwb7E3yi81ItjZ9j3AJd3a3Mk,1395
|
|
92
|
+
ommlds/cli/sessions/chat/inject.py,sha256=tlZ2kmS6PxLbGzgKhbtUyzUw2uyeZ9TpWt0QFdgmAOM,1656
|
|
93
|
+
ommlds/cli/sessions/chat/session.py,sha256=eqwelLE74JFC-fBpk_hdwMD2nP4pLv3ZPwUn99200B8,521
|
|
94
|
+
ommlds/cli/sessions/chat/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
95
|
+
ommlds/cli/sessions/chat/backends/catalog.py,sha256=GroogxBQf_zlrhEEwTSq18v13HWsuXOP276VcuphPic,1756
|
|
96
|
+
ommlds/cli/sessions/chat/backends/inject.py,sha256=VbZ-Fb679kTItRpAhIYCqSM8vXUFeRDQWssUfrFgGi8,882
|
|
97
|
+
ommlds/cli/sessions/chat/backends/injection.py,sha256=GCn5OvNIEowgB70kQVuU84z3i8lLA4vOVkTZlQG8s0o,327
|
|
98
|
+
ommlds/cli/sessions/chat/backends/types.py,sha256=5eImYHXLKqbC5MDrN443eMGamP9snCmV1n7LtAsqgPk,696
|
|
99
|
+
ommlds/cli/sessions/chat/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
100
|
+
ommlds/cli/sessions/chat/chat/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
+
ommlds/cli/sessions/chat/chat/ai/inject.py,sha256=Uq1zDpFj3cZqWns2gfMu1Oun4ssbfzVB1JfpUdwh8wc,2572
|
|
102
|
+
ommlds/cli/sessions/chat/chat/ai/injection.py,sha256=2O_ELMusxQsYaB2oqvzjYpZQzjshocJup7Z5unzoUIY,404
|
|
103
|
+
ommlds/cli/sessions/chat/chat/ai/rendering.py,sha256=cicA6NwkM9UJb1dgsakhkhIMWGzBsArPFvYoINBmuec,2285
|
|
104
|
+
ommlds/cli/sessions/chat/chat/ai/services.py,sha256=RNO3emXEFPr0M04wThRQo332x0n5R3n8aQFctcePCHQ,2629
|
|
105
|
+
ommlds/cli/sessions/chat/chat/ai/tools.py,sha256=en94LLM8y73N11xhQPlkSLfbzAmYVwKU-4nz2i0CK0E,1094
|
|
106
|
+
ommlds/cli/sessions/chat/chat/ai/types.py,sha256=QH6Cn6DrdxBi0Tnura7Fq-WtGUm0FdsazZSgki6nf0A,750
|
|
107
|
+
ommlds/cli/sessions/chat/chat/state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
108
|
+
ommlds/cli/sessions/chat/chat/state/inject.py,sha256=usHhiE1fKtttJvxgVN-LuwIsfyau_0n17-99bDuPNnw,1131
|
|
109
|
+
ommlds/cli/sessions/chat/chat/state/inmemory.py,sha256=2lSCWnNEH_vj9RJUVzM8huAHAXBJ6Go02og2nzew1hk,861
|
|
110
|
+
ommlds/cli/sessions/chat/chat/state/storage.py,sha256=IabpjwrD89kX7s_hcKjpumu0He0jMmK-uOig1RmAxIA,1428
|
|
111
|
+
ommlds/cli/sessions/chat/chat/state/types.py,sha256=iMovPXnRvZJ8ieM5gPnTBi1X7j-9GUtziiPBZJJf034,794
|
|
112
|
+
ommlds/cli/sessions/chat/chat/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
113
|
+
ommlds/cli/sessions/chat/chat/user/inject.py,sha256=x0DV0kMxEiHVTjQwsQlW4wKHfACu0Nlnhbsc4Uum_wI,2164
|
|
114
|
+
ommlds/cli/sessions/chat/chat/user/interactive.py,sha256=AZ8v5uGscnNk4KJdGisOA2LND8m7473fY5Whks7M_tI,688
|
|
115
|
+
ommlds/cli/sessions/chat/chat/user/oneshot.py,sha256=jPrZBBuf-olBfPF7CPTYK7-Dr7EvSriU7L0nORHfbv4,588
|
|
116
|
+
ommlds/cli/sessions/chat/chat/user/types.py,sha256=MNlhMxlLtxVod9rUZlSPvRaippPAXEdX_GHh73QLeSg,262
|
|
117
|
+
ommlds/cli/sessions/chat/content/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
118
|
+
ommlds/cli/sessions/chat/content/messages.py,sha256=DhGIBdPXXiQdKcQkPKFJPmhdL2CBHvyoVWhSKBRVMY0,939
|
|
119
|
+
ommlds/cli/sessions/chat/content/strings.py,sha256=PyaHeUnAAuhOyJr7F7G4xupUOQLs7_iOd74wFNHTkfg,1055
|
|
120
|
+
ommlds/cli/sessions/chat/phases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
121
|
+
ommlds/cli/sessions/chat/phases/inject.py,sha256=m9GcCVcp1GnNKN1qwDSgTkfp3e107wXgPeEHDLbfG8s,448
|
|
122
|
+
ommlds/cli/sessions/chat/phases/injection.py,sha256=ZUFRRLp3HNhKaPBW6aiw5XFEGNkqTj8WVSlXM0kg0y0,326
|
|
123
|
+
ommlds/cli/sessions/chat/phases/manager.py,sha256=_wfc0FfL5h_5L-6hnYb3U3kiRmkGDkJu7wGj5Cgz7_Y,727
|
|
124
|
+
ommlds/cli/sessions/chat/phases/types.py,sha256=w1pAEydJYaHzSzdlqygCwKxvVZnfo_R_xJqq8wBzZsQ,512
|
|
125
|
+
ommlds/cli/sessions/chat/rendering/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
126
|
+
ommlds/cli/sessions/chat/rendering/inject.py,sha256=Yo_BDxDNbTge8UtEp31uTKhsFdaeVf-4CFs3rdu8l0I,885
|
|
127
|
+
ommlds/cli/sessions/chat/rendering/markdown.py,sha256=C4z9Rs0ivVTrBmu7lFnybNOq1j9hEZb58Gc_R8rmcUI,1803
|
|
128
|
+
ommlds/cli/sessions/chat/rendering/raw.py,sha256=L7RIY77dycZRTspWJC4Vj4fP9I-vdqo_0qe_8bj-0QQ,2432
|
|
129
|
+
ommlds/cli/sessions/chat/rendering/types.py,sha256=6wzYeitDGVufrf0W-R2cuwcBscPf9yPl0HtiCd7am2Q,449
|
|
130
|
+
ommlds/cli/sessions/chat/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
131
|
+
ommlds/cli/sessions/chat/tools/confirmation.py,sha256=I_nYBIIoeprCShUaVpN4v01YOAdY6iJEM5-ybc0p8VA,1072
|
|
132
|
+
ommlds/cli/sessions/chat/tools/execution.py,sha256=4sRuZWZjNBo852hhLZjqTqEZpgu9KPXHEawiICIMUdc,1576
|
|
133
|
+
ommlds/cli/sessions/chat/tools/inject.py,sha256=iKBvMrgmFCkgjD0MWtIQFuoiijfRwmhfFW1l6q5Fnd0,3845
|
|
134
|
+
ommlds/cli/sessions/chat/tools/injection.py,sha256=xsVbJAKsDIP-2LbzDXZ3LBJgeY0FJ66UuCK0OYB1uw0,837
|
|
135
|
+
ommlds/cli/sessions/chat/tools/rendering.py,sha256=a9gIhxuGF9tfXGlkGXpdweSz4dacIsxoqJNKpRSvUN4,1402
|
|
136
|
+
ommlds/cli/sessions/chat/tools/weather.py,sha256=vZXOHdRGGlkDEXasW5foc58MyEMOc79bhIfIgrumRlo,302
|
|
98
137
|
ommlds/cli/sessions/completion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
99
138
|
ommlds/cli/sessions/completion/completion.py,sha256=2ZrzmHBCF3mG13ABcoiHva6OUzPpdF7qzByteaLNsxk,1077
|
|
100
139
|
ommlds/cli/sessions/embedding/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
140
|
ommlds/cli/sessions/embedding/embedding.py,sha256=9U5Maj-XI5nsrk7m-O3P2rZggey0z2p7onZn2QfQe38,1051
|
|
102
|
-
ommlds/cli/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
103
|
-
ommlds/cli/tools/config.py,sha256=aEssMUVNR0yy9v9yXJm3MOohb97Gx26jrOg2QHZuFbo,272
|
|
104
|
-
ommlds/cli/tools/inject.py,sha256=L30UvDCyXjt4gB1snatp7xx-VF4nlBiewS10Hnaq76c,1938
|
|
105
|
-
ommlds/cli/tools/weather.py,sha256=FUPxPF5KBbbyK3voBtcRUOkuMO2zK5GFZoFTJMaM6LQ,300
|
|
106
141
|
ommlds/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
107
142
|
ommlds/datasets/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
108
143
|
ommlds/datasets/lib/movies.py,sha256=LmdfoXsZU9XMM_r-sxCLv_s06BFzwWO4xUj6sc9XVcI,1961
|
|
@@ -325,9 +360,9 @@ ommlds/wiki/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
325
360
|
ommlds/wiki/utils/io.py,sha256=UKgDJGtmpnWvIqVd2mJc2QNPOqlToEY1GEveNp6_pMo,7088
|
|
326
361
|
ommlds/wiki/utils/progress.py,sha256=EhvKcMFYtsarCQhIahlO6f0SboyAKP3UwUyrnVnP-Vk,3222
|
|
327
362
|
ommlds/wiki/utils/xml.py,sha256=vVV8Ctn13aaRM9eYfs9Wd6rHn5WOCEUzQ44fIhOvJdg,3754
|
|
328
|
-
ommlds-0.0.0.
|
|
329
|
-
ommlds-0.0.0.
|
|
330
|
-
ommlds-0.0.0.
|
|
331
|
-
ommlds-0.0.0.
|
|
332
|
-
ommlds-0.0.0.
|
|
333
|
-
ommlds-0.0.0.
|
|
363
|
+
ommlds-0.0.0.dev464.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
364
|
+
ommlds-0.0.0.dev464.dist-info/METADATA,sha256=tgOdigb0BtGCCBTpaDgfW0Rog8sK9jpRUYW1jsIxMxo,3224
|
|
365
|
+
ommlds-0.0.0.dev464.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
366
|
+
ommlds-0.0.0.dev464.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
|
|
367
|
+
ommlds-0.0.0.dev464.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
|
|
368
|
+
ommlds-0.0.0.dev464.dist-info/RECORD,,
|
ommlds/cli/sessions/chat/base.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
import typing as ta
|
|
3
|
-
|
|
4
|
-
from omlish import lang
|
|
5
|
-
|
|
6
|
-
from .... import minichain as mc
|
|
7
|
-
from ..base import Session
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
DEFAULT_CHAT_MODEL_BACKEND = 'openai'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ChatOption: ta.TypeAlias = mc.ChatChoicesOptions
|
|
20
|
-
ChatOptions = ta.NewType('ChatOptions', ta.Sequence[ChatOption])
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ChatSessionConfigT = ta.TypeVar('ChatSessionConfigT', bound='ChatSession.Config')
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class ChatSession(Session[ChatSessionConfigT], lang.Abstract, ta.Generic[ChatSessionConfigT]):
|
|
30
|
-
@dc.dataclass(frozen=True)
|
|
31
|
-
class Config(Session.Config, lang.Abstract):
|
|
32
|
-
_: dc.KW_ONLY
|
|
33
|
-
|
|
34
|
-
markdown: bool = False
|
|
35
|
-
|
|
36
|
-
dangerous_no_tool_confirmation: bool = False
|
|
37
|
-
|
|
38
|
-
def __init__(
|
|
39
|
-
self,
|
|
40
|
-
config: ChatSessionConfigT,
|
|
41
|
-
) -> None:
|
|
42
|
-
super().__init__(config)
|
ommlds/cli/sessions/chat/code.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
import itertools
|
|
3
|
-
import os.path
|
|
4
|
-
|
|
5
|
-
from omlish import check
|
|
6
|
-
from omlish import lang
|
|
7
|
-
|
|
8
|
-
from .... import minichain as mc
|
|
9
|
-
from ....minichain.lib.code.prompts import CODE_AGENT_SYSTEM_PROMPT
|
|
10
|
-
from ...tools.config import ToolsConfig
|
|
11
|
-
from .base import DEFAULT_CHAT_MODEL_BACKEND
|
|
12
|
-
from .base import ChatOptions
|
|
13
|
-
from .base import ChatSession
|
|
14
|
-
from .printing import ChatSessionPrinter
|
|
15
|
-
from .state import ChatStateManager
|
|
16
|
-
from .tools import ToolUseExecutor
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class CodeChatSession(ChatSession['CodeChatSession.Config']):
|
|
23
|
-
@dc.dataclass(frozen=True)
|
|
24
|
-
class Config(ChatSession.Config):
|
|
25
|
-
_: dc.KW_ONLY
|
|
26
|
-
|
|
27
|
-
new: bool = False
|
|
28
|
-
|
|
29
|
-
backend: str | None = None
|
|
30
|
-
model_name: str | None = None
|
|
31
|
-
|
|
32
|
-
initial_message: mc.Content | None = None
|
|
33
|
-
|
|
34
|
-
def __init__(
|
|
35
|
-
self,
|
|
36
|
-
config: Config,
|
|
37
|
-
*,
|
|
38
|
-
state_manager: ChatStateManager,
|
|
39
|
-
chat_options: ChatOptions | None = None,
|
|
40
|
-
printer: ChatSessionPrinter,
|
|
41
|
-
backend_catalog: mc.BackendCatalog,
|
|
42
|
-
tool_exec_request_executor: ToolUseExecutor,
|
|
43
|
-
tools_config: ToolsConfig | None = None,
|
|
44
|
-
) -> None:
|
|
45
|
-
super().__init__(config)
|
|
46
|
-
|
|
47
|
-
self._state_manager = state_manager
|
|
48
|
-
self._chat_options = chat_options
|
|
49
|
-
self._printer = printer
|
|
50
|
-
self._backend_catalog = backend_catalog
|
|
51
|
-
self._tool_exec_request_executor = tool_exec_request_executor
|
|
52
|
-
self._tools_config = tools_config
|
|
53
|
-
|
|
54
|
-
async def run(self) -> None:
|
|
55
|
-
if self._config.new:
|
|
56
|
-
self._state_manager.clear_state()
|
|
57
|
-
state = self._state_manager.extend_chat([
|
|
58
|
-
mc.SystemMessage(CODE_AGENT_SYSTEM_PROMPT),
|
|
59
|
-
])
|
|
60
|
-
|
|
61
|
-
else:
|
|
62
|
-
state = self._state_manager.get_state()
|
|
63
|
-
|
|
64
|
-
backend = self._config.backend
|
|
65
|
-
if backend is None:
|
|
66
|
-
backend = DEFAULT_CHAT_MODEL_BACKEND
|
|
67
|
-
|
|
68
|
-
# FIXME: lol
|
|
69
|
-
from ....minichain.lib.fs.context import FsContext
|
|
70
|
-
fs_tool_context = FsContext(
|
|
71
|
-
root_dir=os.getcwd(),
|
|
72
|
-
writes_permitted=self._tools_config is not None and self._tools_config.enable_unsafe_tools_do_not_use_lol,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
from ....minichain.lib.todo.context import TodoContext
|
|
76
|
-
todo_tool_context = TodoContext()
|
|
77
|
-
|
|
78
|
-
mdl: mc.ChatChoicesService
|
|
79
|
-
async with lang.async_maybe_managing(self._backend_catalog.get_backend(
|
|
80
|
-
mc.ChatChoicesService,
|
|
81
|
-
backend,
|
|
82
|
-
*([mc.ModelName(mn)] if (mn := self._config.model_name) is not None else []),
|
|
83
|
-
)) as mdl:
|
|
84
|
-
for i in itertools.count():
|
|
85
|
-
if not i and self._config.initial_message is not None:
|
|
86
|
-
req_msg = mc.UserMessage(self._config.initial_message)
|
|
87
|
-
else:
|
|
88
|
-
try:
|
|
89
|
-
prompt = input('> ') # FIXME: async lol
|
|
90
|
-
except EOFError:
|
|
91
|
-
break
|
|
92
|
-
req_msg = mc.UserMessage(prompt)
|
|
93
|
-
|
|
94
|
-
state = self._state_manager.extend_chat([req_msg])
|
|
95
|
-
|
|
96
|
-
while True:
|
|
97
|
-
response = await mdl.invoke(mc.ChatChoicesRequest(
|
|
98
|
-
state.chat,
|
|
99
|
-
(self._chat_options or []),
|
|
100
|
-
))
|
|
101
|
-
|
|
102
|
-
tool_resp_lst = []
|
|
103
|
-
for resp_msg in check.single(response.v).ms:
|
|
104
|
-
state = self._state_manager.extend_chat([resp_msg])
|
|
105
|
-
|
|
106
|
-
if isinstance(resp_msg, mc.AiMessage):
|
|
107
|
-
self._printer.print(resp_msg)
|
|
108
|
-
|
|
109
|
-
elif isinstance(resp_msg, mc.ToolUseMessage):
|
|
110
|
-
trm = await self._tool_exec_request_executor.execute_tool_use(
|
|
111
|
-
resp_msg.tu,
|
|
112
|
-
fs_tool_context,
|
|
113
|
-
todo_tool_context,
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
self._printer.print(trm.tur.c)
|
|
117
|
-
tool_resp_lst.append(trm)
|
|
118
|
-
|
|
119
|
-
else:
|
|
120
|
-
raise TypeError(resp_msg)
|
|
121
|
-
|
|
122
|
-
if not tool_resp_lst:
|
|
123
|
-
break
|
|
124
|
-
|
|
125
|
-
state = self._state_manager.extend_chat(tool_resp_lst)
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
|
|
3
|
-
from omlish import check
|
|
4
|
-
from omlish import lang
|
|
5
|
-
|
|
6
|
-
from .... import minichain as mc
|
|
7
|
-
from .base import DEFAULT_CHAT_MODEL_BACKEND
|
|
8
|
-
from .base import ChatSession
|
|
9
|
-
from .printing import ChatSessionPrinter
|
|
10
|
-
from .state import ChatStateManager
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class InteractiveChatSession(ChatSession['InteractiveChatSession.Config']):
|
|
17
|
-
@dc.dataclass(frozen=True)
|
|
18
|
-
class Config(ChatSession.Config):
|
|
19
|
-
_: dc.KW_ONLY
|
|
20
|
-
|
|
21
|
-
new: bool = False
|
|
22
|
-
|
|
23
|
-
backend: str | None = None
|
|
24
|
-
model_name: str | None = None
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
config: Config,
|
|
29
|
-
*,
|
|
30
|
-
state_manager: ChatStateManager,
|
|
31
|
-
printer: ChatSessionPrinter,
|
|
32
|
-
backend_catalog: mc.BackendCatalog,
|
|
33
|
-
) -> None:
|
|
34
|
-
super().__init__(config)
|
|
35
|
-
|
|
36
|
-
self._state_manager = state_manager
|
|
37
|
-
self._printer = printer
|
|
38
|
-
self._backend_catalog = backend_catalog
|
|
39
|
-
|
|
40
|
-
async def run(self) -> None:
|
|
41
|
-
if self._config.new:
|
|
42
|
-
state = self._state_manager.clear_state()
|
|
43
|
-
else:
|
|
44
|
-
state = self._state_manager.get_state()
|
|
45
|
-
|
|
46
|
-
backend = self._config.backend
|
|
47
|
-
if backend is None:
|
|
48
|
-
backend = DEFAULT_CHAT_MODEL_BACKEND
|
|
49
|
-
|
|
50
|
-
mdl: mc.ChatChoicesService
|
|
51
|
-
async with lang.async_maybe_managing(self._backend_catalog.get_backend(
|
|
52
|
-
mc.ChatChoicesService,
|
|
53
|
-
backend,
|
|
54
|
-
*([mc.ModelName(mn)] if (mn := self._config.model_name) is not None else []),
|
|
55
|
-
)) as mdl:
|
|
56
|
-
while True:
|
|
57
|
-
try:
|
|
58
|
-
prompt = input('> ') # FIXME: async lol
|
|
59
|
-
except EOFError:
|
|
60
|
-
break
|
|
61
|
-
|
|
62
|
-
req_msg = mc.UserMessage(prompt)
|
|
63
|
-
|
|
64
|
-
response = await mdl.invoke(mc.ChatChoicesRequest([*state.chat, req_msg]))
|
|
65
|
-
|
|
66
|
-
resp_msg = check.isinstance(check.single(response.v[0].ms), mc.AiMessage)
|
|
67
|
-
|
|
68
|
-
self._printer.print(resp_msg)
|
|
69
|
-
|
|
70
|
-
state = self._state_manager.extend_chat([req_msg, resp_msg])
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import abc
|
|
2
|
-
import typing as ta
|
|
3
|
-
|
|
4
|
-
from omdev.tui import rich
|
|
5
|
-
from omlish import check
|
|
6
|
-
from omlish import lang
|
|
7
|
-
from omlish.formats import json
|
|
8
|
-
|
|
9
|
-
from .... import minichain as mc
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class ChatSessionPrinter(lang.Abstract):
|
|
16
|
-
@abc.abstractmethod
|
|
17
|
-
def print(self, obj: mc.Message | mc.Content) -> None:
|
|
18
|
-
raise NotImplementedError
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class StringChatSessionPrinter(ChatSessionPrinter, lang.Abstract):
|
|
25
|
-
@abc.abstractmethod
|
|
26
|
-
def _print_str(self, s: str) -> None:
|
|
27
|
-
raise NotImplementedError
|
|
28
|
-
|
|
29
|
-
def print(self, obj: mc.Message | mc.Content) -> None:
|
|
30
|
-
if obj is None:
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
elif isinstance(obj, mc.Message):
|
|
34
|
-
if isinstance(obj, mc.SystemMessage):
|
|
35
|
-
if obj.c is not None:
|
|
36
|
-
self._print_str(check.isinstance(obj.c, str))
|
|
37
|
-
elif isinstance(obj, mc.UserMessage):
|
|
38
|
-
if obj.c is not None:
|
|
39
|
-
self._print_str(check.isinstance(obj.c, str))
|
|
40
|
-
elif isinstance(obj, mc.AiMessage):
|
|
41
|
-
if obj.c is not None:
|
|
42
|
-
self._print_str(check.isinstance(obj.c, str))
|
|
43
|
-
elif isinstance(obj, mc.ToolUseResultMessage):
|
|
44
|
-
self._print_str(check.isinstance(obj.tur.c, str))
|
|
45
|
-
else:
|
|
46
|
-
raise TypeError(obj)
|
|
47
|
-
|
|
48
|
-
elif isinstance(obj, mc.JsonContent):
|
|
49
|
-
self._print_str(json.dumps_pretty(obj.v))
|
|
50
|
-
|
|
51
|
-
elif isinstance(obj, str):
|
|
52
|
-
self._print_str(obj)
|
|
53
|
-
|
|
54
|
-
else:
|
|
55
|
-
raise TypeError(obj)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class SimpleStringChatSessionPrinter(StringChatSessionPrinter):
|
|
62
|
-
def __init__(
|
|
63
|
-
self,
|
|
64
|
-
*,
|
|
65
|
-
str_printer: ta.Callable[[str], None] | None = None,
|
|
66
|
-
) -> None:
|
|
67
|
-
super().__init__()
|
|
68
|
-
|
|
69
|
-
if str_printer is None:
|
|
70
|
-
str_printer = print
|
|
71
|
-
self._str_printer = str_printer
|
|
72
|
-
|
|
73
|
-
def _print_str(self, s: str) -> None:
|
|
74
|
-
s = s.strip()
|
|
75
|
-
if not s:
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
self._str_printer(s)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
class MarkdownStringChatSessionPrinter(StringChatSessionPrinter):
|
|
85
|
-
def _print_str(self, s: str) -> None:
|
|
86
|
-
s = s.strip()
|
|
87
|
-
if not s:
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
rich.Console().print(rich.Markdown(s))
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
##
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class StreamPrinter(lang.ExitStacked, lang.Abstract):
|
|
97
|
-
@abc.abstractmethod
|
|
98
|
-
def feed(self, s: str) -> None:
|
|
99
|
-
raise NotImplementedError
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
class SimpleStreamPrinter(StreamPrinter):
|
|
106
|
-
def feed(self, s: str) -> None:
|
|
107
|
-
print(s, end='', flush=True)
|
|
108
|
-
|
|
109
|
-
def _exit_contexts(self) -> None:
|
|
110
|
-
super()._exit_contexts()
|
|
111
|
-
print(flush=True)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class MarkdownStreamPrinter(StreamPrinter):
|
|
118
|
-
def __init__(self) -> None:
|
|
119
|
-
super().__init__()
|
|
120
|
-
|
|
121
|
-
def _enter_contexts(self) -> None:
|
|
122
|
-
super()._enter_contexts()
|
|
123
|
-
self._ir: rich.MarkdownLiveStream = self._enter_context(rich.IncrementalMarkdownLiveStream())
|
|
124
|
-
|
|
125
|
-
def feed(self, s: str) -> None:
|
|
126
|
-
self._ir.feed(s)
|